#!/bin/sh # $FreeBSD$ # PROVIDE: pot # REQUIRE: NETWORKING syslogd pf # BEFORE: ntpdate # KEYWORD: shutdown nojail . /etc/rc.subr name="pot" desc="Pot containers" procname="pot" rcvar=pot_enable start_cmd="pot_start" stop_cmd="pot_stop" restart_cmd="pot_restart" status_cmd="pot_status" start_precmd="pot_deprecated_start" stop_postcmd="pot_deprecated_stop" load_rc_config $name : ${pot_enable:=NO} : ${pot_list:=""} pot_deprecated_start() { if [ -n "$pot_list" ]; then echo "pot_list is deprecated! please use pot set-attr to set the start-at-boot attribute to your pot" fi } pot_deprecated_stop() { if [ -n "$pot_list" ]; then echo "pot_list is deprecated! please use pot set-attr to set the start-at-boot attribute to your pot" fi } pot_start() { local _pname _dyn_pot_list _start _dyn_pot_list=$(/usr/local/bin/pot ls -q) for _pname in $_dyn_pot_list ; do if _start=$( /usr/local/bin/pot get-attr -p "$_pname" -A start-at-boot -q ) && [ "$_start" = "YES" ]; then /usr/local/bin/pot start "$_pname" fi done } pot_stop() { local _pname _dyn_pot_list _start _dyn_pot_list=$(/usr/local/bin/pot ls -q) for _pname in $_dyn_pot_list ; do if _start=$( /usr/local/bin/pot get-attr -p "$_pname" -A start-at-boot -q ) && [ "$_start" = "YES" ]; then /usr/local/bin/pot stop "$_pname" fi done } pot_restart() { pot_stop pot_deprecated_stop sleep 5 pot_start pot_deprecated_start } pot_status() { local _pname _dyn_pot_list _start for _pname in $_dyn_pot_list ; do if _start=$( /usr/local/bin/pot get-attr -p "$_pname" -A start-at-boot -q ) && [ "$_start" = "YES" ]; then if /usr/local/bin/pot info -qrp "$_pname" ; then echo "pot $_pname is up and running" else echo "pot $_pname is not running" fi fi done } run_rc_command "$1"