From 83e25cf1768ba1f1504ce91f1deb0cd289836e2f Mon Sep 17 00:00:00 2001 From: onefang Date: Tue, 18 Oct 2022 11:54:57 +1000 Subject: Check for stale lock file. --- update_apt-panopticon | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'update_apt-panopticon') diff --git a/update_apt-panopticon b/update_apt-panopticon index f2f3387..7bbe1d7 100755 --- a/update_apt-panopticon +++ b/update_apt-panopticon @@ -11,10 +11,16 @@ if [ -f .git ] ; then #chown -R mirrors:www-data * fi -if [ ! -f apt-panopticon.lock ] ; then - rm ../results; ln -s apt-panopticon/results_old ../results - flock -n apt-panopticon.lock ./apt-panopticon.lua && rm apt-panopticon.lock - rm ../results; ln -s apt-panopticon/results ../results +# Check if the lock file still exists. +if [ -f apt-panopticon.lock ] ; then + # Check if it's still running. + ps ax -eo pid,args | grep "luajit ./apt-panopticon.lua" | grep -v "grep luajit ./apt-panopticon.lua" | while read line ; do echo "Previous apt-panopticon still running, exiting." exit 1 ; done + echo "Crashed apt-panopticon detected, removing stale lock file." + rm apt-panopticon.lock fi +rm ../results; ln -s apt-panopticon/results_old ../results +flock -n apt-panopticon.lock ./apt-panopticon.lua && rm apt-panopticon.lock +rm ../results; ln -s apt-panopticon/results ../results + #chown -R mirrors:www-data /var/www/html/SledjHamr/apt-panopticon/results -- cgit v1.1