diff options
author | Charadon <charadon@charadon-gmpc.hsd1.ga.comcast.net> | 2022-07-14 00:57:33 -0400 |
---|---|---|
committer | Charadon <charadon@charadon-gmpc.hsd1.ga.comcast.net> | 2022-07-14 00:57:33 -0400 |
commit | 905c436f2b1e0c74a2d858bf09b320f54292b251 (patch) | |
tree | 53bd64cf906d73d89ed86377fd3754b1a257c525 | |
parent | f1d82781ed9ff96fd936921e96792d3826be8931 (diff) | |
download | dscip-905c436f2b1e0c74a2d858bf09b320f54292b251.tar.gz |
Added lock functionality
-rwxr-xr-x | dscip | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/dscip b/dscip index 045cd65..c35ae3b 100755 --- a/dscip +++ b/dscip @@ -44,6 +44,18 @@ DSCIP_DISREGARD_COMMIT_CHECK="false" # If the script should just rebuild even # ################################################################################ +# Check if script is currently running, and if not, reset LOCK # +if [ -f $WORKING_DIRECTORY/LOCK ]; then + LOCKED_PID=$(cat $WORKING_DIRECTORY/LOCK) + if ps -p $LOCKED_PID; then + exit 0 + else + rm $WORKING_DIRECTORY/LOCK + fi +fi + +echo "$$" > $WORKING_DIRECTORY/LOCK + if [ "$DSCIP_DAEMON" = "true" ]; then if [ "$DSCIP_DAEMON_FORK" = "true" ] && [ ! "$FORKED" = "true" ]; then FORKED=true nohup "$0" "$@" > /dev/null 2>&1 @@ -98,6 +110,7 @@ run () { else build fi + rm $WORKING_DIRECTORY/LOCK # Remove lock # } run |