From 5be79235703bd37395a2e3662e1f04e86352516c Mon Sep 17 00:00:00 2001 From: Salt Date: Fri, 21 Jun 2019 08:18:22 -0500 Subject: [PATCH] Move logout trap so that you can actually use the tool normally --- firestarter | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/firestarter b/firestarter index ad4c7d5..bc964f9 100755 --- a/firestarter +++ b/firestarter @@ -55,23 +55,6 @@ startfile() { fi } -# Traps -trap_exit() { - log "Logging out" - 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\"" @@ -399,9 +382,24 @@ step_wait() { [ "$dryrun" = "1" ] && exit 0 log "Waiting for programs to exit" log "Send any termination signal to firestarter to log out" + trap step_logout EXIT wait exit 0 } +step_logout() { + log "Logging out" + 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 +} # Main main() {