summaryrefslogtreecommitdiffstats
path: root/cron-jobs/update-web-db
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-08-25 18:30:42 +0200
committerDan McGee <dan@archlinux.org>2010-08-25 18:30:42 +0200
commit0e9dc9f69e290fe352de7b2bbd288890a78eced5 (patch)
tree3c2c49a7a5cd92c4f048afe7ddcba7e2dd438ba5 /cron-jobs/update-web-db
parent9f695214d0d63f60d67bb5c1caeae50110c03f7a (diff)
downloaddbscripts-0e9dc9f69e290fe352de7b2bbd288890a78eced5.tar.gz
dbscripts-0e9dc9f69e290fe352de7b2bbd288890a78eced5.tar.xz
Add update-web-db cronjob
This has been untracked by version control for a while on gerolde in both the cron-jobs directory and in /etc/cron.hourly/. Add it here so we can make changes and know what is going on. This is an improved script over what we currently have. It is one script instead of two, and it does things a little smarter with the logging. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'cron-jobs/update-web-db')
-rwxr-xr-xcron-jobs/update-web-db47
1 files changed, 47 insertions, 0 deletions
diff --git a/cron-jobs/update-web-db b/cron-jobs/update-web-db
new file mode 100755
index 0000000..8631a04
--- /dev/null
+++ b/cron-jobs/update-web-db
@@ -0,0 +1,47 @@
+#!/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 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 arch in ${ARCHES}; do
+ for repo in ${REPOS}; do
+ echo "Updating ${repo}-${arch}"
+ 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
+ ./manage.py reporead ${flags} ${arch} ${dbfile}
+ echo ""
+ done
+done >> "${LOGOUT}" 2>&1
+
+echo "" >> "${LOGOUT}"
+
+# rotate the file if it is getting big (> 10M), overwriting any old backup
+if [[ $(stat -c%s update-web-db) -gt 10485760 ]]; then
+ mv "${LOGOUT}" "${LOGOUT}.old"
+fi