El script de inicio en Debian 8 (Jessie) con etherwake no funciona

El script de inicio en Debian 8 (Jessie) con etherwake no funciona

Estoy intentando reactivar remotamente una máquina esclava cuando el maestro arranca a través de un script bash usando el etherwakecomando para enviar paquetes mágicos. Ambos sistemas operativos son Debian 8. El código completo está escrito a continuación:

/etc/init.d/etherwake

#!/bin/sh
#/etc/init.d/etherwake

### BEGIN INIT INFO
# Provides: etherwake
# Required-Start: $all
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start etherwake at boot time
# Description: Enable service provided by etherwake.
### END INIT INFO

ETHERWAKE=/usr/sbin/etherwake

case "$1" in

        start)
                echo  "Booting slaves through etherwake..."
                $ETHERWAKE <MAC Address>
                echo  "Finished booting all slaves."
                ;;

        stop)
                echo "Stop not implemented. Doing nothing"
                ;;

        restart|force-reload)
                $0 stop
                sleep 10
                $0 start
                ;;

        *)
                echo "Usage: /etc/init.d/etherwake {start}"
                exit 1
                ;;
esac

exit 0

Después de escribir el guión, hice:

  1. chmod 755 /etc/init.d/etherwake
  2. update-rc.d etherwake defaults
  3. Reinicie el sistema medianteshutdown -r now

También intenté usarlo /etc/rc.localde 3 maneras diferentes:

/etc/rc.local

#!/bin/sh -e
#
# rc.local

/etc/init.d/etherwake
etherwake <MAC Address>
/usr/sbin/etherwake <MAC Address>
exit 0

No hubo suerte alguna. Cuando ejecuto manualmente /etc/rc.localo /etc/init.d/etherwakecomo root, todo funciona bien. Pensé que podría ser algo con los permisos, pero hasta donde leí, cualquier script /etc/init.dse ejecuta como root de forma predeterminada. ¿Qué estoy haciendo mal?

Gracias de antemano.


Editar:

Entiendo que Debian 8 usa systemd en lugar de sysvinit. Después de configurar todo systemctl -l status etherwake.serviceme da:

● etherwake.service - Etherwake magic packet service
   Loaded: loaded (/etc/systemd/system/etherwake.service; enabled)
   Active: inactive (dead) since Fri 2016-09-30 16:30:56 BRT; 1min 33s ago
  Process: 824 ExecStart=/etc/init.d/etherwake start (code=exited, status=0/SUCCESS)
 Main PID: 824 (code=exited, status=0/SUCCESS)

Sep 30 16:30:56 hostname etherwake[824]: Booting slaves through etherwake...
Sep 30 16:30:56 hostname etherwake[824]: Finished booting all slaves.

Y /etc/systemd/system/etherwake.servicees:

[Unit]
Description=Etherwake magic packet service
Wants=network-online.target
After=syslog.service network.target network-online.target

[Service]
ExecStart=/etc/init.d/etherwake start

[Install]
WantedBy=default.target

Otra cosa que noté es que correr systemctl restart etherwakefunciona de maravilla.

Respuesta1

El problema es que update-rc.d etherwake defaultstal vez no funcione. Intente habilitar el servicio a través de systemctl, ejecute:

systemctl enable etherwake

información relacionada