From 76cda4b53f156e3f8ed334becea6dd5cd16132ba Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Sun, 4 May 2025 12:35:12 -0600 Subject: [PATCH] fix & for subshell --- usr/local/share/bastille/cmd.sh | 2 +- usr/local/share/bastille/config.sh | 2 +- usr/local/share/bastille/cp.sh | 2 +- usr/local/share/bastille/destroy.sh | 2 +- usr/local/share/bastille/jcp.sh | 2 +- usr/local/share/bastille/limits.sh | 2 +- usr/local/share/bastille/mount.sh | 2 +- usr/local/share/bastille/pkg.sh | 2 +- usr/local/share/bastille/restart.sh | 11 +++++++++-- usr/local/share/bastille/service.sh | 2 +- usr/local/share/bastille/start.sh | 2 +- usr/local/share/bastille/stop.sh | 2 +- usr/local/share/bastille/sysrc.sh | 2 +- usr/local/share/bastille/tags.sh | 2 +- usr/local/share/bastille/template.sh | 2 +- usr/local/share/bastille/umount.sh | 2 +- usr/local/share/bastille/zfs.sh | 2 +- 17 files changed, 25 insertions(+), 18 deletions(-) diff --git a/usr/local/share/bastille/cmd.sh b/usr/local/share/bastille/cmd.sh index 9b945c70..914a1f8a 100644 --- a/usr/local/share/bastille/cmd.sh +++ b/usr/local/share/bastille/cmd.sh @@ -125,7 +125,7 @@ for _jail in ${JAILS}; do RETURN=$(($RETURN+$ERROR_CODE)) fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/config.sh b/usr/local/share/bastille/config.sh index af2826ba..642c1036 100644 --- a/usr/local/share/bastille/config.sh +++ b/usr/local/share/bastille/config.sh @@ -293,7 +293,7 @@ for _jail in ${JAILS}; do fi fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/cp.sh b/usr/local/share/bastille/cp.sh index 6dd640d8..10d4760e 100644 --- a/usr/local/share/bastille/cp.sh +++ b/usr/local/share/bastille/cp.sh @@ -100,7 +100,7 @@ for _jail in ${JAILS}; do error_continue "[ERROR]: CP failed: ${host_path} -> ${jail_path}" fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index 6637c52e..2f506b27 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -120,7 +120,7 @@ destroy_jail() { fi fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/jcp.sh b/usr/local/share/bastille/jcp.sh index 5a927131..0e2c736a 100644 --- a/usr/local/share/bastille/jcp.sh +++ b/usr/local/share/bastille/jcp.sh @@ -108,7 +108,7 @@ for _jail in ${DEST_TARGET}; do fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/limits.sh b/usr/local/share/bastille/limits.sh index 6b1e3814..e841b9e7 100644 --- a/usr/local/share/bastille/limits.sh +++ b/usr/local/share/bastille/limits.sh @@ -287,7 +287,7 @@ for _jail in ${JAILS}; do esac - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/mount.sh b/usr/local/share/bastille/mount.sh index 427f03a7..32394b5c 100644 --- a/usr/local/share/bastille/mount.sh +++ b/usr/local/share/bastille/mount.sh @@ -198,7 +198,7 @@ for _jail in ${JAILS}; do mount -F "${bastille_jailsdir}/${_jail}/fstab" -a || error_continue "Failed to mount volume: ${_fullpath}" echo "Added: ${_fstab_entry}" - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/pkg.sh b/usr/local/share/bastille/pkg.sh index 13566d6e..d73b6857 100644 --- a/usr/local/share/bastille/pkg.sh +++ b/usr/local/share/bastille/pkg.sh @@ -130,7 +130,7 @@ for _jail in ${JAILS}; do fi fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/restart.sh b/usr/local/share/bastille/restart.sh index a812b440..dc1aed1b 100644 --- a/usr/local/share/bastille/restart.sh +++ b/usr/local/share/bastille/restart.sh @@ -112,10 +112,17 @@ set_target "${TARGET}" for _jail in ${JAILS}; do + ( + # Only restart running jails if check_target_is_running "${_jail}"; then bastille stop ${_stop_options} ${_jail} bastille start ${_start_options} ${_jail} fi - -done \ No newline at end of file + + ) & + + bastille_running_jobs "${bastille_process_limit}" + +done +wait \ No newline at end of file diff --git a/usr/local/share/bastille/service.sh b/usr/local/share/bastille/service.sh index 43c51a51..364dec5f 100644 --- a/usr/local/share/bastille/service.sh +++ b/usr/local/share/bastille/service.sh @@ -103,7 +103,7 @@ for _jail in ${JAILS}; do jexec -l "${_jail}" /usr/sbin/service "$@" - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/start.sh b/usr/local/share/bastille/start.sh index bc26c4e6..9226560c 100644 --- a/usr/local/share/bastille/start.sh +++ b/usr/local/share/bastille/start.sh @@ -210,7 +210,7 @@ for _jail in ${JAILS}; do # Delay between jail action sleep "${DELAY_TIME}" - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/stop.sh b/usr/local/share/bastille/stop.sh index ee0046aa..9d1329f8 100644 --- a/usr/local/share/bastille/stop.sh +++ b/usr/local/share/bastille/stop.sh @@ -151,7 +151,7 @@ for _jail in ${JAILS}; do done fi - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/sysrc.sh b/usr/local/share/bastille/sysrc.sh index 4021808f..ac679e7b 100644 --- a/usr/local/share/bastille/sysrc.sh +++ b/usr/local/share/bastille/sysrc.sh @@ -103,7 +103,7 @@ for _jail in ${JAILS}; do jexec -l "${_jail}" /usr/sbin/sysrc "$@" - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/tags.sh b/usr/local/share/bastille/tags.sh index a720b5f8..28ef556b 100644 --- a/usr/local/share/bastille/tags.sh +++ b/usr/local/share/bastille/tags.sh @@ -120,7 +120,7 @@ for _jail in ${JAILS}; do ;; esac - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/template.sh b/usr/local/share/bastille/template.sh index 78a8d03a..de6c0491 100644 --- a/usr/local/share/bastille/template.sh +++ b/usr/local/share/bastille/template.sh @@ -476,7 +476,7 @@ for _jail in ${JAILS}; do info "\nTemplate applied: ${TEMPLATE}" - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/umount.sh b/usr/local/share/bastille/umount.sh index fc15db1f..37d8d082 100644 --- a/usr/local/share/bastille/umount.sh +++ b/usr/local/share/bastille/umount.sh @@ -130,7 +130,7 @@ for _jail in ${JAILS}; do echo "Unmounted: ${_jailpath}" - ) + ) & bastille_running_jobs "${bastille_process_limit}" diff --git a/usr/local/share/bastille/zfs.sh b/usr/local/share/bastille/zfs.sh index 524c23f4..bddd675a 100644 --- a/usr/local/share/bastille/zfs.sh +++ b/usr/local/share/bastille/zfs.sh @@ -138,7 +138,7 @@ for _jail in ${JAILS}; do ;; esac - ) + ) & bastille_running_jobs "${bastille_process_limit}"