Debian 8(Jessie)でetherwakeが機能しない起動スクリプト

Debian 8(Jessie)でetherwakeが機能しない起動スクリプト

etherwakebashスクリプトを介してマスターが起動したら、マジックパケットを送信するコマンドを使用してスレーブをリモートで起動しようとします。どちらのオペレーティングシステムも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

スクリプトを作成した後、次のことを行いました。

  1. chmod 755 /etc/init.d/etherwake
  2. update-rc.d etherwake defaults
  3. システムを再起動して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すべてのスクリプトはデフォルトで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

おすすめ記事