Victor LABORIE
842e57ba53
* Jails are created on start and run in tmpfs * All config files are on /etc/bkctld * Cleaning of sshd_config and /etc/group
26 lines
717 B
Bash
Executable file
26 lines
717 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Check if a jail is on or not
|
|
# Usage: is-on <jailname>
|
|
#
|
|
|
|
LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
|
|
|
|
jail="${1:-}"
|
|
if [ ! -n "${jail}" ]; then
|
|
"${LIBDIR}/bkctld-help" && exit 1
|
|
fi
|
|
[ -d "${CONFDIR}/${jail}" ] || error "${jail} : trying to check inexistant jail"
|
|
|
|
return=1
|
|
if [ -f "${RUNDIR}/${jail}/sshd.pid" ]; then
|
|
pid=$(cat "${RUNDIR}/${jail}/sshd.pid")
|
|
ps -p "${pid}" > /dev/null && return=0
|
|
fi
|
|
if [ "${return}" -eq 1 ]; then
|
|
[ -f "${LOGDIR}/${jail}/authlog" ] && lsof -t "${LOGDIR}/${jail}/authlog"|xargs --no-run-if-empty kill -9
|
|
rm -rf "${RUNDIR}/${jail}"
|
|
grep -q "${JAILDIR}/${jail}" /proc/mounts && umount --lazy --recursive "${JAILDIR}/${jail}"
|
|
fi
|
|
exit "${return}"
|