evobackup/lib/bkctld-stop
Victor LABORIE 842e57ba53 Big refactoring
* Jails are created on start and run in tmpfs
* All config files are on /etc/bkctld
* Cleaning of sshd_config and /etc/group
2020-01-08 14:46:18 +01:00

26 lines
778 B
Bash
Executable file

#!/bin/sh
#
# Stop jail <jailname> or all
# Usage: stop <jailname>|all
#
LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
jail="${1:-}"
if [ ! -n "${jail}" ]; then
"${LIBDIR}/bkctld-help" && exit 1
fi
[ -d "${CONFDIR}/${jail}" ] || error "${jail} : trying to stop inexistant jail"
"${LIBDIR}/bkctld-is-on" "${jail}" || exit 0
if [ -f "${RUNDIR}/${jail}/sshd.pid" ]; then
pid=$(cat "${RUNDIR}/${jail}/sshd.pid")
for conn in $(ps --ppid "${pid}" -o pid=); do
kill "${conn}"
done
kill "${pid}" && notice "${jail} was stopped [${pid}]"
fi
[ -f "${LOGDIR}/${jail}/authlog" ] && lsof -t "${LOGDIR}/${jail}/authlog"|xargs --no-run-if-empty kill -9 && rm -rf "${RUNDIR}/${jail}"
umount --lazy --recursive "${JAILDIR}/${jail}" && rmdir "${JAILDIR}/${jail}"