diff options
author | erdgeist <erdgeist@erdgeist.org> | 2010-01-11 03:57:13 +0000 |
---|---|---|
committer | erdgeist <erdgeist@erdgeist.org> | 2010-01-11 03:57:13 +0000 |
commit | feedbc6d52002183283e60ce2cc6e0d407e4e2cf (patch) | |
tree | 5c4e84cde2ced7384a7feddba985005a301f73d7 /ezjail.sh | |
parent | 90caf58048fc0351621ee656e7d08ea1d851177e (diff) |
Make non runnable jails stoppable, second attempt
Diffstat (limited to 'ezjail.sh')
-rwxr-xr-x | ezjail.sh | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -35,30 +35,38 @@ stopcrypto_cmd="do_cmd stopcrypto _" | |||
35 | do_cmd() | 35 | do_cmd() |
36 | { | 36 | { |
37 | action=$1; message=$2; shift 2; | 37 | action=$1; message=$2; shift 2; |
38 | unset ezjail_list ezjail_pass ezjail_mds | 38 | unset ezjail_list ezjail_pass ezjail_mds ezjail_stop |
39 | ezjail_cfgs=${ezjail_prefix}/etc/ezjail/ | ||
39 | ezjail_fromrc="YES" | 40 | ezjail_fromrc="YES" |
40 | 41 | ||
42 | case "${action}" in *stop) ezjail_stop="YES";; esac | ||
43 | |||
41 | # If a jail list is given on command line, process it | 44 | # If a jail list is given on command line, process it |
42 | # If not, fetch it from our config directory | 45 | # If not, fetch it from our config directory |
43 | if [ "$*" ]; then | 46 | if [ "$*" ]; then |
44 | ezjail_list=`echo -n $* | tr -c '[:alnum:] ' '_'` | 47 | ezjail_list=`echo -n $* | tr -c '[:alnum:] ' '_'` |
45 | unset ezjail_fromrc | 48 | unset ezjail_fromrc |
46 | else | 49 | else |
47 | case "${action}" in *stop) reverse_command="tail -r";; *) reverse_command="cat";; esac | 50 | [ "${ezjail_stop}" ] && reverse_command="tail -r" || reverse_command="cat" |
48 | [ -d "${ezjail_prefix}/etc/ezjail/" ] && cd "${ezjail_prefix}/etc/ezjail/" && ezjail_list=`ls | xargs rcorder | ${reverse_command}` | 51 | [ -d "${ezjail_cfgs}" ] && cd "${ezjail_cfgs}" && ezjail_list=`ls | xargs rcorder | ${reverse_command}` |
49 | echo -n "${message##_}" | 52 | echo -n "${message##_}" |
50 | fi | 53 | fi |
51 | 54 | ||
52 | for ezjail in ${ezjail_list}; do | 55 | for ezjail in ${ezjail_list}; do |
53 | # If jail is temporary disabled (dot in name), skip it for starts | 56 | unset ezjail_config |
54 | case "${action}" in *stop) ezjail=${ezjail%%.*};; esac | 57 | |
55 | [ "${ezjail%.*}" != "${ezjail}" ] && echo -n " skipping ${ezjail}" && continue | 58 | [ -e "${ezjail_jailcfgs}/${ezjail}" ] && ezjail_config="${ezjail_jailcfgs}/${ezjail}" |
59 | [ -e "${ezjail_jailcfgs}/${ezjail}.norun" ] && ezjail_config="${ezjail_jailcfgs}/${ezjail}.norun" | ||
56 | 60 | ||
57 | # Check for jails config | 61 | # Check for jails config |
58 | [ ! -r "${ezjail_prefix}/etc/ezjail/${ezjail}" ] && echo " Warning: Jail ${ezjail} not found." && continue | 62 | [ -f "${ezjail_config}" ] || echo " Warning: Jail ${ezjail} not found." && continue |
63 | |||
64 | # If jail is temporary disabled (dot in name), skip it for starts | ||
65 | [ "${ezjail_stop}" ] && ezjail="${ezjail%%.*}" | ||
66 | [ "${ezjail%.*}" != "${ezjail}" ] && echo -n " skipping ${ezjail}" && continue | ||
59 | 67 | ||
60 | # Read config file | 68 | # Read config file |
61 | . "${ezjail_prefix}/etc/ezjail/${ezjail}" | 69 | . ${ezjail_config} |
62 | 70 | ||
63 | eval ezjail_rootdir=\"\$jail_${ezjail}_rootdir\" | 71 | eval ezjail_rootdir=\"\$jail_${ezjail}_rootdir\" |
64 | eval ezjail_image=\"\$jail_${ezjail}_image\" | 72 | eval ezjail_image=\"\$jail_${ezjail}_image\" |