Fix command execution in network.send_wol to handle return values correctly.
This commit is contained in:
@@ -74,7 +74,7 @@ function network.port_is_up(host, port, timeout_sec, check_interval_sec)
|
||||
if (os.time() - start_time) < timeout then
|
||||
if not retry_message_sent then
|
||||
utils.log("Port " ..
|
||||
port .. " not yet available on " .. host .. ", retrying every " .. check_interval_sec .. "s...")
|
||||
port .. " not yet available on " .. host .. ", retrying every " .. check_interval_sec .. "s...")
|
||||
retry_message_sent = true
|
||||
end
|
||||
os.execute("sleep " .. check_interval_sec)
|
||||
@@ -148,8 +148,9 @@ function network.send_wol(mac_str, bcast_ip, port)
|
||||
if not network.is_socket_available() then
|
||||
utils.log("Socket module not available, using external wol tool")
|
||||
local cmd = string.format("wol -i %s -p %d %s", bcast_ip, port, mac_str)
|
||||
local result = os.execute(cmd)
|
||||
return result == 0, result ~= 0 and "wol command failed" or nil
|
||||
local ok, reason, code = os.execute(cmd)
|
||||
return ok and reason == "exit" and code == 0,
|
||||
(not ok or reason ~= "exit" or code ~= 0) and "wol command failed" or nil
|
||||
end
|
||||
|
||||
-- Create IPv4 UDP socket (udp4 if available), bind to IPv4 wildcard to lock AF_INET
|
||||
|
||||
Reference in New Issue
Block a user