My goal is to have the init system start a script called every time the Pi boots to multi-user mode (which hopefully will also mean that the network is available).

If you're following along at home, there's a good chance you don't want to mess around with my entire mouse logging project right now, so I'll write a quick Python script for testing purposes (based on this StackOverflow answer by Nathan Jhaveri).

You can paste or type the code into ~/ using Nano and mark it executable:

nano /home/pi/
import SocketServer
from BaseHTTPServer import BaseHTTPRequestHandler

class MyHandler(BaseHTTPRequestHandler):
    def do_GET(self):
        self.send_header("Content-type", "text/plain")

httpd = SocketServer.TCPServer(("", 80), MyHandler)
chmod +x ~/

All this does is create a very simple web server that, when you visit the Raspberry Pi's network address, returns an ASCII mouse. To test, I'll check my Pi's IP address, start the script, and use curl to make sure it's running. (I'm using tmux to open more than one shell.)

Your IP address will likely be different, but in my case this looks like so:

sudo ./

If  you're not on a network, you can just use localhost instead:

And if you want to test in a web browser, just enter the Pi's address in the URL bar:

Now that we have an example service, let's talk about how to start it.

This guide was first published on Sep 01, 2015. It was last updated on Sep 01, 2015.

This page (An Example Service: was last updated on Aug 27, 2015.

Text editor powered by tinymce.