From e3cb7b6cb0503b594c7c124e6f78a10102f7a47c Mon Sep 17 00:00:00 2001 From: Salt Date: Fri, 21 Jun 2019 07:57:54 -0500 Subject: [PATCH] Fix help text, add cleanup trap --- firestarter | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/firestarter b/firestarter index fccea9a..094a72f 100755 --- a/firestarter +++ b/firestarter @@ -55,6 +55,22 @@ startfile() { fi } +# Traps +trap_exit() { + if command -v loginctl > /dev/null 2>&1; then + # Use loginctl if possible + local sessionid="$(< /proc/self/sessionid)" + if [ -n "$sessionid" ]; then + loginctl terminate-session "$sessionid" + fi + else + # Otherwise just brute it + kill $(jobs -p) + fi + return 0 +} +trap trap_exit EXIT + # Steps in execution step_generate() { log "Creating default config setup in \"$g_configdir\"" @@ -227,7 +243,7 @@ EOF } step_printhelp() { cat << EOF -Usage: $0 [OPTION...] +Usage: $(basename -- "$0") [OPTION...] Start or generate a desktop environment configuration -h Show this help text