Files
bastille/usr/local/etc/rc.d/bastille
T

62 lines
1.2 KiB
Bash
Raw Normal View History

2018-04-06 13:40:48 -06:00
#!/bin/sh
# Bastille jail startup script
2018-04-06 13:40:48 -06:00
#
# 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.
2018-04-06 13:40:48 -06:00
# Space separated list of jails to start.
#
. /etc/rc.subr
name=bastille
2018-11-24 09:55:16 -07:00
rcvar=${name}_enable
2018-04-06 13:40:48 -06:00
: ${bastille_enable:=NO}
2018-11-24 09:55:16 -07:00
: ${bastille_list:="ALL"}
2018-04-06 13:40:48 -06:00
2018-11-30 09:12:43 -07:00
command=/usr/local/bin/${name}
start_cmd="bastille_start"
stop_cmd="bastille_stop"
restart_cmd="bastille_stop && bastille_start"
2018-04-06 13:40:48 -06:00
bastille_start()
{
if [ ! -n "${bastille_list}" ]; then
echo "${bastille_list} is undefined"
return 1
fi
local _jail
2018-04-06 13:40:48 -06:00
for _jail in ${bastille_list}; do
echo "Starting Bastille Jail: ${_jail}"
2018-11-30 09:12:43 -07:00
${command} start ${_jail}
2018-04-06 13:40:48 -06:00
done
}
bastille_stop()
{
if [ ! -n "${bastille_list}" ]; then
echo "${bastille_list} is undefined"
return 1
fi
local _jail
2018-04-06 13:40:48 -06:00
for _jail in ${bastille_list}; do
echo "Stopping Bastille Jail: ${_jail}"
2018-11-30 09:12:43 -07:00
${command} stop ${_jail}
2018-04-06 13:40:48 -06:00
done
}
2018-11-30 09:12:43 -07:00
load_rc_config ${name}
run_rc_command "$1"