29th
Ubuntu boot time scripts with etc/init.d
I wanted to collect some of my learnings on how ubuntu/debian manages scripts at boot time.
First, /etc/rcRUN-LEVEL.d/NNname is a series of directories that are symlinked to the /etc/init.d/name actual boot script.
So, if you want a service or program to run at boot time first create the script at /etc/init.d/servicename and chmod it to be executable. You can find an example at /etc/init.d/skeleton
Set the appropriate runlevels directly in the script. The defaults should work for most users.
then run sudo update-rc.d servicename defaults and the appropriate symlinks will be added for you.
When you’re constructing your boot script, the LSB header tells update-rc.d what runlevels and what ORDER to run your daemons in. For our use which will be a onetime execution before self-destruction on the first boot of a vm template we want all other services to start first so we will add a ” Required-Start $all “