From 906afa4bdb6c2cf1980311a4f771a5af872d04b5 Mon Sep 17 00:00:00 2001 From: Charadon Date: Wed, 10 Aug 2022 00:57:13 -0400 Subject: Hopefully solved the locking once and for all --- dscip | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/dscip b/dscip index 99915ee..520a169 100755 --- a/dscip +++ b/dscip @@ -55,19 +55,18 @@ set -u if [ -f "$WORKING_DIRECTORY/LOCK" ]; then LOCKED_PID=$(cat "$WORKING_DIRECTORY/LOCK") # shellcheck disable=SC2009 - if ps -aux | grep -w "[^]]$LOCKED_PID" > /dev/null; then - echo "Script still running. Exiting..." - exit 0 - else - echo "Script not running, resetting lock..." - rm "$WORKING_DIRECTORY/LOCK" - fi + for i in $(pgrep -f "$0"); do + if [ "$i" = "$LOCKED_PID" ]; then + echo "Script still running. Exiting..." + exit 0 + fi + done + echo "Script not running. Removing old lock." + rm -f "$WORKING_DIRECTORY/LOCK" fi echo "$$" > "$WORKING_DIRECTORY/LOCK" - - build () { # Remove old output rm -f "$WORKING_DIRECTORY"/output.txt -- cgit 1.4.1-2-gfad0 From 5eec8261658d0e629750669bf02080a25c75b26c Mon Sep 17 00:00:00 2001 From: Charadon Date: Thu, 11 Aug 2022 22:00:40 -0400 Subject: Added [dscip] to output, mostly for use in daemons. --- dscip | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dscip b/dscip index 520a169..8532b9f 100755 --- a/dscip +++ b/dscip @@ -29,14 +29,14 @@ if [ "$DSCIP_AUTO_UPDATE" = "true" ]; then DSCIP_NEW_CKSUM="$(cksum "$0")" # Rerun dscip if update was found. if [ ! "$DSCIP_CKSUM" = "$DSCIP_NEW_CKSUM" ]; then - echo "Update found. Rerunning DSCIP..." + echo "[dscip] Update found. Rerunning DSCIP..." "$SHELL" "$0" "$@" exit 0 else - echo "No updates found. Continuing..." + echo "[dscip] No updates found. Continuing..." fi else - echo "Auto updates turned off. Continuing..." + echo "[dscip] Auto updates turned off. Continuing..." fi ################################################################################ @@ -57,11 +57,11 @@ if [ -f "$WORKING_DIRECTORY/LOCK" ]; then # shellcheck disable=SC2009 for i in $(pgrep -f "$0"); do if [ "$i" = "$LOCKED_PID" ]; then - echo "Script still running. Exiting..." + echo "[dscip] Script still running. Exiting..." exit 0 fi done - echo "Script not running. Removing old lock." + echo "[dscip] Script not running. Removing old lock." rm -f "$WORKING_DIRECTORY/LOCK" fi -- cgit 1.4.1-2-gfad0