diff options
author | erdgeist <erdgeist@erdgeist.org> | 2006-02-03 17:38:25 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2006-02-03 17:38:25 +0000 |
commit | e2f7a80daef27b9934aa6a65352ff0cdfeb8ab97 (patch) | |
tree | f4c3529b513ca3b6fc7d4b670fbfbf9167728010 /ezjail.sh | |
parent | 4e50d9edadc613ccc45058cbc639b8781efca159 (diff) |
Tidying up the rc.d script, only run, if any of the jails specified exists. restart does not work anymore due to a bug in rc.subr
Diffstat (limited to 'ezjail.sh')
-rwxr-xr-x | ezjail.sh | 42 |
1 files changed, 17 insertions, 25 deletions
@@ -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 | ||
22 | ezjail_enable=${ezjail_enable:-"NO"} | 22 | ezjail_enable=${ezjail_enable:-"NO"} |
23 | 23 | ||
24 | restart_cmd="do_restart" | 24 | restart_cmd="do_cmd restart _" |
25 | start_cmd="do_start" | 25 | start_cmd="do_cmd start '_ ezjail'" |
26 | stop_cmd="do_stop" | 26 | stop_cmd="do_cmd stop '_ ezjail'" |
27 | 27 | ||
28 | do_start() | 28 | do_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}; | |
36 | do_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 | |||
45 | do_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 | ||
53 | run_rc_command $* | 45 | run_rc_command $* |