-
Notifications
You must be signed in to change notification settings - Fork 33
Description
Is your feature request related to a problem? Please describe.
In our use-case, we don't start pots at system startup using the pot rc script (for various, site-specific reasons). At boot, not even the pot filesystem is available (so running any pot command at boot will cause errors).
We would still like to have them stopped cleanly on system shutdown.
Describe the feature you'd like to have
An rc script called pot-shutdown
#!/bin/sh
# PROVIDE: pot_shutdown
# REQUIRE: NETWORKING LOGIN FILESYSTEM
# BEFORE: securelevel
# KEYWORD: shutdown nojail
. /etc/rc.subr
PATH=$PATH:/usr/local/bin
name="pot_shutdown"
desc="Script to stop running pots"
rcvar=pot_shutdown_enable
start_cmd="pot_shutdown_noop"
stop_cmd="pot_shutdown_stop"
restart_cmd="pot_shutdown_noop"
status_cmd="pot_shutdown_status"
extra_commands="status"
load_rc_config $name
: ${pot_shutdown_enable:=NO}
pot_shutdown_noop()
{
echo "pot_shutdown can only stop things"
}
pot_shutdown_stop()
{
local _pname _dyn_pot_list
_dyn_pot_list=$(pot_shutdown_status)
if [ "$?" -eq 0 ]; then
for _pname in $_dyn_pot_list ; do
echo "Stopping $_pname..."
/usr/local/bin/pot stop "$_pname"
done
fi
}
pot_shutdown_status()
{
/usr/local/bin/pot show -rq
}
run_rc_command "$1"
NOTE: See how the command makes use of "pot show" instead of "pot list" - something we probably want to use in the pot rc script as well.
Describe potential alternatives or workaround you've considered (if any)
Maybe this could be integrated in the normal pot rc script - in general, the idea is to stop all running pots cleanly on system shutdown, but not start them (all) on boot.