2012-09-28

mk802 -- insserv

How to add a service when using dependency-based booting

In Debian releases prior to 6.0, a service could be added with update-rc.d:

update-rc.d mydaemon defaults

Starting with Debian 6.0, the insserv command is used instead, if dependency-based booting is enabled:

insserv mydaemon

Where mydaemon is an executable init script placed in /etc/init.d. insserv will produce no output if everything went OK. Examine the error code in $? if you want to be sure.

Both the old and the new way requires an init script to be present in /etc/init.d. For dependency-based booting, the script needs to be an LSB init script.


1.
root@arm:~# ls -l /etc/init.d/ssh*
-rwxr-xr-x    1 root     root          2451 Sep 14 09:12 ssh
-rwxr-xr-x    1 root     root          3881 Feb 24  2012 ssh-bv1al

2.
root@arm:~# head /etc/init.d/ssh
#! /bin/sh

### BEGIN INIT INFO
# Provides:             sshd
# Required-Start:       $remote_fs $syslog
# Required-Stop:        $remote_fs $syslog
# Default-Start:        2 3 4 5
# Default-Stop:
# Short-Description:    OpenBSD Secure Shell server
### END INIT INFO

3.
root@arm:~# ls /etc/rc2.d /etc/rc3.d
/etc/rc2.d:
README       S01rsyslog  S03board_tweaks.sh  S03loadcpufreq   S05rc.local
S01bootlogs  S01sudo     S03cron             S03rsync         S05rmnologin
S01motd      S02apache2  S03dbus             S04cpufrequtils

/etc/rc3.d:
README       S01rsyslog  S03board_tweaks.sh  S03loadcpufreq   S05rc.local
S01bootlogs  S01sudo     S03cron             S03rsync         S05rmnologin
S01motd      S02apache2  S03dbus             S04cpufrequtils


4.
root@arm:~# insserv ssh
insserv: warning: script 'K01board_tweaks.sh' missing LSB tags and overrides
insserv: warning: script 'board_tweaks.sh' missing LSB tags and overrides
insserv: warning: script 'ssh-bv1al' missing LSB tags and overrides

5.
root@arm:~# ls /etc/rc2.d /etc/rc3.d
/etc/rc2.d:
README       S01rsyslog  S03board_tweaks.sh  S03loadcpufreq  S04cpufrequtils
S01bootlogs  S01sudo     S03cron             S03rsync        S05rc.local
S01motd      S02apache2  S03dbus             S03ssh          S05rmnologin

/etc/rc3.d:
README       S01rsyslog  S03board_tweaks.sh  S03loadcpufreq  S04cpufrequtils
S01bootlogs  S01sudo     S03cron             S03rsync        S05rc.local
S01motd      S02apache2  S03dbus             S03ssh          S05rmnologin
root@arm:~#