A quick dirty guide to init scripts on ubuntu
Start with the file
/etc/init.d/skeleton. It’s a template you can use that is already LSB compliant and contains all of the good stuff.
Make a copy and modify as you need
sudo cp /etc/init.d/skeleton /etc/init.d/myscript
sudo nano /etc/init.d/myscript
Make it executable
sudo chmod +x /etc/init.d/myscript
execute this command to add your new script to the list of default services to start on boot.
sudo update-rc.d myscript defaults
if you ever want to delete the service, invoke update-rc.d again
sudo update-rc.d -f myscript remove
- ubuntu man page for start-stop-daemon
- Debian documentation for LBSInitScripts
- An article on writing an init script for TeamCity, which was my first source for this article
- Debuntu.org: Manage services with update-rc.d