How to get update-rc.d or insserv to follow dependencies

Viewed 11427

I have been trying to set up a script to run at boot on a Debian 7.1 system for a while now with no luck. I've tried using both insserv and update-rc.d, but my issue seems to be the same with either tool. Here is the LSB portion of my script:

#!/bin/bash

### BEGIN INIT INFO
# Provides:             start_guest
# Required-Start:       $bootlogs $sudo $virtualbox-guest-utils $syslog
# Required-Stop:        $bootlogs $sudo $virtualbox-guest-utils $syslog
# Should-Start:
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    start_guest
### END INIT INFO

With update-rc.d, here are the various commands I have tried, all with the same result:

sudo update-rc.d start_guest defaults
sudo update-rc.d start_guest defaults 22
sudo update-rc.d start_guest start 22 2 3 4 5 . stop 78 2 3 4 5 .

No matter which one I run, I am told this (showing runlevel 2 only as 2,3,4,5 are the same and 0,1,6 are all K01):

insserv: remove service /etc/init.d/../rc2.d/S21rc.local
insserv: enable service ../init.d/rc.local -> /etc/init.d/../rc2.d/S20rc.local
insserv: remove service /etc/init.d/../rc2.d/S21rmnologin
insserv: enable service ../init.d/rmnologin -> /etc/init.d/../rc2.d/S20rmnologin
insserv: enable service ../init.d/start_guest -> /etc/init.d/../rc2.d/S17start_guest

I can't ever get it to start somewhere other than S17 no matter what kind of dependency information I get it. Unfortunately, ../rc2.d/S19bootlogs will be started after my script, which will prevent me from obtaining sometimes critical logging information.

When I attempt to do the same thing with insserv, I am told that normal services have been instructed to start my new service, but it still doesn't seem to be following dependency ordering. I need several more services to be running before start_guest starts running (things like sudo, virtualbox-guest-utils, etc.)

me@bronze:/etc/init.d# sudo insserv start_guest 
insserv: Service remote_fs has to be enabled to start service start_guest
insserv: Service syslog has to be enabled to start service start_guest
insserv: exiting now!

David Krmpotic's answer to this question almost answers mine, but it doesn't seem like even the "Required-Start" dependencies are being followed either.

How do I get my script to run at boot and follow the given dependencies? Thank you!

2 Answers
Related