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