Pages

Monday, May 27, 2013

OpenSprinkler Pi (OSPi) background Start/Stop/Restart init.d script

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:

  1. First You should be creating and saving the file in /etc/init.d
  2. sudo nano /etc/init.d/ospi
  3. After this you will want to make the script executable
  4. sudo chmod 755 /etc/init.d/ospi
  5. You can now go ahead and start your server
  6. sudo /etc/init.d/ospi start
  7. check status of the server
  8. sudo /etc/init.d/ospi status
  9. Test restart the server
  10. sudo /etc/init.d/ospi restart
  11. Test stopping the server
  12. sudo /etc/init.d/ospi stop
  13. And finally register script to be run at start-up
  14. sudo update-rc.d ospi defaults
  15. If you ever want to remove the script from start-up, run the following command:
  16. sudo update-rc.d -f  ospi remove