#!/bin/sh
HOST=
USER=
PASSWD=
# Script to generate a webpage with the output of the 'farm project' command
# This can be executed via cron because it needs no user input at runtime
export PATH=${PATH}:/usr/local/bin;
SCRATCH_FILE1=`mktemp /tmp/.ss.XXXXXXXXXX`
SCRATCH_FILE2=`mktemp /tmp/.ss.XXXXXXXXXX`
SCRATCH_FILE3=`mktemp /tmp/.ss.XXXXXXXXXX`
SCRATCH_FILE4=`mktemp /tmp/.ss.XXXXXXXXXX`
COVER_FILE=series_status.html
HELPER_FILE=ss_helper.html
LPANE_FILE=ss_lpane.html
SERIES_FILE=ss_series.html
STATIC_FILE=ss_static.html
LOCK_PNG=spotlightred.png
OPEN_PNG=spotlightgreen.png
PAGE_PNG=quandary_ena.png
# leave this dir clean
trap "/bin/rm -f ${SCRATCH_FILE1} ${SCRATCH_FILE2} ${SCRATCH_FILE3} ${SCRATCH_FILE4} \
${COVER_FILE} ${HELPER_FILE} ${LPANE_FILE} ${SERIES_FILE} ${STATIC_FILE} ss_TESTPATTERN_*.html >/dev/null 2>&1" 0
trap "exit 2" 1 2 3 15
rm -f ${COVER_FILE} ${HELPER_FILE}
# generate the cover page that defines the two panes
cat > ${COVER_FILE} << +++
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="en-US">
<head>
<title>Series Status</title>
<link rel="icon" type="image/png" href="${PAGE_PNG}"/>
<link rel="shortcut icon" type="image/png" href="${PAGE_PNG}"/>
</head>
<font face = "Verdana">
<frameset cols = "25%, 75%">
<frame src = "${LPANE_FILE}"/>
<frame src = "${HELPER_FILE}" name = "showframe"/>
</frameset>
</font>
</html>
+++
# generate the page that defines the two panes within the left pane of the cover page
cat > ${LPANE_FILE} << +++
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html lang="en-US">
<font face = "Verdana">
<frameset rows = "75%, 25%">
<frame src = "${SERIES_FILE}"/>
<frame src = "${STATIC_FILE}" noresize="noresize"/>
</frameset>
</font>
</html>
+++
# generate the helper page that goes on the right pane at the start
cat > ${HELPER_FILE} << +++
<!DOCTYPE HTML>
<html lang="en-US">
<font face = "Verdana">
<h3>Select the desired series from the pane on the left.</h3>
</font>
</html>
+++
# generate the static page that goes on the bottom pane of the cover page's left pane
cat > ${STATIC_FILE} << +++
<!DOCTYPE HTML>
<html lang="en-US">
<font face = "Verdana">
</font>
</html>
+++
# -------------------------------------------------------------------------------
# IMPORTANT: if you remove/rename any of these, remember to update BRSEDFN below
# -------------------------------------------------------------------------------
# Legacy Levels
PRE_V1_LABEL="Pre-V1"
PRE_V1="TESTPATTERN_B18_LINUX.X64:st_testapps_b18"
# V1 and its RUPs
V1_RUPS_LABEL="V1 and its RUPs"
V1_RUPS="TESTPATTERN_11.1.1.5.1_LINUX.X64:st_testapps_11.1.1.5.1
TESTPATTERN_PT.DEVPRJNXT_LINUX.X64:st_testapps_pt-devprjnxt"
# generate the page that goes on the left pane
rm -f ${SERIES_FILE}
cat > ${SERIES_FILE} << +++
<!DOCTYPE HTML>
<html lang="en-US">
<body>
<font face = "Verdana">
+++
# Pre-V1
echo "<h3>${PRE_V1_LABEL}</h3><h5>" >> ${SERIES_FILE}
for i in ${PRE_V1}
do
SERIES=`echo ${i} | sed 's/:..*//'`
echo "<a href = \"ss_${SERIES}.html\" target = \"showframe\"/>"${SERIES}"</a><br/>" >> ${SERIES_FILE}
done
# V1 and its RUPs
echo "</h5><h3>${V1_RUPS_LABEL}</h3><h5>" >> ${SERIES_FILE}
for i in ${V1_RUPS}
do
SERIES=`echo ${i} | sed 's/:..*//'`
echo "<a href = \"ss_${SERIES}.html\" target = \"showframe\"/>"${SERIES}"</a><br/>" >> ${SERIES_FILE}
done
# ARU-enabled
echo "</h5><h3>${ARU_LABEL}</h3><h5>" >> ${SERIES_FILE}
for i in ${ARU}
do
SERIES=`echo ${i} | sed 's/:..*//'`
echo "<a href = \"ss_${SERIES}.html\" target = \"showframe\"/>"${SERIES}"</a><br/>" >> ${SERIES_FILE}
done
# Long running branches
echo "</h5><h3>${V2_PLUS_LABEL}</h3><h5>" >> ${SERIES_FILE}
for i in ${V2_PLUS}
do
SERIES=`echo ${i} | sed 's/:..*//'`
echo "<a href = \"ss_${SERIES}.html\" target = \"showframe\"/>"${SERIES}"</a><br/>" >> ${SERIES_FILE}
done
echo "</h5>" >> ${SERIES_FILE}
cat >> ${SERIES_FILE} << +++
</font>
</body>
</html>
+++
# add 'em up
BRSEDFN="${PRE_V1} ${V1_RUPS} ${ARU} ${V2_PLUS}"
getstatus() {
branch="$1"
series="$2"
out=`/usr/local/bin/ade describe -b ${branch} -prod fusionapps | grep "Frozen on[ ][ ]*:"`
[ -z "${out}" ] && {
# open branch
status="<font color=\"green\"><strong>Open</strong></font>"
cat ${SERIES_FILE} | sed "/${series}/s/^/<img src=\"${OPEN_PNG}\" height=\"12\" width=\"12\"\/>\ \;\ \;/" > ${SCRATCH_FILE1}
} || {
# frozen branch
# by=`echo "${out}" | grep 'Frozen by' | sed 's/..*: //'`
on=`echo "${out}" | sed 's/on\s*: /on /'`
# status="<font color=\"red\"><strong>Frozen by ${by} on ${on}</strong></font>"
status='<font color="red"><strong>'`echo ${on}`'</strong></font>'
cat ${SERIES_FILE} | sed "/${series}/s/^/<img src=\"${LOCK_PNG}\" height=\"12\" width=\"12\"\/>\ \;\ \;/" > ${SCRATCH_FILE1}
}
mv ${SCRATCH_FILE1} ${SERIES_FILE}
}
# get the lrg history jsp file for size comparison later
/usr/bin/wget -O ${SCRATCH_FILE3} --force-html http://cruisecontrol.oraclecorp.com/fusionapps/lrgHistory.jsp > /dev/null 2>&1
# generate the pages that goes on the right pane of the cover page upon a click
for i in ${BRSEDFN}
do
SERIES=`echo ${i} | sed 's/:..*//'`
BRANCH=`echo ${i} | sed 's/..*://'`
OUT="ss_${SERIES}.html"
getstatus ${BRANCH} ${SERIES}
# start it off
cat > ${OUT} << +++
<!DOCTYPE HTML>
<html lang="en-US">
<body>
<font face = "Verdana">
<h2>${SERIES}: ${status}</h2>
<h5>(Branch name: ${BRANCH})</h5>
<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/ade describe -b ${BRANCH} -prod TESTPATTERN</span>)</font><br/>
<br/>
+++
echo '<h5>' >> ${OUT}
# Cruisecontrol report
echo '<a href="http://oracruise.oraclecorp.com/fusionapps/buildresults/'${SERIES}'" target="blank">CruiseControl report</a><br/>' >> ${OUT}
# Browse code
echo '<a href="http://xarch.us.oracle.com/cgi-bin/secure/source?top=/ade_autofs/ade_fusion_linux&path=/'${SERIES}'/LATEST" target="blank">Browse source code</a><br/>' >> ${OUT}
# LRG history
/usr/bin/wget -O ${SCRATCH_FILE4} --force-html http://cruisecontrol.oraclecorp.com/fusionapps/lrgHistory.jsp\?series=${SERIES} > /dev/null 2>&1
cmp -s ${SCRATCH_FILE3} ${SCRATCH_FILE4} # compare downloaded file's size with the jsp file's size
[ $? -eq 1 ] && { # if they're not the same, hyperlink it, else skip the entry altogether
echo '<a href="http://cruisecontrol.oraclecorp.com/fusionapps/lrgHistory.jsp?series='${SERIES}'" target="blank">LRG history</a>' >> ${OUT}
}
echo '</h5>' >> ${OUT}
# Branch locks
/usr/local/bin/ade exec /usr/local/nde/ade/util/get_branch_locks.pl -branch ${BRANCH} -prod TESTPATTERN 2>/dev/null |\
sed -e '/^$/d' > ${SCRATCH_FILE1}
[ `cat ${SCRATCH_FILE1} | wc -l` -eq 1 ] && {
echo '<br/><h3>Locks: None</h3>' >> ${OUT}
echo '<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/ade exec /usr/local/nde/ade/util/get_branch_locks.pl -branch '${BRANCH}' -prod TESTPATTERN</span>)</font><br/>' >> ${OUT}
} || {
echo '<br/><h3>Locks:</h3>' >> ${OUT}
echo '<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/ade exec /usr/local/nde/ade/util/get_branch_locks.pl -branch '${BRANCH}' -prod TESTPATTERN</span>)</font><br/><pre>' >> ${OUT}
cat ${SCRATCH_FILE1} >> ${OUT}
echo '</pre>' >> ${OUT}
}
# Merge refreshes
/usr/local/bin/farm project -query -history -ptseries ${SERIES} |\
sed -e '/Farm Command Line/d' \
-e '/Event History/d' \
-e '/^$/d' > ${SCRATCH_FILE1}
[ `cat ${SCRATCH_FILE1} | wc -l` -eq 4 ] && {
echo '<br/><h3>Merge/Refresh History: None</h3>' >> ${OUT}
echo '<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/farm project -query -history -ptseries '${SERIES}'</span>)</font><br/>' >> ${OUT}
} || {
echo '<br/><h3>Merge/Refresh History:</h3>' >> ${OUT}
echo '<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/farm project -query -history -ptseries '${SERIES}'</span>)</font><br/><pre>' >> ${OUT}
cat ${SCRATCH_FILE1} >> ${OUT}
echo '</pre>' >> ${OUT}
}
# labels
/usr/local/bin/ade showlabels -series ${SERIES} > ${SCRATCH_FILE2}
cat ${SCRATCH_FILE2} |\
sed -e '/\.S$/ {
s/^/\<span style="color: darkgray;">/
s/$/<\/span>/
}' > ${SCRATCH_FILE1}
[ `cat ${SCRATCH_FILE1} | wc -l` -gt 0 ] && {
echo '<br/><h3>Recent labels:</h3>' >> ${OUT}
echo '<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/ade showlabels -series '${SERIES}'</span>)</font><br/><pre>' >> ${OUT}
cat ${SCRATCH_FILE1} >> ${OUT}
echo '</pre>' >> ${OUT}
}
# depprods
LATEST_LABEL=`tail -1 ${SCRATCH_FILE2}`
[ X"${LATEST_LABEL}"X != XX ] && {
echo '<br/><h3>Dependencies for latest label:</h3>' >> ${OUT}
echo '<font size="-2">(Cmd: <span style="background-color: yellow;">/usr/local/bin/ade showdepprods -inlabel '${LATEST_LABEL}' -short</span>)</font><br/><pre>' >> ${OUT}
/usr/local/bin/ade showdepprods -inlabel ${LATEST_LABEL} -short | \
egrep -v "BACKEND|${LATEST_LABEL}" | \
while read TAGLINE
do
PATH=
ARRAY=(`echo "${TAGLINE}"`)
PATH=`echo ${ARRAY[2]} | /bin/sed -e "s/_/\//g" -e "s/^/http:\/\/dstintg.us.oracle.com\/products\//" -e 's/$/\/tindex.html/'`
/usr/bin/wget --spider -F ${PATH} > /dev/null 2>&1
[ $? -eq 0 ] && {
echo "${ARRAY[0]}: <a href=\"${PATH}\" target=\"blank\">${ARRAY[2]}</a>"
} || {
echo "${ARRAY[0]}: ${ARRAY[2]}"
}
done >> ${OUT}
echo '</pre>' >> ${OUT}
}
# datestamp the generated file
echo '<hr><font size="-2">Data gathered: '`date +"%c %Z"`'</font>' >> ${OUT}
# close it out
echo '</font></body></html>' >> ${OUT}
done
# publish the generated file to your webserver (assumes netrc is configured correctly)
ftp -nv <<-!x
open $HOST
user $USER $PASSWORD
cd P4/Series_Status/public_html
prompt
mput ${COVER_FILE} ${HELPER_FILE} ${LPANE_FILE} ${SERIES_FILE} ${STATIC_FILE}
mput ${OPEN_PNG} ${LOCK_PNG} ${PAGE_PNG}
mput ss_TESTPATTERN_*.html
bye
!x
exit 0

