jaaassh
Dabbler
- Joined
- Apr 23, 2015
- Messages
- 49
TLDR: How can I shutdown freenas from the command line the same way the UI does?
------------------
My BIOS is configured s.t. WOL works. If I plug in my machine, and send the packet, the system turns on.
The UPS service, by default, shuts freenas down with "shutdown -p now"
-- This command, powers off the motherboard entirely. So, nothing is listening for the WOL packet.
I tried "shutdown -h now"
-- This shuts lots of things down, but ultimately leaves "press any key to reboot" on the screen. So, as far as the BIOS is concerned, the system is still up I can't remotely reboot things.
Using the freenas UI to shutdown actually shuts things down AND leaves the system in a state that WOL works... but it's not clear what freenas is doing under the hood to trigger that shutdown?
I found this thing: https://github.com/freenas/freenas/blob/master/src/freenas/etc/ix.rc.d/ix-shutdown
...which seems a bit different on my installed system:
...and it doesn't seem to do much:
# /etc/ix.rc.d/ix-shutdown
Usage: /etc/ix.rc.d/ix-shutdown [fast|force|one|quiet](start|stop|restart|rcvar|enabled|describe|extracommands|status|poll)
# /etc/ix.rc.d/ix-shutdown stop
#
Am I on the right track?
------------------
My BIOS is configured s.t. WOL works. If I plug in my machine, and send the packet, the system turns on.
The UPS service, by default, shuts freenas down with "shutdown -p now"
-- This command, powers off the motherboard entirely. So, nothing is listening for the WOL packet.
I tried "shutdown -h now"
-- This shuts lots of things down, but ultimately leaves "press any key to reboot" on the screen. So, as far as the BIOS is concerned, the system is still up I can't remotely reboot things.
Using the freenas UI to shutdown actually shuts things down AND leaves the system in a state that WOL works... but it's not clear what freenas is doing under the hood to trigger that shutdown?
I found this thing: https://github.com/freenas/freenas/blob/master/src/freenas/etc/ix.rc.d/ix-shutdown
...which seems a bit different on my installed system:
Code:
# cat /etc/ix.rc.d/ix-shutdown
#
# $FreeBSD$
#
# PROVIDE: ix-shutdown
# REQUIRE: LOGIN
# KEYWORD: shutdown
. /etc/rc.subr
execute_task()
{
local stype=$1
local f="ini_$stype"
eval local $f
local sf=$(var_to_sf $f)
${FREENAS_SQLITE_CMD} ${FREENAS_CONFIG} \
"SELECT $sf FROM tasks_initshutdown WHERE ini_when = 'shutdown' AND ini_enabled = 1 AND ini_type = '$stype' ORDER BY id" | \
while eval read -r $f; do
if [ "${stype}" = "command" ]; then
sh -c "${ini_command}" < /dev/null
else
if [ -e "${ini_script}" ]; then
sh -c "exec ${ini_script}" < /dev/null
fi
fi
done
}
do_shutdown()
{
RO_FREENAS_CONFIG=$(ro_sqlite ${name} 2> /tmp/${name}.fail && rm /tmp/${name}.fail)
trap 'rm -f ${RO_FREENAS_CONFIG}' EXIT
/usr/local/bin/midclt call core.event_send system ADDED '{"id": "shutting-down"}' > /dev/null
execute_task "command"
execute_task "script"
}
name="ix-shutdown"
start_cmd=':'
stop_cmd='do_shutdown'
load_rc_config $name
run_rc_command "$1"...and it doesn't seem to do much:
# /etc/ix.rc.d/ix-shutdown
Usage: /etc/ix.rc.d/ix-shutdown [fast|force|one|quiet](start|stop|restart|rcvar|enabled|describe|extracommands|status|poll)
# /etc/ix.rc.d/ix-shutdown stop
#
Am I on the right track?