[Pkg-sysvinit-devel] Make init.d/skeleton a very simple init.d script?

Henrique de Moraes Holschuh hmh at debian.org
Mon Feb 3 22:29:23 UTC 2014


On Mon, 03 Feb 2014, Petter Reinholdtsen wrote:
>   root at minerva:~# /etc/init.d/acpi-fakekey restart
>   [ ok ] Restarting acpi_fakekey daemon...done.
>   root at minerva:~# ./acpi-fakekey-new restart
>   [ ok ] Stopping acpi_fakekey daemon: acpi_fakekeyd.
>   [ ok ] Preparing to start acpi_fakekey daemon...done.
>   [ ok ] Starting acpi_fakekey daemon: acpi_fakekeyd.
>   root at minerva:~# 
> 
> Would such change be acceptable?  Here is the script in question
> reduced from 69 to 40 lines:

It is acceptable, however it is not optimal.  Some daemons, such as apache,
can be told to restart.  It is best if we implement restart as restart, not
as start-stop...

OTOH, we already support a restart override, so it really isn't a big deal.

> do_start_cmd_override() {
>     if [ -d /sys/devices/virtual/misc/uinput ]; then
> 	start-stop-daemon --start --quiet --oknodo --exec /usr/sbin/acpi_fakekeyd
>     else
> 	return 0
>     fi
> }

I really hate hackjobs of daemons that can't even support pidfiles properly.
Bleh.

> I guess the changed behaviour could be slightly changed by rewriting
> do_restart to use do_stop_cmd and do_start_cmd instead of do_stop and
> do_start, but am not sure it is a good idea.

We could also avoid the need to override start/stop when no pidfile support
is available, by doing the right thing when PIDFILE is not set, something
like this:

start-stop-daemon --start --quiet ${PIDFILE:+--pidfile ${PIDFILE}} --exec $DAEMON --test >/dev/null

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh



More information about the Pkg-sysvinit-devel mailing list