autodist-launcher: move code in 60-autodist-update to /usr/bin script
This commit is contained in:
parent
8794727a6a
commit
702d3cfe09
77
autodist-launcher
Executable file
77
autodist-launcher
Executable file
@ -0,0 +1,77 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist launcher
|
||||
# (c) 2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/autodist/config
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
# Disable icecc
|
||||
export PATH=/usr/bin:$PATH
|
||||
|
||||
i=$1
|
||||
|
||||
[ "$i" ] || {
|
||||
echo "Usage: autodist-launcher autodist_conf"
|
||||
exit 1
|
||||
}
|
||||
|
||||
PIDFILE=/run/autodist/autodist-launcher-${i}.pid
|
||||
[ -e $PIDFILE ] && {
|
||||
PIDCHECK=`cat $PIDFILE`
|
||||
[ "$PIDCHECK" -a -e /proc/$PIDCHECK ] && {
|
||||
echo "autodist-launcher for configuration $i already running; exiting."
|
||||
exit 0
|
||||
}
|
||||
}
|
||||
echo $$ > $PIDFILE
|
||||
trap "rm -f $PIDFILE; exit 1" SIGQUIT SIGINT SIGKILL SIGTERM
|
||||
|
||||
HOUR=`date +%H`
|
||||
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
|
||||
|
||||
AUTODIST_PIDFILE=/run/autodist/autodist.pid
|
||||
LOGFILE=/var/autodist/log/autodist.log
|
||||
LASTLOGFILE=/var/autodist/log/autodist-last.log
|
||||
|
||||
if [ -e $AUTODIST_PIDFILE ]; then
|
||||
PIDCHECK=`cat $AUTODIST_PIDFILE`
|
||||
if [ "$PIDCHECK" -a -e /proc/$PIDCHECK ]; then
|
||||
echo "autodist already running; exiting."
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
REPLOGFILE=$LOCAL_REPS_BASE_DIR/$r/autodist.log
|
||||
REPLASTLOGFILE=$LOCAL_REPS_BASE_DIR/$r/autodist-last.log
|
||||
|
||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||
|
||||
if [ ! "$AUTOPORT_UPDATE_NO_DISTROMATIC" ]; then
|
||||
distromatic -q -t $DISTROMATIC_REPOSITORY --gensrcpkglist > $LOCAL_REPS_BASE_DIR/$DISTROMATIC_REPOSITORY/srcpkglist 2>/dev/null
|
||||
fi
|
||||
|
||||
#autodist-upstream-updates -q -h -u -r $DISTROMATIC_REPOSITORY -o $r \
|
||||
# > $LOCAL_REPS_BASE_DIR/distromatic/$r/_popular.html
|
||||
autodist-upstream-updates -q -u -r $DISTROMATIC_REPOSITORY -o $r
|
||||
|
||||
[ -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
|
||||
rm -f ${PIDFILE}
|
@ -1,75 +1,17 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# autodist autoupdate hourly cron script
|
||||
# (c) 2008-2014 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
# (c) 2008-2021 by Silvan Calarco <silvan.calarco@mambasoft.it>
|
||||
#
|
||||
. /etc/autodist/config
|
||||
. /etc/sysconfig/autoport
|
||||
|
||||
ME=`basename $0`
|
||||
|
||||
# Disable icecc
|
||||
export PATH=/usr/bin:$PATH
|
||||
|
||||
# FIXME: parametrize automaint call
|
||||
if [ ! "$AUTOPORT_UPDATE_NO_AUTOMAINT" ]; then
|
||||
automaint -s devel-autodist -d devel -p devel-makedist
|
||||
fi
|
||||
|
||||
[ "$$" == "`pidof -x $ME`" -o "$$" == "`pidof -x 60-autodist-update`" ] || {
|
||||
# echo "Warning: $ME script already running; exiting."
|
||||
exit 0
|
||||
}
|
||||
|
||||
PIDFILE=/run/autodist/autodist.pid
|
||||
HOUR=`date +%H`
|
||||
[ "`uname -m`" = "x86_64" ] && HOST_IS_X86_64=1
|
||||
|
||||
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
|
||||
if [ ! "$AUTOPORT_UPDATE_NO_DISTROMATIC" ]; then
|
||||
pid_check
|
||||
distromatic -q -t $DISTROMATIC_REPOSITORY --gensrcpkglist > $LOCAL_REPS_BASE_DIR/$DISTROMATIC_REPOSITORY/srcpkglist 2>/dev/null
|
||||
fi
|
||||
|
||||
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
|
||||
echo "Running autodist-launcher ${i}"
|
||||
systemd-run -u autodist-launcher-${i} /usr/bin/autodist-launcher ${i}
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user