2011-10-17 15:04:06 +02:00
|
|
|
#! /bin/bash
|
2011-10-24 12:17:15 +02:00
|
|
|
if lockfile -r0 -! /home/integration/deploy/lock.file &> /dev/null
|
2011-10-17 15:04:06 +02:00
|
|
|
then
|
2011-10-24 12:17:15 +02:00
|
|
|
# If we could not get the lock, check how old the lock file is
|
2011-10-17 15:04:06 +02:00
|
|
|
DATE=$(date +%s)
|
2011-10-24 12:17:15 +02:00
|
|
|
# What if the file is not there any more?
|
2011-10-17 15:04:06 +02:00
|
|
|
LOCK_AGE=$(stat -c %Z /home/integration/deploy/lock.file)
|
|
|
|
|
|
|
|
AGE=$[($DATE - $LOCK_AGE)/60]
|
|
|
|
|
2012-01-20 11:30:03 +01:00
|
|
|
if [ "$AGE" -gt "20" ]
|
2011-10-17 15:04:06 +02:00
|
|
|
then
|
|
|
|
echo lock.file is $AGE min old.
|
|
|
|
./cleanup.sh
|
|
|
|
# else
|
|
|
|
# echo lock.file is $AGE min old.
|
|
|
|
fi
|
2011-10-24 12:17:15 +02:00
|
|
|
else
|
|
|
|
# If we got the lock, do a cleanup (releasing the lock) just in case something has still been left running
|
|
|
|
./cleanup.sh &> /dev/null
|
2011-10-17 15:04:06 +02:00
|
|
|
fi
|