aboutsummaryrefslogtreecommitdiff
path: root/sysutils/ioc/files/ioc.in
blob: 639db9875cc0e05ab8e37c3b74fca31f1cbe4959 (plain) (blame)
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
#!/bin/sh

# PROVIDE: ioc
# REQUIRE: LOGIN cleanvar sshd ZFS
# BEFORE:  securelevel
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable ioc start on boot:
#
# ioc_enable="YES"
#

. /etc/rc.subr

name="ioc"
rcvar=ioc_enable

# read configuration and set defaults
load_rc_config "$name"
: ${ioc_enable="NO"}
: ${ioc_lang="en_US.UTF-8"}

start_cmd="ioc_start"
stop_cmd="ioc_stop"
status_cmd="ioc_status"
extra_commands="status"
export LANG=$ioc_lang

[ $# -ne 1 ] && rc_usage $_keywords

ioc_start()
{
    if checkyesno ${rcvar}; then
        echo "* [ioc] starting jails... "
        %%PREFIX%%/bin/ioc start --rc
    fi
}

ioc_stop()
{
    if checkyesno ${rcvar}; then
        echo "* [ioc] stopping jails... "
        %%PREFIX%%/bin/ioc stop --rc
    fi
}

ioc_status()
{
    if checkyesno ${rcvar}; then
        echo -n "* [ioc] checking jails status..."
	test -z "$(%%PREFIX%%/bin/ioc list boot=yes running=no template=no,- --no-header --output=name --output-format=list)"
	status=$?
	if test ${status} -eq 0; then
            echo " OK"
	else
            echo " Failed!"
	fi
	exit $status
    fi
}

run_rc_command "$1"