1
0
mirror of https://github.com/AG7GN/nexus-utilities.git synced 2025-05-18 15:30:12 -07:00

Fixed trap actions

This commit is contained in:
Steve Magnuson 2020-02-08 10:14:38 -08:00
parent 7993b2f1d1
commit c70dfaa1ae

16
tnc.sh
View File

@ -97,7 +97,7 @@
#% #%
#================================================================ #================================================================
#- IMPLEMENTATION #- IMPLEMENTATION
#- version ${SCRIPT_NAME} 3.3.2 #- version ${SCRIPT_NAME} 3.3.6
#- author Steve Magnuson, AG7GN #- author Steve Magnuson, AG7GN
#- license CC-BY-SA Creative Commons License #- license CC-BY-SA Creative Commons License
#- script_id 0 #- script_id 0
@ -125,16 +125,12 @@ DEBUG=false
function TrapCleanup () { function TrapCleanup () {
${SCRIPT_NAME} stop ${SCRIPT_NAME} stop
rm -f /tmp/tnc*
rm -f $CONFFILE
exit 0 exit 0
} }
function SafeExit () { function SafeExit () {
${SCRIPT_NAME} stop
rm -f /tmp/tnc* rm -f /tmp/tnc*
rm -f $CONFFILE rm -f $CONFFILE
trap - INT TERM EXIT
exit exit
} }
@ -151,12 +147,12 @@ function ScriptInfo() {
function Usage () { function Usage () {
printf "Usage:\n" printf "Usage:\n"
ScriptInfo usage ScriptInfo usage
exit 1 exit 0
} }
function Die () { function Die () {
echo "${*}" echo "${*}"
SafeExit exit 1
} }
#--------------------------------------- #---------------------------------------
@ -468,7 +464,8 @@ shift $((${OPTIND} - 1)) ## shift options
#============================ #============================
# Trap bad exits with cleanup function # Trap bad exits with cleanup function
trap SafeExit EXIT INT TERM trap TrapCleanup INT
trap SafeExit TERM EXIT
# Exit on error. Append '||true' when you run the script if you expect an error. # Exit on error. Append '||true' when you run the script if you expect an error.
set -o errexit set -o errexit
@ -592,7 +589,7 @@ case "$ACTION" in
[[ "$SCR" != "" ]] && { pkill piardop2; $SCREEN -S $SCR -X quit; } [[ "$SCR" != "" ]] && { pkill piardop2; $SCREEN -S $SCR -X quit; }
done done
## Kill existing session if it exists ## Kill existing session if it exists
pgrep kissattach >/dev/null && kill $(pgrep kissattach) pgrep kissattach >/dev/null && sudo kill $(pgrep kissattach)
## Are the apps installed? ## Are the apps installed?
for i in kissattach kissparms for i in kissattach kissparms
do do
@ -772,5 +769,4 @@ case "$ACTION" in
Usage Usage
;; ;;
esac esac
SafeExit