diff --git a/autodist-cgi b/autodist-cgi index c6f7c92..bb6547b 100755 --- a/autodist-cgi +++ b/autodist-cgi @@ -7,11 +7,20 @@ AS_SECONDARY=`echo "$QUERY_STRING" | sed -n 's/^.*AS_SECONDARY=\([^&]*\).*$/\1/p SHOWLOG=`echo "$QUERY_STRING" | sed -n 's/^.*SHOWLOG=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` SHOWINDEX=`echo "$QUERY_STRING" | sed -n 's/^.*SHOWINDEX=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` LINES=`echo "$QUERY_STRING" | sed -n 's/^.*LINES=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +FORMAT=`echo "$QUERY_STRING" | sed -n 's/^.*FORMAT=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` + +[ ! "$FORMAT" ] && FORMAT=html [ "$LINES" ] || LINES=5 [ "$AS_SECONDARY" ] && SECONDARY_ADD="&SECONDARY=1" -echo -e "Content-type: text/html; charset=UTF-8\n\n" +if [ ! "$AS_SECONDARY" -a "$FORMAT" = "xml" ]; then + echo -e "Content-type: text/xml\nPragma: no-cache\n" + echo -n "ALL]
" @@ -75,20 +84,36 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do _EOF echo -n "
"
          if [ "$SHOWLOG" = "current" ]; then
+            RELOADTIME=600000
             cat $LOGFILE | sed "s|<|\<|g"
          elif [ "$SHOWLOG" = "last" ]; then
             cat $LASTLOGFILE | sed "s|<|\<|g"
          else
+            # Security check
+            [ "${SHOWLOG/\/\.}" != "${SHOWLOG}" ] && continue
             if [ "${AUTOPORT_CHROOT[$i]}" ]; then
-               BUILDLOGFILE="/var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autodist/log/$SHOWLOG"
+               BUILDLOGDIR="/var/autoport/${AUTOPORT_CHROOT[$i]}/home/${AUTOPORT_CHROOT_USER[$i]}/.autodist/log/"
            elif [ "${AUTOPORT_NATIVE[$i]}" -o "${AUTOPORT_UPDATE[$i]}" ]; then
-               BUILDLOGFILE="/var/autodist/log/$SHOWLOG"
+               BUILDLOGDIR="/var/autodist/log/"
             fi
-            [ -e $BUILDLOGFILE ] && cat $BUILDLOGFILE | sed "s|<|\<|g"
+            if [ "${SHOWLOG/\/ok\/}" != "${SHOWLOG}" -o "${SHOWLOG/\failed\/}" != "${SHOWLOG}" ]; then
+               SHOWLOGPKG=${SHOWLOG/*\/}
+               [ "${SHOWLOGPKG}" ] || continue
+               echo ""
+               for t in prepare update build install send; do
+                  echo -n "" || echo ""
+                  [ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "" || echo ""
+                  echo ""
+               done
+               echo "
Last ${SHOWLOGPKG} logs:
$t:" + [ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "OKFAILED
" + fi + [ -e ${BUILDLOGDIR}${SHOWLOG} ] && cat ${BUILDLOGDIR}${SHOWLOG} | sed "s|<|\<|g" fi echo "
" fi elif [ ! "$SHOWLOG" ]; then + RELOADTIME=60000 [[ "$NUM" && "$NUM" != "$i" ]] && continue [[ "$SECONDARY" = "$AS_SECONDARY" ]] || continue if [ "${AUTOPORT_UPDATE[$i]}" ]; then @@ -220,3 +245,9 @@ if [ "$AUTOPORT_CGI_SECONDARY" -a ! "$SHOWLOG" ]; then fi fi [ ! "$AS_SECONDARY" ] && echo "

Generated by autodist CGI interface. Last update: `date`" + +if [ ! "$AS_SECONDARY" -a "$FORMAT" = "xml" ]; then + echo -n "]]>" + [ "$RELOADTIME" ] && echo -n "$RELOADTIME" + echo "" +fi