File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99# TODO:
1010# - Impliment functionality to revert changes if the script fails.
1111#
12- # Version: v2.0.1
12+ # Version: v2.0.2
1313# License: MIT License
1414# Copyright (c) 2020-2024 Hunter T. (StrangeRanger)
1515#
@@ -82,25 +82,23 @@ readonly C_SSHD_CONFIG
8282
8383
8484# ###
85- # Cleanly exit the script.
85+ # Exit the script and display a message based on the exit code .
8686#
8787# PARAMETERS:
8888# - $1: exit_code (Required)
89- # - The exit code to exit the script with.
9089clean_exit () {
9190 local exit_code=" $1 "
9291
9392 # Unset the EXIT trap to prevent re-entry.
9493 trap - EXIT
9594
9695 case " $exit_code " in
97- 0) exit 0 ;;
98- 1) echo " " ;;
96+ 0) ;;
97+ 1) echo " " ;;
98+ 129) echo -e " \n${C_WARNING} Hangup signal detected (SIGHUP)" ;;
9999 130) echo -e " \n${C_WARNING} User interrupt detected (SIGINT)" ;;
100100 143) echo -e " \n${C_WARNING} Termination signal detected (SIGTERM)" ;;
101- 129) echo -e " \n${C_WARNING} Hangup signal detected (SIGHUP)" ;;
102- 131) echo -e " \n${C_WARNING} Quit signal detected (SIGQUIT)" ;;
103- * ) echo -e " \n${C_WARNING} Exiting with code: $exit_code " ;;
101+ * ) echo -e " \n${C_WARNING} Exiting with code: $exit_code " ;;
104102 esac
105103
106104 echo " Exiting..."
@@ -111,10 +109,9 @@ clean_exit() {
111109# ###[ Trapping Logic ]##################################################################
112110
113111
112+ trap ' clean_exit 129' SIGHUP
114113trap ' clean_exit 130' SIGINT
115114trap ' clean_exit 143' SIGTERM
116- trap ' clean_exit 129' SIGHUP
117- trap ' clean_exit 131' SIGQUIT
118115trap ' clean_exit $?' EXIT
119116
120117
You can’t perform that action at this time.
0 commit comments