diff --git a/updateTest.bash b/updateTest.bash index 84b41914..7b3304f0 100755 --- a/updateTest.bash +++ b/updateTest.bash @@ -1,17 +1,55 @@ #!/bin/bash export DISPLAY=:1 - +[ ! -z "$DEBUG" ] && set -x +IP="192.168.95.239" HL="/home/lanforge" HLD="${HL}/Documents" scripts="${HLD}/lanforge-scripts" +verNum="5.4.3" GUILog="/home/lanforge/Documents/GUILog.txt" GUIUpdate="/home/lanforge/Documents/GUIUpdateLog.txt" CTLGUI="/home/lanforge/Documents/connectTestGUILog.txt" CTLH="/home/lanforge/Documents/connectTestHLog.txt" -verNum="5.4.3" GUIDIR="${HL}/LANforgeGUI_${verNum}" ST="/tmp/summary.txt" -IP="192.168.95.239" +DM_FLAG="${HL}/LANforgeGUI_${verNum}/DAEMON_MODE" +output=/tmp/gui_update_test + +function start_gui() { + daemon_mode="" + [ -f $GUIDIR/DAEMON_MODE ] && daemon_mode="-daemon" + ( cd $GUIDIR; nohup env RESTARTS=999999 ./lfclient.bash $daemon_mode -s localhost &> $GUILog & ) + connect_fail=0 + wait_8080 || connect_fail=1 + + if [[ $connect_fail = 1 ]]; then + echo "" > $output + [ -s $GUIUpdate ] && cat $GUIUpdate >> $output + cat $GUILog >> $output + mail -s 'GUI connect failure' "test.notice@candelatech.com" < $output + exit 1 + fi +} + +function wait_8080() { + set +x + local connected=0 + local limit_sec=30 + echo "Testing for 8080 connection " + while (( connected == 0 )); do + (( limit_sec <= 0)) && break + curl -so /dev/null http://localhost:8080/ && connected=1 + (( connected >= 1 )) && break; + limit_sec=$(( limit_sec - 1 )) + echo -n "." + sleep 1 + done + if [[ $connected = 0 ]]; then + echo "Unable to connect, bye" + return 1 + fi + [ ! -z "$DEBUG" ] && set -x +} if [ -f ${GUIDIR}/down-check ]; then numFound=`find ${GUIDIR} -name down-check -mmin +59 | grep -c down-check` @@ -35,44 +73,66 @@ if [ -f ${GUIDIR}/down-check ]; then fi fi -rm -f /tmp/*.txt -rm -f $GUILog $GUIUpdate $CTLGUI $CTLH $ST +sudo rm -f /tmp/*.txt +sudo rm -f $GUILog $GUIUpdate $CTLGUI $CTLH $ST touch "${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART" pgrep java &>/dev/null && killall -9 java -python3 ${scripts}/auto-install-gui.py --versionNumber $verNum &> $GUIUpdate +touch $GUIUpdate +if [ ! -z "SKIP_INSTALL" ] && [ x$SKIP_INSTALL = x1 ]; then + echo "skipping installation" + sleep 4 +else + echo "doing installation" + sleep 4 + python3 ${scripts}/auto-install-gui.py --versionNumber $verNum &> $GUIUpdate + [ -s $GUIUpdate ] && grep -q "Current GUI version up to date" $GUIUpdate && exit + echo "===============================================" > $ST + head $GUILog >> $ST + echo "===============================================" >> $ST + [ -s $GUIUpdate ] && head $GUIUpdate >> $ST + if grep -q -i "fail" $GUIUpdate; then + cat $ST | mail -s 'GUI Update Test Failure' -a $GUILog -a $GUIUpdate "test.notice@candelatech.com" + exit 1 + fi +fi sleep 1 rm -f "${HL}/LANforgeGUI_${verNum}/NO_AUTOSTART" -( cd $GUIDIR; nohup env RESTARTS=999999 ./lfclient.bash -s localhost &> $GUILog & ) -sleep 10 -grep -q "Current GUI version up to date" $GUIUpdate && exit -echo "===============================================" > $ST -head $GUILog >> $ST -echo "===============================================" >> $ST -head $GUIUpdate >> $ST -if grep -q -i "fail" $GUIUpdate; then - cat $ST | mail -s 'GUI Update Test Failure' -a $GUILog -a $GUIUpdate "test.notice@candelatech.com" -fi -#pgrep java &>/dev/null && killall -9 java -#( cd $GUIDIR; nohup env RESTARTS=999999 ./lfclient.bash -s localhost &> $GUILog & ) +start_gui python3 ${scripts}/connectTest.py &> $CTLGUI +pgrep java &>/dev/null && killall -9 java +sleep 1 +#-daemon touch "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE" - -pgrep java &>/dev/null && killall -9 java -sleep 10 - +start_gui python3 ${scripts}/connectTest.py &> $CTLH -rm "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE" -pgrep java &>/dev/null && killall -9 java - echo "===============================================" >> $ST head $CTLGUI >> $ST echo "===============================================" >> $ST head $CTLH >> $ST echo "===============================================" >> $ST +rm -f "${HL}/LANforgeGUI_${verNum}/DAEMON_MODE" +pgrep java &>/dev/null && killall -9 java +start_gui +connect_fail=0 +wait_8080 || connect_fail=1 -cat $ST | mail -s 'GUI Update Test' -a $GUILog -a $GUIUpdate -a $CTLGUI -a $CTLH "test.notice@candelatech.com" +cat $ST > $output +echo "===============================================" >> $output +[ -s $GUILog ] && cat $GUILog >> $output +echo "===============================================" >> $output +[ -s $GUIUpdate ] && cat $GUIUpdate >> $output +echo "===============================================" >> $output +[ -s $CTLGUI ] && cat $CTLGUI >> $output +echo "===============================================" >> $output +[ -s $CTLH ] && cat $CTLH >> $output +echo "===============================================" >> $output +echo -e "--\n.\n" >> $output +mail -s 'GUI Update Test' "test.notice@candelatech.com" < $output + +#cat $ST | mail -s 'GUI Update Test' -a $GUILog -a $GUIUpdate -a $CTLGUI -a $CTLH "test.notice@candelatech.com" +#eof