[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Run script at boot time



On Wed, 20 Mar 2013 14:53:09 +0000
Tony van der Hoff <tony@vanderhoff.org> wrote:

> On 20/03/13 14:29, Adam Wolfe wrote:
> > I'd go with /etc/rc.local
> > That's what it is for.
> > 
> > 
> > On 03/20/2013 10:23 AM, Tony van der Hoff wrote:
> >> Hi,
> >>
> >> Running Squeeze, I would like to run a script
> >> (ltsp-update-sshkeys) on each system boot.
> >>
> >> Where would I place a link to such a script; /etc/init.d hardly
> >> seems appropriate? I'm guessing it needs to be run after
> >> networking has been set up in order to correctly generate the ssh
> >> keys for the chroot.
> >>
> >> I don't really understand the boot sequence nowadays. Any advice
> >> appreciated.
> >>
> 
> Thanks, all for your replies. I'll give rc.local a go!
> 
> 

If you just need to run something at boot *after* particular things are
done, and it doesn't matter what else has been done, this is the best
way.

If you ever have a script which should be run *before* certain other
init scripts, then you need to do it by the book.

Look at /etc/init.d/README for basic information, and there is plenty of
more detailed material on the Net. Broadly, you now don't need to work
out what S and K numbers you want, you just specify what you need your
script to run after, and/or before, and what runlevels you want.

The script sequence will be rebuilt at boot time, and the dependencies
solved to start things in the right order. As many things will be
started simultaneously as possible to minimise boot time, so the fewer
dependencies you can specify, the better. You can, of course, create a
dependency loop this way, so take a bit of care over this and check to
make sure your script does get run the first time. Remember that other
software can be upgraded and change its dependencies, so again, try to
minimise your script's dependencies for maximum reliability.

The /etc/init.d/.depend.X files are created at boot time, and show the
current dependency set, which may help in placing your own scripts.

This way, your script does go into /etc/init.d, so it is advised that
you name it personally to avoid any future clashes, e.g. my iptables
start/stop script is called jretrading.com-fw.

-- 
Joe


Reply to: