diff options
-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\" |