Debian 8 (Jessie) の etherwake を使用した起動スクリプトが動作しない

Debian 8 (Jessie) の etherwake を使用した起動スクリプトが動作しない

私は、マジック パケットを送信するコマンドを使用して、bash スクリプトでマスターが起動したときにスレーブ マシンをリモートで起動しようとしていますetherwake。両方の OS は Debian 8 です。完全なコードは次のとおりです。

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

スクリプトを書いた後、私は次のことを行いました。

  1. chmod 755 /etc/init.d/etherwake
  2. update-rc.d etherwake defaults
  3. システムを再起動するshutdown -r now

私も/etc/rc.local3つの異なる方法で使用してみました:

ローカル

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

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

/etc/rc.localまったく運がありません。どちらかを手動で root として実行すると/etc/init.d/etherwake、すべてうまくいきます。権限に問題があるのではないかと考えましたが、私が読んだ限りでは、スクリプトはすべて/etc/init.dデフォルトで root として実行されます。何が間違っているのでしょうか?

前もって感謝します。


編集:

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

関連情報