Skip to content

Commit 7ab0432

Browse files
authored
Update install.sh: Save status on interrupt
* Also fix bug saving STATUS_CODE (was called STATUS).
1 parent 427dca0 commit 7ab0432

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

install.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ STATUS_NOT_CONTINUE="User elected not to continue" # Exiting, but not an error
7171
STATUS_NO_REBOOT="User elected not to reboot"
7272
STATUS_CLEAR="Clear" # Clear the file
7373
STATUS_ERROR="Error encountered"
74-
#STATUS_INT="Got interupt"
74+
STATUS_INT="Got interrupt"
7575
STATUS_VARIABLES=() # Holds all the variables and values to save
7676

7777
# Some versions of Linux default to 750 so web server can't read it
@@ -2364,7 +2364,7 @@ exit_installation()
23642364
clear_status
23652365
else
23662366
[[ -n ${MORE_STATUS} ]] && MORE_STATUS="; MORE_STATUS='${MORE_STATUS}'"
2367-
echo -e "STATUS_INSTALLATION='${STATUS}'${MORE_STATUS}" > "${STATUS_FILE}"
2367+
echo -e "STATUS_INSTALLATION='${STATUS_CODE}'${MORE_STATUS}" > "${STATUS_FILE}"
23682368
echo -e "${STATUS_VARIABLES[@]}" >> "${STATUS_FILE}"
23692369
fi
23702370
fi
@@ -2375,6 +2375,12 @@ exit_installation()
23752375
}
23762376

23772377

2378+
####
2379+
handle_interrupts()
2380+
{
2381+
display_msg --log info "\nGot interrupt - saving installation status, then exiting.\n"
2382+
exit_installation 1 "${STATUS_INT}" "Saving status."
2383+
}
23782384

23792385
############################################## Main part of program
23802386

@@ -2451,6 +2457,7 @@ TESTING="${TESTING}" # xxx keeps shellcheck quiet
24512457
shift
24522458
done
24532459

2460+
24542461
if [[ -n ${FUNCTION} ]]; then
24552462
# Don't log when a single function is executed.
24562463
DISPLAY_MSG_LOG=""
@@ -2463,6 +2470,8 @@ fi
24632470
[[ ${HELP} == "true" ]] && usage_and_exit 0
24642471
[[ ${OK} == "false" ]] && usage_and_exit 1
24652472

2473+
trap "handle_interrupts" SIGTERM SIGINT
2474+
24662475
# See if we should skip some steps.
24672476
# When most function are called they add a variable with the function's name set to "true".
24682477
if [[ -z ${FUNCTION} && -s ${STATUS_FILE} ]]; then

0 commit comments

Comments
 (0)