diff options
Diffstat (limited to 'update_apt-panopticon')
-rwxr-xr-x | update_apt-panopticon | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/update_apt-panopticon b/update_apt-panopticon index b70f4c3..dde18a5 100755 --- a/update_apt-panopticon +++ b/update_apt-panopticon | |||
@@ -1,16 +1,55 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | cd /var/www/html/apt-panopticon/apt-panopticon_cgp | 3 | PANOPATH="/var/www/html/apt-panopticon" |
4 | #git pull > /dev/null | 4 | #KEEPDAYS=$((2 * 30)) |
5 | #chown -R mirrors:www-data * | 5 | |
6 | cd /var/www/html/apt-panopticon/apt-panopticon | 6 | cd ${PANOPATH}/apt-panopticon_cgp |
7 | #git pull > /dev/null | 7 | if [ -d .git ] ; then |
8 | #chown -R mirrors:www-data * | 8 | git pull > /dev/null |
9 | 9 | chown -R www-data:www-data * | |
10 | if [ ! -f apt-panopticon.lock ] ; then | 10 | fi |
11 | rm ../results; ln -s apt-panopticon/results_old ../results | 11 | cd ${PANOPATH}/apt-panopticon |
12 | flock -n apt-panopticon.lock ./apt-panopticon.lua && rm apt-panopticon.lock | 12 | if [ -d .git ] ; then |
13 | rm ../results; ln -s apt-panopticon/results ../results | 13 | git pull > /dev/null |
14 | chown -R www-data:www-data * | ||
15 | fi | ||
16 | |||
17 | # Check if the lock file still exists. | ||
18 | if [ -f apt-panopticon.lock ] ; then | ||
19 | # Check if it's still running. | ||
20 | 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 | ||
21 | if [ -f apt-panopticon.running ] ; then | ||
22 | echo "Previous apt-panopticon still running, exiting." | ||
23 | echo "Previous apt-panopticon still running, exiting." | ||
24 | ./laggers | ||
25 | rm apt-panopticon.running | ||
26 | exit 1 | ||
27 | fi | ||
28 | echo "Crashed apt-panopticon detected, removing stale lock file." | ||
29 | echo "Crashed apt-panopticon detected, removing stale lock file." | ||
30 | ./laggers | ||
31 | rm apt-panopticon.lock | ||
32 | fi | ||
33 | |||
34 | # Clean up any mess left over from failed runs. | ||
35 | find results_* -maxdepth 2 ! -name "pkgmaster.devuan.org" -name "*.*" -type d -print0 | xargs -0rt /bin/rm -fr | ||
36 | |||
37 | if [ "z" != "z${KEEPDAYS}" ] ; then | ||
38 | # Remove old results. | ||
39 | find . -daystart -maxdepth 2 -name "stamp" -type f ! -mtime $((0 - ${KEEPDAYS})) -printf "%h\0" | xargs -0rt /bin/rm -fr | ||
40 | find . -daystart -maxdepth 2 -name "results_*.tar.xz" -type f ! -mtime $((0 - ${KEEPDAYS})) -print0 | xargs -0rt /bin/rm -f | ||
41 | find . -maxdepth 1 -name "results_*" -type d -empty -print0 | xargs -0rt /bin/rm -fr | ||
14 | fi | 42 | fi |
15 | 43 | ||
16 | #chown -R mirrors:www-data /var/www/html/SledjHamr/apt-panopticon/results | 44 | rm ../results; ln -s apt-panopticon/results_old ../results |
45 | 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 | ||
46 | if [ -f apt-panopticon.lock ] ; then | ||
47 | echo "apt-panopticon timed out." | ||
48 | ./laggers | ||
49 | fi | ||
50 | rm ../results; ln -s apt-panopticon/results ../results | ||
51 | |||
52 | chown -R www-data:www-data * | ||
53 | |||
54 | # Clean up any mess left over from THIS failed run. | ||
55 | find results_* -maxdepth 2 ! -name "pkgmaster.devuan.org" -name "*.*" -type d -print0 | xargs -0rt /bin/rm -fr | ||