From ee1d46fb3ab1bbe93ed36303f691e14d64b8c436 Mon Sep 17 00:00:00 2001 From: Matias Barcenas Date: Sun, 26 Apr 2020 02:38:29 -0500 Subject: [PATCH] Optional updates, execution log, & kill lineage. Change the update behavior by making it optional to the user. Changed the piping of logs to null, to execution.log in fluxspace. Added a helper utility for killing parents and their children! --- fluxion.sh | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/fluxion.sh b/fluxion.sh index 77552b7..ed2627f 100755 --- a/fluxion.sh +++ b/fluxion.sh @@ -22,7 +22,7 @@ readonly FLUXIONNoiseFloor=-90 readonly FLUXIONNoiseCeiling=-60 readonly FLUXIONVersion=6 -readonly FLUXIONRevision=5 +readonly FLUXIONRevision=6 # Declare window ration bigger = smaller windows FLUXIONWindowRatio=4 @@ -176,7 +176,7 @@ if [ $FLUXIONDebug ]; then readonly FLUXIONOutputDevice="/tmp/fluxion_debug_log" readonly FLUXIONHoldXterm="-hold" else - readonly FLUXIONOutputDevice="/dev/null" + readonly FLUXIONOutputDevice="/tmp/execution.log" readonly FLUXIONHoldXterm="" fi @@ -270,9 +270,10 @@ fluxion_startup() { if installer_utils_check_update "https://$fluxionDomain/$fluxionPath" \ "FLUXIONVersion=" "FLUXIONRevision=" \ $FLUXIONVersion $FLUXIONRevision; then - installer_utils_run_update "https://$updateDomain/$updatePath" \ - "FLUXION-V$FLUXIONVersion.$FLUXIONRevision" "$FLUXIONPath" - fluxion_shutdown + if installer_utils_run_update "https://$updateDomain/$updatePath" \ + "FLUXION-V$FLUXIONVersion.$FLUXIONRevision" "$FLUXIONPath"; then + fluxion_shutdown + fi fi echo # Do not remove. @@ -401,6 +402,36 @@ fluxion_shutdown() { } +# ============================================================ # +# ================== < Helper Subroutines > ================== # +# ============================================================ # +# The following will kill the parent proces & all its children. +fluxion_kill_lineage() { + if [ ${#@} -lt 1 ]; then return -1; fi + + if [ ! -z "$2" ]; then + local -r options=$1 + local match=$2 + else + local -r options="" + local match=$1 + fi + + # Check if the match isn't a number, but a regular expression. + # The following might + if ! [[ "$match" =~ ^[0-9]+$ ]]; then + match=$(pgrep -f $match 2> $FLUXIONOutputDevice) + fi + + # Check if we've got something to kill, abort otherwise. + if [ -z "$match" ]; then return -2; fi + + kill $options $(pgrep -P $match 2> $FLUXIONOutputDevice) \ + &> $FLUXIONOutputDevice + kill $options $match &> $FLUXIONOutputDevice +} + + # ============================================================ # # ================= < Handler Subroutines > ================== # # ============================================================ #