diff --git a/autodist-cgi b/autodist-cgi index bb6547b..3dd72d7 100755 --- a/autodist-cgi +++ b/autodist-cgi @@ -2,8 +2,8 @@ . /etc/sysconfig/autoport NUM=`echo "$QUERY_STRING" | sed -n 's/^.*NUM=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` -SECONDARY=`echo "$QUERY_STRING" | sed -n 's/^.*SECONDARY=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` -AS_SECONDARY=`echo "$QUERY_STRING" | sed -n 's/^.*AS_SECONDARY=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +HOST=`echo "$QUERY_STRING" | sed -n 's/^.*HOST=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` +AS_HOST=`echo "$QUERY_STRING" | sed -n 's/^.*AS_HOST=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"` 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"` @@ -12,9 +12,13 @@ FORMAT=`echo "$QUERY_STRING" | sed -n 's/^.*FORMAT=\([^&]*\).*$/\1/p' | sed "s/% [ ! "$FORMAT" ] && FORMAT=html [ "$LINES" ] || LINES=5 -[ "$AS_SECONDARY" ] && SECONDARY_ADD="&SECONDARY=1" -if [ ! "$AS_SECONDARY" -a "$FORMAT" = "xml" ]; then +[ "$HOST" ] || HOST=0 +[ "$AS_HOST" ] || AS_HOST=0 + +[ "$AS_HOST" -a "$HOST" != "0" ] && HOST_ADD="&HOST=$HOST" + +if [ "$AS_HOST" = "0" -a "$FORMAT" = "xml" ]; then echo -e "Content-type: text/xml\nPragma: no-cache\n" echo -n "ALL]
" - -[ "$SHOWINDEX" -o ! "$AS_SECONDARY" ] && \ -for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do - [ "${AUTOPORT_ARCH[$i]}" ] || continue - [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue - - if [ "${AUTOPORT_UPDATE[$i]}" ]; then - echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) " - elif [ "${AUTOPORT_CHROOT[$i]}" ]; then - echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) " - elif [ "${AUTOPORT_NATIVE[$i]}" ]; then - echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) " - elif [ "${AUTOPORT_CROSS[$i]}" ]; then - echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_CROSS[$i]};${AUTOPORT_ARCH[$i]}) " - fi -done - if [ "$SHOWINDEX" ]; then + echo "Host $AS_HOST:" + for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do + [ "${AUTOPORT_ARCH[$i]}" ] || continue + [ "${AUTOPORT_DISABLE[$i]}" -a "${AUTOPORT_DISABLE[$i]}" != "0" ] && continue + + if [ "${AUTOPORT_UPDATE[$i]}" ]; then + echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) " + elif [ "${AUTOPORT_CHROOT[$i]}" ]; then + echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) " + elif [ "${AUTOPORT_NATIVE[$i]}" ]; then + echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) " + elif [ "${AUTOPORT_CROSS[$i]}" ]; then + echo "${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_CROSS[$i]};${AUTOPORT_ARCH[$i]}) " + fi + done + echo "
" exit 0 -else - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWINDEX=1" 2>/dev/null +elif [ "$AS_HOST" = "0" ]; then + echo "Show: [All hosts] [Build hosts monitor]
" + for h in `seq 0 ${#AUTOPORT_CGI_HOST[*]}`; do + curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&SHOWINDEX=1" 2>/dev/null + done + echo "
" fi -[ ! "$AS_SECONDARY" ] && echo "
" +[ ! "$SHOWLOG" -a "$HOST" = "$AS_HOST" ] && echo "

Host: `hostname -s` (`uname -m`, kernel `uname -r`)

" -[ ! "$SHOWLOG" -a "$SECONDARY" = "$AS_SECONDARY" ] && echo "

Host: `hostname -s` (`uname -m`, kernel `uname -r`)

" - -if [ "$SHOWLOG" -a "$SECONDARY" != "$AS_SECONDARY" ]; then - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWLOG=$SHOWLOG&NUM=$NUM&LOG=$LOG" 2>/dev/null +if [ "$SHOWLOG" -a "$HOST" != "$AS_HOST" ]; then + curl "${AUTOPORT_CGI_HOST[$HOST]}?AS_HOST=$HOST&SHOWLOG=$SHOWLOG&NUM=$NUM&LOG=$LOG" 2>/dev/null else for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do @@ -75,8 +79,25 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do else continue fi - if [ "$SHOWLOG" ]; then - if [ "$SECONDARY" = "$AS_SECONDARY" -a "$NUM" = "$i" ]; then + if [ "$SHOWLOG" = "monitor" ]; then + echo "

