webbuild: use sudo wrapper to sort list of log files to take the most recent

This commit is contained in:
Silvan Calarco 2013-05-23 15:44:13 +02:00
parent 9cfdccccc0
commit 641029e7ec
2 changed files with 3 additions and 11 deletions

View File

@ -289,7 +289,7 @@ function environment_logdir() {
elif [ "${AUTOPORT_NATIVE[$env]}" ]; then elif [ "${AUTOPORT_NATIVE[$env]}" ]; then
local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}` local envhome=`eval echo ~${AUTOPORT_CHROOT_USER[$env]}`
if [ "${AUTOPORT_CHROOT_USER[$env]}" = "autodist" ]; then if [ "${AUTOPORT_CHROOT_USER[$env]}" = "autodist" ]; then
echo "$envhome/log" echo "/var/autodist/log/"
else else
echo "$envhome/.autodist/log/" echo "$envhome/.autodist/log/"
fi fi

View File

@ -33,16 +33,8 @@ function showlog() {
LOGDIR=`environment_logdir $ENVIRONMENT` LOGDIR=`environment_logdir $ENVIRONMENT`
LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4" LOGFILES="$LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"
# sort by most recent and take first
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do LOGFILES=`$SUDO_WRAPPER 0 $ENVIRONMENT "$USER" "" "ls -t $LOGFILES 2>/dev/null | head -1"`
[ "$i" = "$ENVIRONMENT" ] && continue
[ "${AUTOPORT_ARCH[$i]}" = "${AUTOPORT_ARCH[$ENVIRONMENT]}" ] || continue
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
LOGDIR="/var/autodist/log"
LOGFILES="$LOGFILES $LOGDIR/$LOGFILE1 $LOGDIR/$LOGFILE2 $LOGDIR/$LOGFILE3 $LOGDIR/$LOGFILE4"
fi
done
LOGFILES=`ls -t $LOGFILES | head -1`
fi fi
echo -n "<output><![CDATA[<hr><b>Console output for $PACKAGE ($LOGTYPE$LOGSTATUSAPPEND):</b>" echo -n "<output><![CDATA[<hr><b>Console output for $PACKAGE ($LOGTYPE$LOGSTATUSAPPEND):</b>"
echo "<div align=left class=output id=$LOGOUTPUTID>" echo "<div align=left class=output id=$LOGOUTPUTID>"