X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=config%2Fdebian%2Fcron.dinstall;h=5f17739a27e283d620e86d2e50fdbbd144f534d8;hb=ec2548b155c22b68b7340b25087ca71defd64c21;hp=3401fb27115d9369dbf395a32f42dd1b6ec12423;hpb=9bbe85e05fbf25ac69ad60d8e6cc06035d671155;p=dak.git diff --git a/config/debian/cron.dinstall b/config/debian/cron.dinstall index 3401fb27..5f17739a 100755 --- a/config/debian/cron.dinstall +++ b/config/debian/cron.dinstall @@ -28,32 +28,8 @@ export SCRIPTVARS=/srv/ftp.debian.org/dak/config/debian/vars ######################################################################## # Functions # ######################################################################## -# log something (basically echo it together with a timestamp) -# -# Set $PROGRAM to a string to have it added to the output. -function log () { - if [ -z "${PROGRAM}" ]; then - echo "$(date +"%b %d %H:%M:%S") $(hostname -s) [$$] $@" - else - echo "$(date +"%b %d %H:%M:%S") $(hostname -s) ${PROGRAM}[$$]: $@" - fi -} - -# log the message using log() but then also send a mail -# to the address configured in MAILTO (if non-empty) -function log_error () { - log "$@" - if [ -z "${MAILTO}" ]; then - echo "$@" | mail -e -s "[$PROGRAM@$(hostname -s)] ERROR [$$]" ${MAILTO} - fi -} - -# debug log, only output when DEBUG=1 -function debug () { - if [ $DEBUG -eq 1 ]; then - log "$*" - fi -} +# common functions are "outsourced" +. "${configdir}/common" # Timestamp. Used for dinstall stat graphs function ts() { @@ -98,9 +74,20 @@ function pgdump_pre() { function pgdump_post() { log "Creating post-daily-cron-job backup of projectb database..." cd $base/backup - POSTDUMP=$base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S) - pg_dump projectb > $POSTDUMP - ln -sf $POSTDUMP current + POSTDUMP=$(date +%Y.%m.%d-%H:%M:%S) + pg_dump projectb > $base/backup/dump_$POSTDUMP + pg_dumpall --globals-only > $base/backup/dumpall_$POSTDUMP + ln -sf $base/backup/dump_$POSTDUMP current + ln -sf $base/backup/dumpall_$POSTDUMP currentall +} + +# Load the dak-dev projectb +function pgdakdev() { + cd $base/backup + echo "drop database projectb" | psql -p 5433 template1 + cat currentall | psql -p 5433 template1 + createdb -p 5433 -T template0 projectb + fgrep -v '\connect' current | psql -p 5433 projectb } # Updating various files @@ -353,20 +340,29 @@ function savetimestamp() { echo ${NOW} > "${dbdir}/dinstallstart" } +function maillogfile() { + cat "$LOGFILE" | mail -s "Log for dinstall run of ${NOW}" cron@ftp-master.debian.org +} + function renamelogfile() { - if [ -f "${dbdir}/dinstallstart" ]; then - RENAMETO=$(cat "${dbdir}/dinstallstart") - mv "$LOGFILE" "$logdir/dinstall_${RENAMETO}.log" - logstats "$logdir/dinstall_${RENAMETO}.log" - bzip2 -9 "$logdir/dinstall_${RENAMETO}.log" - else - error "Problem, I don't know when dinstall started, unable to do log statistics." - NOW=`date "+%Y.%m.%d-%H:%M:%S"` - mv "$LOGFILE" "$logdir/dinstall_${NOW}.log" - bzip2 -9 "$logdir/dinstall_${NOW}.log" - fi + if [ -f "${dbdir}/dinstallstart" ]; then + NOW=$(cat "${dbdir}/dinstallstart") + maillogfile + mv "$LOGFILE" "$logdir/dinstall_${NOW}.log" + logstats "$logdir/dinstall_${NOW}.log" + bzip2 -9 "$logdir/dinstall_${NOW}.log" + else + error "Problem, I don't know when dinstall started, unable to do log statistics." + NOW=`date "+%Y.%m.%d-%H:%M:%S"` + maillogfile + mv "$LOGFILE" "$logdir/dinstall_${NOW}.log" + bzip2 -9 "$logdir/dinstall_${NOW}.log" + fi } +function testingsourcelist() { + dak ls -s testing -f heidi -r .| egrep 'source$' > ${webdir}/testing.list +} ######################################################################## ######################################################################## @@ -426,14 +422,14 @@ function stage() { touch "${stagedir}/${FUNC}" + if [ -n "${TIME}" ]; then + ts "${TIME}" + fi + if [ -f "${LOCK_STOP}" ]; then log "${LOCK_STOP} exists, exiting immediately" exit 42 fi - - if [ -n "${TIME}" ]; then - ts "${TIME}" - fi } ######################################################################## @@ -461,8 +457,14 @@ fi # How many logfiles to keep LOGROTATE=${LOGROTATE:-400} +# Marker for dinstall start +DINSTALLSTART="${lockdir}/dinstallstart" +# Marker for dinstall end +DINSTALLEND="${lockdir}/dinstallend" + # Timestamps start at -1. so first gets 0 TS=-1 +touch "${DINSTALLSTART}" ts "startup" # Tell everyone we are doing some work @@ -681,6 +683,14 @@ GO=( ) stage $GO +GO=( + FUNC="pgdakdev" + TIME="dak-dev db" + ARGS="" + ERR="false" +) +stage $GO + GO=( FUNC="expire" TIME="expire_dumps" @@ -709,7 +719,7 @@ GO=( FUNC="bts" TIME="" ARGS="" - ERR="" + ERR="false" ) stage $GO @@ -747,6 +757,13 @@ GO=( ) stage $GO +GO=( + FUNC="testingsourcelist" + TIME="" + ARGS="" + ERR="false" +) + rm -f ${LOCK_BRITNEY} GO=( @@ -782,4 +799,5 @@ stage $GO # Now, at the very (successful) end of dinstall, make sure we remove # our stage files, so the next dinstall run will do it all again. -rm -f "${stagedir}/*" +rm -f ${stagedir}/* +touch "${DINSTALLEND}"