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

Re: How to install init scripts manually?



On 8/4/14, Gary Dale <garydale@torfree.net> wrote:
> 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.
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org
> Archive: [🔎] 53DFA8A4.3040507@torfree.net">https://lists.debian.org/[🔎] 53DFA8A4.3040507@torfree.net
>
>

Gary,

yes I checked the ownership and permission differences between
manually created symlinks and the ones created by insserv, but there
were none. Both the actual script in /etc/init.d directory and
symlinks in /etc/rc*.d directories are owned by root. I even tried
this under the Wheezy:

root@vserver:~# cat /etc/issue
Debian GNU/Linux 7 \n \l

root@vserver:~#

..but still init(version 2.88) ignored the manually created symlinks.
I know that one should use insserv instead, but I was just curious why
init ignores manually created symlinks. In addition, I looked into
/etc/init.d/rc script which should be used to start scripts in
/etc/rc*.d directories and according to this script the actual utility
starting the services is startpar. Command is "startpar -p 4 -t 20 -T
3 -M $1 -P $previous -R $runlevel" where "$1" is either start, stop or
boot and "$previous" is a previous runlevel and "$runlevel" is a
runlevel where one enters.
Maybe someone who is an expert on SystemV init and startpar on
Squeeze/Wheezy could look into it and explain how does the bootup
process work and why manual symlinks do not work?



regards,
Martin


Reply to: