diff --git a/bkctld b/bkctld index d1c01a7..79f9209 100755 --- a/bkctld +++ b/bkctld @@ -35,20 +35,7 @@ case "${subcommand}" in ;; "start" | "stop" | "reload" | "restart" | "sync" | "update" | "remove") if [ "${jail}" = "all" ]; then - jails=$(ls "${JAILDIR}") - 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 + ls "${JAILDIR}"|xargs --no-run-if-empty --max-args=1 --max-procs=0 "${LIBDIR}/bkctld-${subcommand}" else "${LIBDIR}/bkctld-${subcommand}" "${jail}" fi diff --git a/lib/bkctld-reload b/lib/bkctld-reload index 4c05dd4..1e97039 100755 --- a/lib/bkctld-reload +++ b/lib/bkctld-reload @@ -5,7 +5,7 @@ LIBDIR="$(dirname $0)" && . "${LIBDIR}/config" jail="${1:-}" [ -n "${jail}" ] || usage 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}") diff --git a/lib/bkctld-start b/lib/bkctld-start index f2514ab..cf0daa1 100755 --- a/lib/bkctld-start +++ b/lib/bkctld-start @@ -5,7 +5,7 @@ LIBDIR="$(dirname $0)" && . "${LIBDIR}/config" jail="${1:-}" [ -n "${jail}" ] || usage 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}" grep -q "${JAILDIR}/${jail}/proc" /proc/mounts || mount -t proc "proc-${jail}" proc diff --git a/lib/bkctld-stop b/lib/bkctld-stop index 1bafc0b..da2f93a 100755 --- a/lib/bkctld-stop +++ b/lib/bkctld-stop @@ -5,7 +5,7 @@ LIBDIR="$(dirname $0)" && . "${LIBDIR}/config" jail="${1:-}" [ -n "${jail}" ] || usage 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}") for conn in $(ps --ppid "${pid}" -o pid=); do