Fix jail cleaning when not running

This commit is contained in:
Victor Laborie 2017-08-17 14:53:40 -04:00
parent 44620c363a
commit 3bd4294cfb

24
bkctld
View file

@ -41,21 +41,17 @@ check_jail() {
check_jail_on() {
jail=$1
if [ -f ${JAILDIR}/${jail}/${SSHD_PID} ]; then
pid=$(cat ${JAILDIR}/${jail}/${SSHD_PID})
ps -p $pid > /dev/null
if [ $? -eq 0 ]; then
exit 0
else
rm ${JAILDIR}/${jail}/${SSHD_PID}
umount --lazy --recursive ${JAILDIR}/${jail}/dev
umount --lazy ${JAILDIR}/${jail}/proc/
exit 1
fi
else
exit 1
return=1
if [ -f ${JAILDIR}/${jail}/${SSHD_PID} ]; then
pid=$(cat ${JAILDIR}/${jail}/${SSHD_PID})
ps -p $pid > /dev/null && return=0
fi
echo $status
if [ "$return" -eq 1 ]; then
rm -f ${JAILDIR}/${jail}/${SSHD_PID}
grep -q "${JAILDIR}/${jail}/proc" /proc/mounts && umount --lazy ${JAILDIR}/${jail}/proc/
grep -q "${JAILDIR}/${jail}/dev" /proc/mounts && umount --lazy --recursive ${JAILDIR}/${jail}/dev
fi
exit "$return"
}
## get functions : get info on jail