From e0ee0726c8c16fc7182e6beedcf25fe77cf0f3c0 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sat, 19 Jan 2013 17:46:30 +0100 Subject: [PATCH] 60-autodist-update: start using autoport sysconfig configuration for update cron also - file renamed from 60-autodist-autobuild --- etc/cron.hourly/60-autodist-autobuild | 51 ---------------------- etc/cron.hourly/60-autodist-update | 63 +++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 51 deletions(-) delete mode 100755 etc/cron.hourly/60-autodist-autobuild create mode 100755 etc/cron.hourly/60-autodist-update diff --git a/etc/cron.hourly/60-autodist-autobuild b/etc/cron.hourly/60-autodist-autobuild deleted file mode 100755 index f0e06b5..0000000 --- a/etc/cron.hourly/60-autodist-autobuild +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# -# autodist autobuild hourly cron script -# (c) 2008-2012 by Silvan Calarco -# -. /etc/autodist/config - -ME=`basename $0` -[ "$$" == "`pidof -x $ME`" -o "$$" == "`pidof -x 60-openmamba-autobuild-autodist`" ] || { - echo "Warning: $ME script already running; exiting." - exit 0 -} - -AUTODIST_CMD="linux32 autodist" -AUTODIST_REPOSITORY=devel-autodist -DISTROMATIC_REPOSITORY=devel-future - -LOGFILE=/var/autodist/log/autodist.log -LASTLOGFILE=/var/autodist/log/autodist-last.log -REPLOGFILE=$LOCAL_REPS_BASE_DIR/$AUTODIST_REPOSITORY/autodist.log -REPLASTLOGFILE=$LOCAL_REPS_BASE_DIR/$AUTODIST_REPOSITORY/autodist-last.log - -PIDFILE=/var/run/autodist/autodist.pid -HOUR=`date +%H` - -function pid_check() { - - [ -e $PIDFILE ] && PIDCHECK=`cat $PIDFILE` - - [ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && { - echo "Error: an autodist process is already running; exiting for safety." - exit 0 - - } -} - -pid_check -distromatic -q -t $DISTROMATIC_REPOSITORY --gensrcpkglist > $LOCAL_REPS_BASE_DIR/$DISTROMATIC_REPOSITORY/srcpkglist - -pid_check -autodist-upstream-updates -q -h -u -r $DISTROMATIC_REPOSITORY -o $AUTODIST_REPOSITORY \ - > $LOCAL_REPS_BASE_DIR/distromatic/$AUTODIST_REPOSITORY/_popular.html - -pid_check -[ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE -su -l autodist -c "$AUTODIST_CMD -a --server $AUTODIST_REPOSITORY" > $LOGFILE -[ -e $REPLOGFILE ] && mv $REPLOGFILE $REPLASTLOGFILE -cp $LOGFILE $REPLOGFILE - -#pid_check -#distromatic -q -t devel-autodist --gensrcpkglist > $local_ftp/$REPOSITORY/srcpkglist diff --git a/etc/cron.hourly/60-autodist-update b/etc/cron.hourly/60-autodist-update new file mode 100755 index 0000000..ae3b914 --- /dev/null +++ b/etc/cron.hourly/60-autodist-update @@ -0,0 +1,63 @@ +#!/bin/bash +# +# autodist autoupdate hourly cron script +# (c) 2008-2013 by Silvan Calarco +# +. /etc/autodist/config +. /etc/sysconfig/autoport + +ME=`basename $0` +[ "$$" == "`pidof -x $ME`" -o "$$" == "`pidof -x 60-autodist-update`" ] || { + echo "Warning: $ME script already running; exiting." + exit 0 +} + +PIDFILE=/var/run/autodist/autodist.pid +HOUR=`date +%H` + +function pid_check() { + + [ -e $PIDFILE ] && PIDCHECK=`cat $PIDFILE` + + [ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && { + echo "Error: an autodist process is already running; exiting for safety." + exit 0 + + } +} + +for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do + for r in ${AUTOPORT_REPOSITORIES[$i]}; do + [ "${AUTOPORT_ARCH[$i]}" ] || continue + [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue + + if [ "$HOST_IS_X86_64" -a "${AUTOPORT_ARCH[$i]}" != "x86_64" ]; then + CMD_PREFIX=linux32 + else + CMD_PREFIX= + fi + + # TODO: parametrize DISTROMATIC_REPOSITORY and following log files + DISTROMATIC_REPOSITORY=devel-future + + LOGFILE=/var/autodist/log/autodist.log + LASTLOGFILE=/var/autodist/log/autodist-last.log + REPLOGFILE=$LOCAL_REPS_BASE_DIR/$r/autodist.log + REPLASTLOGFILE=$LOCAL_REPS_BASE_DIR/$r/autodist-last.log + + if [ "${AUTOPORT_UPDATE[$i]}" ]; then + pid_check + distromatic -q -t $DISTROMATIC_REPOSITORY --gensrcpkglist > $LOCAL_REPS_BASE_DIR/$DISTROMATIC_REPOSITORY/srcpkglist + + pid_check + autodist-upstream-updates -q -h -u -r $DISTROMATIC_REPOSITORY -o $r \ + > $LOCAL_REPS_BASE_DIR/distromatic/$r/_popular.html + + pid_check + [ -e $LOGFILE ] && mv $LOGFILE $LASTLOGFILE + su -l autodist -c "$CMD_PREFIX autodist -a --server $r" > $LOGFILE + [ -e $REPLOGFILE ] && mv $REPLOGFILE $REPLASTLOGFILE + cp $LOGFILE $REPLOGFILE + fi + done +done