From feedbc6d52002183283e60ce2cc6e0d407e4e2cf Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 11 Jan 2010 03:57:13 +0000 Subject: Make non runnable jails stoppable, second attempt --- ezjail.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ezjail.sh b/ezjail.sh index ae4ffb2..d7f4e26 100755 --- a/ezjail.sh +++ b/ezjail.sh @@ -35,30 +35,38 @@ stopcrypto_cmd="do_cmd stopcrypto _" do_cmd() { action=$1; message=$2; shift 2; - unset ezjail_list ezjail_pass ezjail_mds + unset ezjail_list ezjail_pass ezjail_mds ezjail_stop + ezjail_cfgs=${ezjail_prefix}/etc/ezjail/ ezjail_fromrc="YES" + case "${action}" in *stop) ezjail_stop="YES";; esac + # If a jail list is given on command line, process it # If not, fetch it from our config directory if [ "$*" ]; then ezjail_list=`echo -n $* | tr -c '[:alnum:] ' '_'` unset ezjail_fromrc else - case "${action}" in *stop) reverse_command="tail -r";; *) reverse_command="cat";; esac - [ -d "${ezjail_prefix}/etc/ezjail/" ] && cd "${ezjail_prefix}/etc/ezjail/" && ezjail_list=`ls | xargs rcorder | ${reverse_command}` + [ "${ezjail_stop}" ] && reverse_command="tail -r" || reverse_command="cat" + [ -d "${ezjail_cfgs}" ] && cd "${ezjail_cfgs}" && ezjail_list=`ls | xargs rcorder | ${reverse_command}` echo -n "${message##_}" fi for ezjail in ${ezjail_list}; do - # If jail is temporary disabled (dot in name), skip it for starts - case "${action}" in *stop) ezjail=${ezjail%%.*};; esac - [ "${ezjail%.*}" != "${ezjail}" ] && echo -n " skipping ${ezjail}" && continue + unset ezjail_config + + [ -e "${ezjail_jailcfgs}/${ezjail}" ] && ezjail_config="${ezjail_jailcfgs}/${ezjail}" + [ -e "${ezjail_jailcfgs}/${ezjail}.norun" ] && ezjail_config="${ezjail_jailcfgs}/${ezjail}.norun" # Check for jails config - [ ! -r "${ezjail_prefix}/etc/ezjail/${ezjail}" ] && echo " Warning: Jail ${ezjail} not found." && continue + [ -f "${ezjail_config}" ] || echo " Warning: Jail ${ezjail} not found." && continue + + # If jail is temporary disabled (dot in name), skip it for starts + [ "${ezjail_stop}" ] && ezjail="${ezjail%%.*}" + [ "${ezjail%.*}" != "${ezjail}" ] && echo -n " skipping ${ezjail}" && continue # Read config file - . "${ezjail_prefix}/etc/ezjail/${ezjail}" + . ${ezjail_config} eval ezjail_rootdir=\"\$jail_${ezjail}_rootdir\" eval ezjail_image=\"\$jail_${ezjail}_image\" -- cgit v1.2.3