summaryrefslogtreecommitdiff
path: root/sysutils/pot/files/pot.in
blob: 72ec8ec13727d51ff9360785f68e4f6a089dcdbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh

# PROVIDE: pot
# REQUIRE: NETWORKING LOGIN FILESYSTEM
# BEFORE: securelevel
# KEYWORD: shutdown nojail

. /etc/rc.subr

PATH=$PATH:%%PREFIX%%/bin
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"

load_rc_config $name
: ${pot_enable:=NO}

pot_start()
{
	local _pname _dyn_pot_list _start
	_dyn_pot_list=$(%%PREFIX%%/bin/pot ls -q)
	for _pname in $_dyn_pot_list ; do
		if [ "$( %%PREFIX%%/bin/pot get-attr -p "$_pname" -A start-at-boot -q )" = "YES" ]; then
			%%PREFIX%%/bin/pot start "$_pname"
		fi
	done
}

pot_stop()
{
	local _pname _dyn_pot_list _start
	_dyn_pot_list=$(%%PREFIX%%/bin/pot ls -q)
	for _pname in $_dyn_pot_list ; do
		if [ "$( %%PREFIX%%/bin/pot get-attr -p "$_pname" -A start-at-boot -q )" = "YES" ]; then
			%%PREFIX%%/bin/pot stop "$_pname"
		fi
	done
}

pot_early_start()
{
	local _pname _dyn_pot_list _start
	_dyn_pot_list=$(%%PREFIX%%/bin/pot ls -q)
	for _pname in $_dyn_pot_list ; do
		if [ "$( %%PREFIX%%/bin/pot get-attr -p "$_pname" -A early-start-at-boot -q )" = "YES" ]; then
			%%PREFIX%%/bin/pot start "$_pname"
		fi
	done
}

pot_early_stop()
{
	local _pname _dyn_pot_list _start
	_dyn_pot_list=$(%%PREFIX%%/bin/pot ls -q)
	for _pname in $_dyn_pot_list ; do
		if [ "$( %%PREFIX%%/bin/pot get-attr -p "$_pname" -A early-start-at-boot -q )" = "YES" ]; then
			%%PREFIX%%/bin/pot stop "$_pname"
		fi
	done
}

pot_restart()
{
	pot_stop
	pot_early_stop
	sleep 5
	pot_early_start
	pot_start
}

pot_status()
{
	local _pname _dyn_pot_list
	for _pname in $_dyn_pot_list ; do
		if [ "$( %%PREFIX%%/bin/pot get-attr -p "$_pname" -A early-start-at-boot -q )" = "YES" ] ||
		   [ "$( %%PREFIX%%/bin/pot get-attr -p "$_pname" -A start-at-boot -q )" = "YES" ]; then
			if %%PREFIX%%/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"