O script de inicialização no Debian 8 (Jessie) com etherwake não funciona

O script de inicialização no Debian 8 (Jessie) com etherwake não funciona

Estou tentando ativar remotamente uma máquina escrava quando o mestre inicializa por meio de um script bash usando o etherwakecomando para enviar pacotes mágicos. Ambos os sistemas operacionais são Debian 8. O código completo está escrito abaixo:

/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

Depois de escrever o roteiro, eu fiz:

  1. chmod 755 /etc/init.d/etherwake
  2. update-rc.d etherwake defaults
  3. Reinicie o sistema atravésshutdown -r now

Também tentei usar /etc/rc.localde 3 maneiras diferentes:

/etc/rc.local

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

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

Sem sorte alguma. Quando executo /etc/rc.localmanualmente /etc/init.d/etherwakecomo root, tudo funciona bem. Eu pensei que poderia ser algo com as permissões, mas pelo que li, qualquer script é /etc/init.dexecutado como root por padrão. O que estou fazendo de errado?

Desde já, obrigado.


Editar:

Eu entendo que o Debian 8 usa systemd em vez de sysvinit. Depois de configurar tudo systemctl -l status etherwake.serviceme dá:

● 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.

E /etc/systemd/system/etherwake.serviceé:

[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

Outra coisa que notei é que correr systemctl restart etherwakefunciona perfeitamente.

Responder1

O problema é que update-rc.d etherwake defaultstalvez não funcione. Tente habilitar o serviço via systemctl, execute:

systemctl enable etherwake

informação relacionada