forked from evolix/evobackup
33 lines
743 B
Bash
Executable file
33 lines
743 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Stop jail <jailname> or all
|
|
# Usage: stop <jailname>|all
|
|
#
|
|
|
|
# shellcheck source=./config
|
|
LIBDIR="$(dirname $0)" && . "${LIBDIR}/includes"
|
|
|
|
jail_name="${1:-}"
|
|
if [ -z "${jail_name}" ]; then
|
|
"${LIBDIR}/bkctld-help" && exit 1
|
|
fi
|
|
jail_path=$(jail_path "${jail_name}")
|
|
|
|
test -d "${jail_path}" || error "${jail_name}: jail is missing."
|
|
|
|
"${LIBDIR}/bkctld-is-on" "${jail_name}" || exit 0
|
|
|
|
pid=$(cat "${jail_path}/${SSHD_PID}")
|
|
for conn in $(ps --ppid "${pid}" -o pid=); do
|
|
kill "${conn}"
|
|
done
|
|
|
|
if kill "${pid}"; then
|
|
notice "${jail_name}: jail has been stopped [${pid}]"
|
|
|
|
umount --lazy --recursive "${jail_path}/dev"
|
|
umount --lazy "${jail_path}/proc/"
|
|
else
|
|
error "${jail_name}: failed to stop jail [${pid}]"
|
|
fi
|