I played around with a LSB init script under Debian Wheezy(init
is from sysvinit package version 2.88dsf-41+deb7u1) for learning purposes. My script is following:
# cat /etc/init.d/test-script
#! /bin/sh
### BEGIN INIT INFO
# Provides: test
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: test script
# Description: test script
### END INIT INFO
# always executes
touch /tmp/test-file
case "$1" in
start)
echo "Starting script test"
touch /tmp/test-file-start
;;
stop)
echo "Stopping script test"
touch /tmp/test-file-stop
;;
restart)
echo "Restarting script test"
touch /tmp/test-file-restart
;;
force-reload)
echo "Force-reloading script test"
touch /tmp/test-file-force-reload
;;
status)
echo "Status of test"
touch /tmp/test-file-status
;;
*)
echo "Usage: /etc/init.d/test {start|stop}"
exit 1
;;
esac
exit 0
#
I made the /etc/init.d/test-script
file executable and added a symlink to /etc/rc2.d/
directory:
lrwxrwxrwx 1 root root 21 Nov 2 13:19 /etc/rc2.d/S04test-script -> ../init.d/test-script
..as my default runlevel is 2 and reloaded the machine, but script was not started. As a final step I also added test
to /etc/init.d/.depend.start
file, but /etc/init.d/test-script
was still not executed during a bootup.
Which additional steps does insserv
take to install an init script?
insserv
works and what does it do. – Martin Nov 02 '15 at 15:12insserv test-script
command exactly does besides calculating the dependencies between theinit
scripts and creating corresponding symlinks to/etc/rc<runlevel>
directories based on the LSB header ininit
scripts. – Martin Nov 02 '15 at 16:07insserv
doesn't do nothing more what I have written in my initial post, then why doesn't the/etc/init.d/test-script
create the/tmp/test-file
and/tmp/test-file-start
files when the system boots into runlevel 2? – Martin Nov 02 '15 at 16:20test-script:
line to/etc/init.d/.depend.start
. – Martin Nov 03 '15 at 14:59