Move trap to each needed subcommand

This commit is contained in:
Perdixky
2025-12-03 20:58:45 +08:00
parent 8a9f105e75
commit d3c1ae14b8
+6 -4
View File
@@ -8,10 +8,6 @@ source ./sdata/lib/package-installers.sh
source ./sdata/lib/dist-determine.sh
prevent_sudo_or_root
# Trap to ensure sudo keepalive is stopped on exit
trap sudo_stop_keepalive EXIT INT TERM
set -e
#####################################################################################
@@ -77,6 +73,8 @@ case ${SUBCMD_NAME} in
pause
# Initialize sudo keepalive for the entire install process
sudo_init_keepalive
# Set trap to cleanup when this subcommand exits
trap sudo_stop_keepalive EXIT INT TERM
if [[ "${SKIP_ALLGREETING}" != true ]]; then
source ${SUBCMD_DIR}/0.greeting.sh
fi
@@ -97,6 +95,8 @@ case ${SUBCMD_NAME} in
pause
# Initialize sudo keepalive for dependency installation
sudo_init_keepalive
# Set trap to cleanup when this subcommand exits
trap sudo_stop_keepalive EXIT INT TERM
if [[ "${SKIP_ALLDEPS}" != true ]]; then
source ${SUBCMD_DIR}/1.deps-router.sh
fi
@@ -108,6 +108,8 @@ case ${SUBCMD_NAME} in
pause
# Initialize sudo keepalive for setup steps
sudo_init_keepalive
# Set trap to cleanup when this subcommand exits
trap sudo_stop_keepalive EXIT INT TERM
if [[ "${SKIP_ALLSETUPS}" != true ]]; then
source ${SUBCMD_DIR}/2.setups.sh
fi