tool/run: Wake On Lan support

Fix #2509
This commit is contained in:
Emery Hemingway 2017-08-23 17:39:20 -05:00 committed by Christian Helmuth
parent 68cd5e8004
commit 9bfc29e456
1 changed files with 38 additions and 0 deletions

38
tool/run/power_on/wol Normal file
View File

@ -0,0 +1,38 @@
##
# Power on the target machine via magic Wake On Lan packets
#
# \param --power-on-wol-mac MAC address of target machine
#
# \param --power-on-wol-dev Outgoing network interface
#
source [genode_dir]/tool/run/amt.inc
proc power_on_wol_mac { } {
return [get_cmd_arg_first --power-on-wol-mac ""]
}
proc power_on_wol_dev { } {
return [get_cmd_arg_first --power-on-wol-dev "eth0"]
}
proc run_power_on { } {
if {[power_on_wol_mac] == ""} {
puts stderr {wake-on-lan MAC address not specified}
exit -1
}
if {![have_installed etherwake]} {
puts stderr {'etherwake' utitity for using wake-on-lan is not installed}
exit -1
}
puts "sending magic WOL packet..."
exec sudo ip link set [power_on_wol_dev] up
exec sudo etherwake -i [power_on_wol_dev] [power_on_wol_mac]
return true
}