summaryrefslogtreecommitdiff
path: root/sysutils/bastille/files/bastille.in
blob: 17cf0df34948015409e38222ad53879b98baddc5 (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
#!/bin/sh

# Bastille jail startup script

# PROVIDE: bastille
# REQUIRE: LOGIN
# KEYWORD: shutdown

# Add the following to /etc/rc.conf[.local] to enable this service
#
# bastille_enable (bool):          Set to NO by default.
#               Set it to YES to enable bastille.
# bastille_list (string):        Set to "ALL" by default.
#               Space separated list of jails to start.
#

. /etc/rc.subr

name=bastille
rcvar=${name}_enable

: ${bastille_enable:=NO}
: ${bastille_list:="ALL"}

command=%%PREFIX%%/bin/${name}
start_cmd="bastille_start"
stop_cmd="bastille_stop"
restart_cmd="bastille_stop && bastille_start"

bastille_start()
{
    if [ ! -n "${bastille_list}" ]; then
        echo "${bastille_list} is undefined"
        return 1
    fi

    local _jail

    for _jail in ${bastille_list}; do
        echo "Starting Bastille Jail: ${_jail}"
        ${command} start ${_jail}
    done
}

bastille_stop()
{
    if [ ! -n "${bastille_list}" ]; then
        echo "${bastille_list} is undefined"
        return 1
    fi

    local _jail

    for _jail in ${bastille_list}; do
        echo "Stopping Bastille Jail: ${_jail}"
        ${command} stop ${_jail}
    done
}

load_rc_config ${name}
run_rc_command "$1"