:: Re: [DNG] init scripts
Página superior
Eliminar este mensaje
Responder a este mensaje
Autor: Rainer Weikusat
Fecha:  
A: dng
Asunto: Re: [DNG] init scripts
Martin Steigerwald <martin@???> writes:
> karl@??? - 01.08.23, 20:36:05 CEST:
>> > I just don't understand why it should take hundreds of
>> > lines of shellscript to run a simple command.
>>
>> For busybox I just use a handwritten /etc/rcS to do everything,
>> about 112 lines on my personal box, makes life very simple tough
>> not automatic.
>
> Some init scripts of SysVInit in Debian use a wrapper that can lead to init
> scripts as simple as:
>
> % cat /etc/init.d/fio
> #!/bin/sh
> # kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
> if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
>     set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
> fi
> ### BEGIN INIT INFO
> # Provides:          fio
> # Required-Start:    $syslog
> # Required-Stop:     $syslog
> # Default-Start:     2 3 4 5
> # Default-Stop:      0 1 6
> # Short-Description: Flexible I/O Tester as service
> # Description:       Runs fio as a service to that fio clients can connect
> #                    to it
> ### END INIT INFO

>
> # Author: Martin Steigerwald […]
>
> DESC="Flexible I/O Tester as service"
> DAEMON=/usr/bin/fio
> DAEMON_ARGS='--server --daemonize /run/fio.pid'
> PIDFILE='/run/fio.pid'


In this case, the mess has been pushed into something else. A typical
init script I'm using looks like this:

,----
| case "$1" in
|     start)
|         systemd-dance "$0" && exit 0
| 
|         starting ca-mgmt-client \
|                  mad-daemon -n chdir /home/$USER monitor -s -n ca-mgmt-client \
|                         chids -u $USER run-ca-mgmt-client
|         ;;
| 
|     stop)
|         monitor-ctrl ca-mgmt-client stop
|         ;;
| 
|     restart)
|         $0 stop
|         $0 start
|         ;;
| 
|     *)
|         printf 'Usage: ca-mgmt-client start|stop|restart\n' >&2
|         exit 1
|         ;;
| esac
| 
| exit 0

`----

[That's even with systemd support as I'm meanwhile forced to support it
professionally.]

There's little point in splitting this tiny bit of code into separate
files just because that's technically possible.
?
The historically accumulated mess in Linux init.d scripts is/ was indeed
fairly gruesome. But that's just an example of poor programming/
software design and in not way tied to the arrangement used for running
such scripts at certain times. Thus, the main argument of the
Poetterclown was that "Look what a mess you've made of the stuff you've
put into your old shelf! You absolutely need my New And Very Much
Improved Shelf[tm] because of this!"