From: Joerg Jaspert Date: Sat, 21 Feb 2009 09:42:48 +0000 (+0100) Subject: dinstall X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=83d7fddfbc1848b8895f299bd607031d082c19c1;p=dak dinstall make sure all functions start in a defined dir, currently $configdir. they have to cd to wherever they want to be if thats not good enough for them. Signed-off-by: Joerg Jaspert --- diff --git a/config/debian/dinstall b/config/debian/dinstall index 62520981..2627e599 100755 --- a/config/debian/dinstall +++ b/config/debian/dinstall @@ -103,11 +103,13 @@ function pgdump_pre() { log "Creating pre-daily-cron-job backup of projectb database..." pg_dump projectb > $base/backup/dump_$(date +%Y.%m.%d-%H:%M:%S) } + 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 - (cd $base/backup; ln -sf $POSTDUMP current) + ln -sf $POSTDUMP current } # Updating various files @@ -273,7 +275,8 @@ function wb() { function expire() { log "Expiring old database dumps..." - (cd $base/backup; $scriptsdir/expire_dumps -d . -p -f "dump_*") + cd $base/backup + $scriptsdir/expire_dumps -d . -p -f "dump_*" } function reports() { @@ -342,13 +345,12 @@ function aptftpcleanup() { function compress() { log "Compress old psql backups" - (cd $base/backup/ - find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +1 | - while read dumpname; do - echo "Compressing $dumpname" - bzip2 -9v "$dumpname" - done - ) + cd $base/backup/ + find -maxdepth 1 -mindepth 1 -type f -name 'dump_*' \! -name '*.bz2' \! -name '*.gz' -mtime +1 | + while read dumpname; do + echo "Compressing $dumpname" + bzip2 -9v "$dumpname" + done } function logstats() { @@ -392,6 +394,10 @@ function stage() { debug "Now calling function ${FUNC}. Arguments: ${ARGS}. Timestamp: ${TS}" + # Make sure we are always at the same place. If a function wants to be elsewhere, + # it has to cd first! + cd ${configdir} + if [ "${ERR}" = "false"]; then set +e fi @@ -400,6 +406,9 @@ function stage() { # No matter what happened in the function, we make sure we have set -e default state back set -e + # Make sure we are always at the same place. + cd ${configdir} + touch "${stagedir}/${FUNC}" if [ -n "${TIME}" ]; then