%20com%20etherwake%20n%C3%A3o%20funciona.png)
Estou tentando ativar remotamente uma máquina escrava quando o mestre inicializa por meio de um script bash usando o etherwake
comando 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:
chmod 755 /etc/init.d/etherwake
update-rc.d etherwake defaults
- Reinicie o sistema através
shutdown -r now
Também tentei usar /etc/rc.local
de 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.local
manualmente /etc/init.d/etherwake
como root, tudo funciona bem. Eu pensei que poderia ser algo com as permissões, mas pelo que li, qualquer script é /etc/init.d
executado 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.service
me 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 etherwake
funciona perfeitamente.
Responder1
O problema é que update-rc.d etherwake defaults
talvez não funcione. Tente habilitar o serviço via systemctl
, execute:
systemctl enable etherwake