Parallelize bkctld <subcommand> all

This commit is contained in:
Victor LABORIE 2019-01-04 16:00:31 +01:00
parent 16014f3c4f
commit 6caa9078e6
4 changed files with 4 additions and 17 deletions

15
bkctld
View file

@ -35,20 +35,7 @@ case "${subcommand}" in
;; ;;
"start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove") "start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove")
if [ "${jail}" = "all" ]; then if [ "${jail}" = "all" ]; then
jails=$(ls "${JAILDIR}") ls "${JAILDIR}"|xargs --no-run-if-empty --max-args=1 --max-procs=0 "${LIBDIR}/bkctld-${subcommand}"
for jail in ${jails}; do
case "${subcommand}" in
"start")
check_jail_on "${jail}" || "${LIBDIR}/bkctld-${subcommand}" "${jail}"
;;
"stop" | "reload" | "restart")
check_jail_on "${jail}" && "${LIBDIR}/bkctld-${subcommand}" "${jail}"
;;
*)
"${LIBDIR}/bkctld-${subcommand}" "${jail}"
;;
esac
done
else else
"${LIBDIR}/bkctld-${subcommand}" "${jail}" "${LIBDIR}/bkctld-${subcommand}" "${jail}"
fi fi

View file

@ -5,7 +5,7 @@ LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
jail="${1:-}" jail="${1:-}"
[ -n "${jail}" ] || usage [ -n "${jail}" ] || usage
check_jail "${jail}" || error "${jail} : trying to reload inexistant jail" check_jail "${jail}" || error "${jail} : trying to reload inexistant jail"
check_jail_on "${jail}" || error "${jail} : trying to reload not running jail" check_jail_on "${jail}" || exit 0
pid=$(cat "${JAILDIR}/${jail}/${SSHD_PID}") pid=$(cat "${JAILDIR}/${jail}/${SSHD_PID}")

View file

@ -5,7 +5,7 @@ LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
jail="${1:-}" jail="${1:-}"
[ -n "${jail}" ] || usage [ -n "${jail}" ] || usage
check_jail "${jail}" || error "${jail} : trying to start inexistant jail" check_jail "${jail}" || error "${jail} : trying to start inexistant jail"
check_jail_on "${jail}" && error "${jail} : trying to start already running jail" check_jail_on "${jail}" && exit 0
cd "${JAILDIR}/${jail}" cd "${JAILDIR}/${jail}"
grep -q "${JAILDIR}/${jail}/proc" /proc/mounts || mount -t proc "proc-${jail}" proc grep -q "${JAILDIR}/${jail}/proc" /proc/mounts || mount -t proc "proc-${jail}" proc

View file

@ -5,7 +5,7 @@ LIBDIR="$(dirname $0)" && . "${LIBDIR}/config"
jail="${1:-}" jail="${1:-}"
[ -n "${jail}" ] || usage [ -n "${jail}" ] || usage
check_jail "${jail}" || error "${jail} : trying to stop inexistant jail" check_jail "${jail}" || error "${jail} : trying to stop inexistant jail"
check_jail_on "${jail}" || error "${jail} : trying to stop not running jail" check_jail_on "${jail}" || exit 0
pid=$(cat "${JAILDIR}/${jail}/${SSHD_PID}") pid=$(cat "${JAILDIR}/${jail}/${SSHD_PID}")
for conn in $(ps --ppid "${pid}" -o pid=); do for conn in $(ps --ppid "${pid}" -o pid=); do