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

Re: How to install init scripts manually?



On 04/08/14 11:04 AM, Martin T wrote:

On 8/4/14, Gary Dale<garydale@torfree.net>  wrote:

On 04/08/14 06:30 AM, Martin T wrote:
Hi,

I played around with a LSB init script under Squeeze(init is from
sysvinit package version 2.88dsf-13.1+squeeze1) 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

#


As a next step, I made the /etc/init.d/test-script file executable and
added a symlink to/etc/rc3.d/("ln -s ../init.d/test-script
/etc/rc3.d/S23test-script") directory and changed my runlevel from
2(default) to 3 with "init 3". However, the test-script was not
started. Then I made a symlink to/etc/rc2.d/  directory:

# file /etc/rc2.d/S23test-script
/etc/rc2.d/S23test-script: symbolic link to `../init.d/test-script'
#

..and reloaded the machine, but still the script was not started. If I
install the script with insserv("insserv /etc/init.d/test-script")
then the script is started if I reload the machine. Am I correct that
both insserv and update-rc.d take some additional steps when enabling
the script besides installing the symlinks and those steps are
required by /sbin/init? I guess one thing is .depend.boot,
.depend.start and .depend.stop files, but something else?


regards,
Martin
Not sure what you mean by "reloaded the machine". However check out the
Debian wiki athttps://wiki.debian.org/RunLevel  and
https://wiki.debian.org/LSBInitScripts.

Did you try telinit instead of init?


Hi,

by "reloaded the machine" I meant that I executed the "reboot"
command. I did try with telinit, but at least on Squeeze this is just
a symlink to init:

# file /sbin/telinit
/sbin/telinit: symbolic link to `init'
#


OK. On Jessie it is a symbolic link to /bin/systemctl. The difference is likely important to provide a standard way to change run levels despite not everyone using init. Ditto for insserv which seems to have been created to allow upstart and init to coexist. update-rc.d seems to be an attempt to make updating the run-levels easier.

I'd recommend staying with the tools and not doing it directly for the simple reason that the old init system seems to be on its way out. The LSB comment mechanism may become obsolete too with systemd apparently on track to be the universal replacement for init and upstart.

As for your specific problem, did you look at ownership and specific permission differences between your manual s-links and the ones inserv and update-rc.d created? That's the only thing I can think of that would prevent a script from running when the symbolic links point to the correct file.


Reply to: