%20con%20etherwake%20no%20funciona.png)
Estoy intentando reactivar remotamente una máquina esclava cuando el maestro arranca a través de un script bash usando el etherwake
comando 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:
chmod 755 /etc/init.d/etherwake
update-rc.d etherwake defaults
- Reinicie el sistema mediante
shutdown -r now
También intenté usarlo /etc/rc.local
de 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.local
o /etc/init.d/etherwake
como root, todo funciona bien. Pensé que podría ser algo con los permisos, pero hasta donde leí, cualquier script /etc/init.d
se 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.service
me 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.service
es:
[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 etherwake
funciona de maravilla.
Respuesta1
El problema es que update-rc.d etherwake defaults
tal vez no funcione. Intente habilitar el servicio a través de systemctl
, ejecute:
systemctl enable etherwake