Roman Iten 5ebcf36d69 tool/run: introduce '[have_]cmd_arg'-procs
Renaming 'get_cmd_switch' and 'get_cmd_arg' to 'have_cmd_arg' and
'cmd_arg' respectively blends in nicely with the now omnipresent pattern
with 'have_[spec|board|installed|include]'.

This commit deprecates 'get_cmd_switch' and 'get_cmd_arg', which will be
removed in a later commit.

Issue #5432
2025-02-24 16:39:20 +01:00

39 lines
805 B
Plaintext

##
# 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 [cmd_arg_first --power-on-wol-mac ""]
}
proc power_on_wol_dev { } {
return [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
}