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

Run a small script at shutdown/reboot



Hello list, I have a small script (foobar.sh) which I would like to run
at shutdown or reboot:
______________________________
#!/bin/bash

if [ -a /test/foo.bar ]; then
        mv /test/foo.bar /test/foo.foo
fi
_____________________________

I placed the script into /etc/init.d/, made it executable, and upon
testing it, it does what it is supposed to do.

I then ran (update-rc.d foobar.sh start 0 6), but it threw up a bunch of
errors:

root@debian:/etc/init.d# update-rc.d foobar.sh start 0 6
update-rc.d: using dependency based boot sequencing
insserv: warning: script 'foobar.sh' missing LSB tags and overrides
insserv: There is a loop between service tlp and foobar.sh if stopped
insserv:  loop involving service foobar.sh at depth 2
insserv:  loop involving service tlp at depth 1
insserv: Stopping foobar.sh depends on tlp and therefore on system
facility `$all' which can not be true!
insserv: exiting now without changing boot order!
update-rc.d: error: insserv rejected the script header

With that not working, I tried to do it manually by creating a symlink
to /etc/init.d/foobar.sh in both rc0.d and rc6.d (calling them
K08foobar), and they have the same permissions and ownership as all of
the other symlinks in those directories, and I can also execute it from
there as well.

Unfortunately, when I shutdown or reboot the machine, it does not get
called.

So what am I missing here?   I'm guessing that using update-rc.d is
probably more heavy duty/involved than I need for this little script
(not to mention beyond my current understanding), but what else would
work?

Thanks for your suggestions,

Jon


Reply to: