blob: 275676eeb0b6fb7c234ea13c0250f32168807dd9 (
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
|
#!/bin/bash
# run at nice 5. it can churn quite a bit of cpu after all.
renice +5 -p $$ > /dev/null
# setup paths
SPATH="/srv/http/archweb"
ARCHES="i686 x86_64"
# having "more important repos" last should make [core] trickle to the top of
# the updates list each hour rather than being overwhelmed by big [extra] and
# [community] updates
REPOS="community-testing multilib-testing multilib community extra testing core"
LOGOUT="/tmp/archweb_update.log"
# figure out what operation to perform
cmd="$(basename $0)"
if [[ $cmd != "update-web-db" && $cmd != "update-web-files-db" ]]; then
echo "Invalid command name '$cmd' specified!"
exit 1
fi
echo "$cmd: Updating DB at $(date)" >> "${LOGOUT}"
## do the dirty, then output the result to a file.
cd $SPATH
for repo in ${REPOS}; do
for arch in ${ARCHES}; do
case "$cmd" in
update-web-db)
dbfile="/srv/ftp/${repo}/os/${arch}/${repo}.db.tar.gz"
flags="" ;;
update-web-files-db)
dbfile="/srv/ftp/${repo}/os/${arch}/${repo}.files.tar.gz"
flags="--filesonly" ;;
esac
if [[ -f $dbfile ]]; then
echo "Updating ${repo}-${arch}" >> "${LOGOUT}"
./manage.py reporead ${flags} ${arch} ${dbfile} >> "${LOGOUT}" 2>&1
echo ""
fi
done
done
echo "" >> "${LOGOUT}"
# rotate the file if it is getting big (> 10M), overwriting any old backup
if [[ $(stat -c%s "${LOGOUT}") -gt 10485760 ]]; then
mv "${LOGOUT}" "${LOGOUT}.old"
fi
# vim: set ts=4 sw=4 et ft=sh:
|