Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pot-shutdown rc script #280

Open
grembo opened this issue Dec 18, 2023 · 0 comments
Open

Add pot-shutdown rc script #280

grembo opened this issue Dec 18, 2023 · 0 comments
Labels

Comments

@grembo
Copy link
Collaborator

grembo commented Dec 18, 2023

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.

@grembo grembo added the feature label Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant