summaryrefslogtreecommitdiff
path: root/ezjail.sh
diff options
context:
space:
mode:
Diffstat (limited to 'ezjail.sh')
-rwxr-xr-xezjail.sh42
1 files changed, 17 insertions, 25 deletions
diff --git a/ezjail.sh b/ezjail.sh
index c98e91d..2869de2 100755
--- a/ezjail.sh
+++ b/ezjail.sh
@@ -4,7 +4,7 @@
4# 4#
5# PROVIDE: ezjail 5# PROVIDE: ezjail
6# 6#
7# Note: Add the following lines to /etc/rc.conf to enable ezjail, 7# Add the following lines to /etc/rc.conf.local or /etc/rc.conf to enable ezjail
8# 8#
9#ezjail_enable="YES" 9#ezjail_enable="YES"
10# 10#
@@ -21,33 +21,25 @@ load_rc_config $name
21 21
22ezjail_enable=${ezjail_enable:-"NO"} 22ezjail_enable=${ezjail_enable:-"NO"}
23 23
24restart_cmd="do_restart" 24restart_cmd="do_cmd restart _"
25start_cmd="do_start" 25start_cmd="do_cmd start '_ ezjail'"
26stop_cmd="do_stop" 26stop_cmd="do_cmd stop '_ ezjail'"
27 27
28do_start() 28do_cmd()
29{ 29{
30 [ -n "$*" ] && jail_list=`echo -n $* | tr -c [:alnum:] _` || echo -n " ezjail" 30 action=$1; message=$2; shift 2;
31 [ -n "$*" ] && jail_list=`echo -n $* | tr -c "[:alnum:] " _` || echo -n "${message##_}"
31 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`} 32 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`}
32 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done 33 jail_pass=""
33 sh /etc/rc.d/jail onestart $jail_list 34 for jail in $jail_list; do
34} 35 if [ -f ${ezjail_prefix}/etc/ezjail/${jail} ]; then
35 36 . ${ezjail_prefix}/etc/ezjail/${jail};
36do_restart() 37 jail_pass="${jail_pass} ${jail}"
37{ 38 else
38 [ -n "$*" ] && jail_list=`echo -n $* | tr -c [:alnum:] _`; 39 echo " Warning: Jail ${jail} not found."
39 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`} 40 fi
40 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done 41 done
41 sh /etc/rc.d/jail onestop $jail_list 42 [ "$jail_pass" ] && sh /etc/rc.d/jail one${action} $jail_pass
42 sh /etc/rc.d/jail onestart $jail_list
43}
44
45do_stop()
46{
47 [ -n "$*" ] && jail_list=`echo -n $* | tr -c [:alnum:] _` || echo -n " ezjail"
48 jail_list=${jail_list:-`ls ${ezjail_prefix}/etc/ezjail/`}
49 for jail in $jail_list; do . ${ezjail_prefix}/etc/ezjail/${jail}; done
50 sh /etc/rc.d/jail onestop $jail_list
51} 43}
52 44
53run_rc_command $* 45run_rc_command $*