I got my OpenSprinkler Pi (OSPi) v1.0 and Raspberry Pi (RPi) Rev.2 hooked-up and connected to internet via USB WiFi dongle. I wanted to run OpenSprinkler Pi (OSPi) Interval Program Demo application in the background automatically when RPi started. while looking for a good init.d script template, found this Simple init.d script template . I did some minor changers and sharing for whoever might be interested:
- First You should be creating and saving the file in /etc/init.d
- After this you will want to make the script executable
- You can now go ahead and start your server
- check status of the server
- Test restart the server
- Test stopping the server
- And finally register script to be run at start-up
- If you ever want to remove the script from start-up, run the following command:
sudo nano /etc/init.d/ospi
sudo chmod 755 /etc/init.d/ospi
sudo /etc/init.d/ospi start
sudo /etc/init.d/ospi status
sudo /etc/init.d/ospi restart
sudo /etc/init.d/ospi stop
sudo update-rc.d ospi defaults
sudo update-rc.d -f ospi remove