autodist-cgi: implement support for multiple secondary hosts; use AS_HOST=# (0 for root host)
autodist-cgi: implement distributed builds monitoring page using icecream-monitor script
This commit is contained in:
parent
a36d759531
commit
cd1132a916
138
autodist-cgi
138
autodist-cgi
@ -2,8 +2,8 @@
|
|||||||
. /etc/sysconfig/autoport
|
. /etc/sysconfig/autoport
|
||||||
|
|
||||||
NUM=`echo "$QUERY_STRING" | sed -n 's/^.*NUM=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
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"`
|
HOST=`echo "$QUERY_STRING" | sed -n 's/^.*HOST=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
|
||||||
AS_SECONDARY=`echo "$QUERY_STRING" | sed -n 's/^.*AS_SECONDARY=\([^&]*\).*$/\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"`
|
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"`
|
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"`
|
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
|
[ ! "$FORMAT" ] && FORMAT=html
|
||||||
|
|
||||||
[ "$LINES" ] || LINES=5
|
[ "$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 -e "Content-type: text/xml\nPragma: no-cache\n"
|
||||||
echo -n "<autodist><output><![CDATA["
|
echo -n "<autodist><output><![CDATA["
|
||||||
RELOADTIME=3600000
|
RELOADTIME=3600000
|
||||||
@ -22,36 +26,36 @@ else
|
|||||||
echo -e "Content-type: text/html; charset=UTF-8\n"
|
echo -e "Content-type: text/html; charset=UTF-8\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! "$AS_SECONDARY" ] && echo "Build environments: [<a href=\"?NUM=\">ALL</a>]<br>"
|
|
||||||
|
|
||||||
[ "$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 "<a href=\"?NUM=$i$SECONDARY_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]})</a> "
|
|
||||||
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
|
||||||
echo "<a href=\"?NUM=$i$SECONDARY_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]})</a> "
|
|
||||||
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
|
||||||
echo "<a href=\"?NUM=$i$SECONDARY_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]})</a> "
|
|
||||||
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
|
||||||
echo "<a href=\"?NUM=$i$SECONDARY_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_CROSS[$i]};${AUTOPORT_ARCH[$i]})</a> "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "$SHOWINDEX" ]; then
|
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 "<a href=\"?NUM=$i$HOST_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]})</a> "
|
||||||
|
elif [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||||
|
echo "<a href=\"?NUM=$i$HOST_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]})</a> "
|
||||||
|
elif [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||||
|
echo "<a href=\"?NUM=$i$HOST_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]})</a> "
|
||||||
|
elif [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||||
|
echo "<a href=\"?NUM=$i$HOST_ADD\">${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_CROSS[$i]};${AUTOPORT_ARCH[$i]})</a> "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "<br>"
|
||||||
exit 0
|
exit 0
|
||||||
else
|
elif [ "$AS_HOST" = "0" ]; then
|
||||||
curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWINDEX=1" 2>/dev/null
|
echo "Show: [<a href=\"?NUM=\">All hosts</a>] [<a href=\"?SHOWLOG=monitor\">Build hosts monitor</a>]<br>"
|
||||||
|
for h in `seq 0 ${#AUTOPORT_CGI_HOST[*]}`; do
|
||||||
|
curl "${AUTOPORT_CGI_HOST[$h]}?AS_HOST=$h&SHOWINDEX=1" 2>/dev/null
|
||||||
|
done
|
||||||
|
echo "<hr>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! "$AS_SECONDARY" ] && echo "<hr>"
|
[ ! "$SHOWLOG" -a "$HOST" = "$AS_HOST" ] && echo "<h2>Host: `hostname -s` (`uname -m`, kernel `uname -r`)</h2>"
|
||||||
|
|
||||||
[ ! "$SHOWLOG" -a "$SECONDARY" = "$AS_SECONDARY" ] && echo "<h2>Host: `hostname -s` (`uname -m`, kernel `uname -r`)</h2>"
|
if [ "$SHOWLOG" -a "$HOST" != "$AS_HOST" ]; then
|
||||||
|
curl "${AUTOPORT_CGI_HOST[$HOST]}?AS_HOST=$HOST&SHOWLOG=$SHOWLOG&NUM=$NUM&LOG=$LOG" 2>/dev/null
|
||||||
if [ "$SHOWLOG" -a "$SECONDARY" != "$AS_SECONDARY" ]; then
|
|
||||||
curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&SHOWLOG=$SHOWLOG&NUM=$NUM&LOG=$LOG" 2>/dev/null
|
|
||||||
else
|
else
|
||||||
|
|
||||||
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
||||||
@ -75,8 +79,25 @@ for i in `seq 0 ${#AUTOPORT_ARCH[*]}`; do
|
|||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$SHOWLOG" ]; then
|
if [ "$SHOWLOG" = "monitor" ]; then
|
||||||
if [ "$SECONDARY" = "$AS_SECONDARY" -a "$NUM" = "$i" ]; then
|
echo "<h2>Build hosts monitor</h2>"
|
||||||
|
icecream-monitor localhost listcs | \
|
||||||
|
while read line; do
|
||||||
|
[ "${line:0:8}" = "200 done" ] && printon=
|
||||||
|
if [ "$printon" ]; then
|
||||||
|
set -- $line
|
||||||
|
case $2 in
|
||||||
|
\(*) echo "<b>$line</b><br>" ;;
|
||||||
|
*) echo "$line<br>" ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
[ "${line:0:6}" = "listcs" ] && printon=1
|
||||||
|
done
|
||||||
|
echo "<br>"
|
||||||
|
RELOADTIME=5000
|
||||||
|
break
|
||||||
|
elif [ "$SHOWLOG" ]; then
|
||||||
|
if [ "$HOST" = "$AS_HOST" -a "$NUM" = "$i" ]; then
|
||||||
echo "<h2>$SHOWLOG log in ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}):</h2>"
|
echo "<h2>$SHOWLOG log in ${AUTOPORT_REPOSITORIES[$i]}(${AUTOPORT_ARCH[$i]}):</h2>"
|
||||||
cat << _EOF
|
cat << _EOF
|
||||||
<div class=downloadbox align=center>
|
<div class=downloadbox align=center>
|
||||||
@ -102,8 +123,8 @@ _EOF
|
|||||||
echo "<table><tr><td colspan=3>Last ${SHOWLOGPKG} logs:</td>"
|
echo "<table><tr><td colspan=3>Last ${SHOWLOGPKG} logs:</td>"
|
||||||
for t in prepare update build install send; do
|
for t in prepare update build install send; do
|
||||||
echo -n "<tr><td>$t:</td><td>"
|
echo -n "<tr><td>$t:</td><td>"
|
||||||
[ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$SECONDARY_ADD&SHOWLOG=${t}/ok/${SHOWLOGPKG}\">OK</a></td>" || echo "<td></td>"
|
[ -e ${BUILDLOGDIR}${t}/ok/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$HOST_ADD&SHOWLOG=${t}/ok/${SHOWLOGPKG}\">OK</a></td>" || echo "<td></td>"
|
||||||
[ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$SECONDARY_ADD&SHOWLOG=${t}/failed/${SHOWLOGPKG}\">FAILED</a></td>" || echo "<td></td>"
|
[ -e ${BUILDLOGDIR}${t}/failed/${SHOWLOGPKG} ] && echo -n "<td><a href=\"?NUM=$i$HOST_ADD&SHOWLOG=${t}/failed/${SHOWLOGPKG}\">FAILED</a></td>" || echo "<td></td>"
|
||||||
echo "</tr>"
|
echo "</tr>"
|
||||||
done
|
done
|
||||||
echo "</table>"
|
echo "</table>"
|
||||||
@ -115,25 +136,25 @@ _EOF
|
|||||||
elif [ ! "$SHOWLOG" ]; then
|
elif [ ! "$SHOWLOG" ]; then
|
||||||
RELOADTIME=60000
|
RELOADTIME=60000
|
||||||
[[ "$NUM" && "$NUM" != "$i" ]] && continue
|
[[ "$NUM" && "$NUM" != "$i" ]] && continue
|
||||||
[[ "$SECONDARY" = "$AS_SECONDARY" ]] || continue
|
[[ "$HOST" = "$AS_HOST" ]] || continue
|
||||||
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
if [ "${AUTOPORT_UPDATE[$i]}" ]; then
|
||||||
echo "<b>* <a href=\"?NUM=$i&SECONDARY=$AS_SECONDARY\">${AUTOPORT_REPOSITORIES[$i]}</a>(${AUTOPORT_ARCH[$i]}) (type:autodist update)"
|
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">${AUTOPORT_REPOSITORIES[$i]}</a>(${AUTOPORT_ARCH[$i]}) (type:autodist update)"
|
||||||
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$SECONDARY_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
|
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
if [ "${AUTOPORT_CHROOT[$i]}" ]; then
|
||||||
echo "<b>* <a href=\"?NUM=$i&SECONDARY=$AS_SECONDARY\">${AUTOPORT_REPOSITORIES[$i]}</a>(${AUTOPORT_ARCH[$i]}) (type:chroot autoport</a> chroot:${AUTOPORT_CHROOT[$i]})"
|
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">${AUTOPORT_REPOSITORIES[$i]}</a>(${AUTOPORT_ARCH[$i]}) (type:chroot autoport</a> chroot:${AUTOPORT_CHROOT[$i]})"
|
||||||
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$SECONDARY_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
|
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
if [ "${AUTOPORT_NATIVE[$i]}" ]; then
|
||||||
echo "<b>* <a href=\"?NUM=$i&SECONDARY=$AS_SECONDARY\">${AUTOPORT_REPOSITORIES[$i]}</a>(${AUTOPORT_ARCH[$i]}) (type:native autoport)"
|
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">${AUTOPORT_REPOSITORIES[$i]}</a>(${AUTOPORT_ARCH[$i]}) (type:native autoport)"
|
||||||
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$SECONDARY_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
|
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">log</a> <a href=\"?SHOWLOG=last&NUM=$i$HOST_ADD\">last</a> ]</b>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${AUTOPORT_CROSS[$i]}" ]; then
|
if [ "${AUTOPORT_CROSS[$i]}" ]; then
|
||||||
echo "<b>* <a href=\"?NUM=$i&SECONDARY=$AS_SECONDARY\">cross-platform</a> autoport (arch:${AUTOPORT_CROSS[$i]})</b>"
|
echo "<b>* <a href=\"?NUM=$i&HOST=$AS_HOST\">cross-platform</a> autoport (arch:${AUTOPORT_CROSS[$i]})</b>"
|
||||||
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$SECONDARY_ADD\">last</a> ]</b>"
|
echo " [ <a href=\"?SHOWLOG=current&NUM=$i$HOST_ADD\">last</a> ]</b>"
|
||||||
fi
|
fi
|
||||||
cat << _EOF
|
cat << _EOF
|
||||||
<div class=downloadbox align=center>
|
<div class=downloadbox align=center>
|
||||||
@ -220,7 +241,7 @@ _EOF
|
|||||||
for b in `seq 1 ${#BUILDNOW[*]}`; do
|
for b in `seq 1 ${#BUILDNOW[*]}`; do
|
||||||
set -- ${BUILDNOW[$b]}
|
set -- ${BUILDNOW[$b]}
|
||||||
if [ "${BUILDLOG[$b]}" ]; then
|
if [ "${BUILDLOG[$b]}" ]; then
|
||||||
echo "<b><a href=\"?SHOWLOG=${BUILDLOG[$b]}&NUM=$i$SECONDARY_ADD\">$1</a>:</b> $2 $3 $4 $5 $6 "
|
echo "<b><a href=\"?SHOWLOG=${BUILDLOG[$b]}&NUM=$i$HOST_ADD\">$1</a>:</b> $2 $3 $4 $5 $6 "
|
||||||
elif [ "$1" ]; then
|
elif [ "$1" ]; then
|
||||||
echo "<b>$1:</b> $2 $3 $4 $5 $6 "
|
echo "<b>$1:</b> $2 $3 $4 $5 $6 "
|
||||||
fi
|
fi
|
||||||
@ -236,18 +257,23 @@ _EOF
|
|||||||
echo "</pre></div></div>"
|
echo "</pre></div></div>"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ "$AUTOPORT_CGI_SECONDARY" -a ! "$SHOWLOG" ]; then
|
|
||||||
if [ "$NUM" -a "$SECONDARY" ]; then
|
# only root host (0) calls other hosts
|
||||||
curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES&NUM=$NUM&SECONDARY=$SECONDARY" 2>/dev/null
|
if [ "$AS_HOST" = "0" -a ! "$SHOWLOG" ]; then
|
||||||
elif [ ! "$NUM" ]; then
|
for h in `seq 1 ${#AUTOPORT_CGI_HOST[*]}`; do
|
||||||
curl "$AUTOPORT_CGI_SECONDARY?AS_SECONDARY=1&LINES=$LINES" 2>/dev/null
|
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 "<p><i>Generated by autodist CGI interface. Last update: `date`</i>"
|
||||||
|
if [ "$FORMAT" = "xml" ]; then
|
||||||
|
echo -n "]]></output>"
|
||||||
|
[ "$RELOADTIME" ] && echo -n "<reloadtime>$RELOADTIME</reloadtime>"
|
||||||
|
echo "</autodist>"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
[ ! "$AS_SECONDARY" ] && echo "<p><i>Generated by autodist CGI interface. Last update: `date`</i>"
|
|
||||||
|
|
||||||
if [ ! "$AS_SECONDARY" -a "$FORMAT" = "xml" ]; then
|
|
||||||
echo -n "]]></output>"
|
|
||||||
[ "$RELOADTIME" ] && echo -n "<reloadtime>$RELOADTIME</reloadtime>"
|
|
||||||
echo "</autodist>"
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user