%EC%9D%98%20%EC%8B%9C%EC%9E%91%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EA%B0%80%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
etherwake
매직 패킷을 보내는 명령을 사용하여 bash 스크립트를 통해 마스터가 부팅될 때 슬레이브 시스템을 원격으로 깨우려고 합니다 . 두 OS 모두 Debian 8입니다. 전체 코드는 다음과 같습니다.
/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
스크립트를 작성한 후 다음을 수행했습니다.
chmod 755 /etc/init.d/etherwake
update-rc.d etherwake defaults
- 다음을 통해 시스템을 재부팅합니다.
shutdown -r now
/etc/rc.local
또한 3가지 다른 방법으로 사용해 보았습니다 .
/etc/rc.local
#!/bin/sh -e
#
# rc.local
/etc/init.d/etherwake
etherwake <MAC Address>
/usr/sbin/etherwake <MAC Address>
exit 0
전혀 행운이 없습니다. 루트로 /etc/rc.local
또는 수동으로 실행하면 모든 것이 잘 작동합니다. /etc/init.d/etherwake
권한이 있는 것일 수 있다고 생각했지만 스크립트를 읽는 한 /etc/init.d
기본적으로 루트로 실행됩니다. 내가 도대체 뭘 잘못하고있는 겁니까?
미리 감사드립니다.
편집하다:
나는 Debian 8이 sysvinit 대신 systemd를 사용한다는 것을 알고 있습니다. 모든 것을 설정한 후 다음을 systemctl -l status etherwake.service
제공합니다.
● 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.
그리고 /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
내가 깨달은 또 다른 점은 달리기가 systemctl restart etherwake
매력으로 작용한다는 것입니다.
답변1
문제는 update-rc.d etherwake defaults
어쩌면 작동하지 않을 수도 있다는 것입니다. 를 통해 서비스를 활성화하고 systemctl
다음을 실행하십시오.
systemctl enable etherwake