aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/update_apt-panopticon
blob: 969cc8f4c482ab53ccabbb25c9c876ba3db62464 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash

PANOPATH="/var/www/html/apt-panopticon"
#KEEPDAYS=$((2 * 30))

cd ${PANOPATH}/apt-panopticon_cgp
if [ -d .git ] ; then
    git pull > /dev/null
    chown -hR www-data:www-data *
fi
cd ${PANOPATH}/apt-panopticon
if [ -d .git ] ; then
    git pull > /dev/null
    chown -hR 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

# Clean up any mess left over from failed runs.
find results_* -maxdepth 2 ! -name "pkgmaster.devuan.org" -name "*.*" -type d -print0 | xargs -0rt /bin/rm -fr

if [ "z" != "z${KEEPDAYS}" ] ; then
    # Remove old results.
    find . -daystart -maxdepth 2 -name "stamp"            -type f ! -mtime $((0 - ${KEEPDAYS})) -printf "%h\0" | xargs -0rt /bin/rm -fr
    find . -daystart -maxdepth 2 -name "results_*.tar.xz" -type f ! -mtime $((0 - ${KEEPDAYS})) -print0        | xargs -0rt /bin/rm -f
    find .           -maxdepth 1 -name "results_*"        -type d -empty -print0                               | xargs -0rt /bin/rm -fr
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 -hR www-data:www-data *

# Clean up any mess left over from THIS failed run.
find results_* -maxdepth 2 ! -name "pkgmaster.devuan.org" -name "*.*" -type d -print0 | xargs -0rt /bin/rm -fr