#!/bin/bash
cd /var/www/html/apt-panopticon/apt-panopticon_cgp
if [ -d .git ] ; then
git pull > /dev/null
chown -R www-data:www-data *
fi
cd /var/www/html/apt-panopticon/apt-panopticon
if [ -d .git ] ; then
git pull > /dev/null
chown -R www-data:www-data *
fi
# 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 "apt-panopticon.lua" | grep -v "grep apt-panopticon.lua" | while read line ; do touch apt-panopticon.running ; exit ; done
if [ -f apt-panopticon.running ] ; then
echo "Previous apt-panopticon still running, exiting."
echo "Previous apt-panopticon still running, exiting."
./laggers
rm apt-panopticon.running
exit 1
fi
echo "Crashed apt-panopticon detected, removing stale lock file."
echo "Crashed apt-panopticon detected, removing stale lock file."
./laggers
rm apt-panopticon.lock
fi
rm ../results; ln -s apt-panopticon/results_old ../results
flock -n apt-panopticon.lock ionice -c3 nice -n 19 timeout --kill-after=20.0 --foreground 8.5m ./apt-panopticon.lua && rm apt-panopticon.lock
if [ -f apt-panopticon.lock ] ; then
echo "apt-panopticon timed out."
./laggers
fi
rm ../results; ln -s apt-panopticon/results ../results
chown -R www-data:www-data *