Build hosts monitor

" + icecream-monitor localhost listcs | \ + while read line; do + [ "${line:0:8}" = "200 done" ] && printon= + if [ "$printon" ]; then + set -- $line + case $2 in + \(*) echo "$line
" ;; + *) echo "$line
" ;; + esac + fi + [ "${line:0:6}" = "listcs" ] && printon=1 + done + echo "
" + RELOADTIME=5000 + break + elif [ "$SHOWLOG" ]; then + if [ "$HOST" = "$AS_HOST" -a "$NUM" = "$i" ]; then echo "

$SHOWLOG log in ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}):

" cat << _EOF
@@ -102,8 +123,8 @@ _EOF echo "" for t in prepare update build install send; do echo -n "" || echo "" - [ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "" || echo "" + [ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && 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 "OKFAILEDOKFAILED
" @@ -115,25 +136,25 @@ _EOF elif [ ! "$SHOWLOG" ]; then RELOADTIME=60000 [[ "$NUM" && "$NUM" != "$i" ]] && continue - [[ "$SECONDARY" = "$AS_SECONDARY" ]] || continue + [[ "$HOST" = "$AS_HOST" ]] || continue if [ "${AUTOPORT_UPDATE[$i]}" ]; then - echo "* ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) (type:autodist update)" - echo " [ log last ]" + echo "* ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) (type:autodist update)" + echo " [ log last ]" fi if [ "${AUTOPORT_CHROOT[$i]}" ]; then - echo "* ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) (type:chroot autoport chroot:${AUTOPORT_CHROOT[$i]})" - echo " [ log last ]" + echo "* ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) (type:chroot autoport chroot:${AUTOPORT_CHROOT[$i]})" + echo " [ log last ]" fi if [ "${AUTOPORT_NATIVE[$i]}" ]; then - echo "* ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) (type:native autoport)" - echo " [ log last ]" + echo "* ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}) (type:native autoport)" + echo " [ log last ]" fi if [ "${AUTOPORT_CROSS[$i]}" ]; then - echo "* cross-platform autoport (arch:${AUTOPORT_CROSS[$i]})" - echo " [ last ]" + echo "* cross-platform autoport (arch:${AUTOPORT_CROSS[$i]})" + echo " [ last ]" fi cat << _EOF
@@ -220,7 +241,7 @@ _EOF for b in `seq 1 ${#BUILDNOW[*]}`; do set -- ${BUILDNOW[$b]} if [ "${BUILDLOG[$b]}" ]; then - echo "$1: $2 $3 $4 $5 $6 " + echo "$1: $2 $3 $4 $5 $6 " elif [ "$1" ]; then echo "$1: $2 $3 $4 $5 $6 " fi @@ -236,18 +257,23 @@ _EOF echo "
" fi done -if [ "$AUTOPORT_CGI_SECONDARY" -a ! "$SHOWLOG" ]; then - if [ "$NUM" -a "$SECONDARY" ]; then - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES&NUM=$NUM&SECONDARY=$SECONDARY" 2>/dev/null - elif [ ! "$NUM" ]; then - curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES" 2>/dev/null + +# only root host (0) calls other hosts +if [ "$AS_HOST" = "0" -a ! "$SHOWLOG" ]; then + for h in `seq 1 ${#AUTOPORT_CGI_HOST[*]}`; do + if [ "$NUM" -a "$HOST" = "$h" ]; then + curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES&NUM=$NUM&HOST=$HOST" 2>/dev/null + elif [ ! "$NUM" ]; then + curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&LINES=$LINES" 2>/dev/null + fi + done +fi +fi +if [ "$AS_HOST" = "0" ]; then + echo "

Generated by autodist CGI interface. Last update: `date`" + if [ "$FORMAT" = "xml" ]; then + echo -n "]]>" + [ "$RELOADTIME" ] && echo -n "$RELOADTIME" + echo "" fi 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