#!/bin/bash
+. /home/live/.bashrc
+
export TARGET_USER=esi
export TARGET_HOST=192.168.25.129
export TARGET_PATH=/home/esi/
export LOCAL_QA_GIT_PATH=/home/live/git/random/
export LOCAL_QA_BRANCH=collab/phasefx/wheezy_installer
export LOCAL_HTML_PATH=/home/live/public_html/
-cd ${LOCAL_QA_GIT_PATH} || exit -1
-git checkout ${LOCAL_QA_BRANCH} || exit -1
+
+echo -n "*** Changing to $LOCAL_QA_GIT_PATH ... "
+cd $LOCAL_QA_GIT_PATH || exit -1
+echo "location changed"
+
+echo "*** Checking out $LOCAL_QA_BRANCH ..."
+git checkout $LOCAL_QA_BRANCH || exit -1
git fetch --all || exit -1
git pull || exit -1
-scp installer/wheezy/installer_installer.sh ${TARGET_USER}@${TARGET_HOST}:${TARGET_PATH} || exit -1
-cd ${LOCAL_HTML_PATH} || exit -1
+echo "*** Local branch updated"
+
+echo "*** Pushing installer script to $TARGET_USER@$TARGET_HOST:$TARGET_PATH"
+scp installer/wheezy/installer_installer.sh $TARGET_USER@$TARGET_HOST:$TARGET_PATH || exit -1
+echo "*** Script pushed"
+
+echo "*** Archiving previous test run"
+cd $LOCAL_HTML_PATH || exit -1
export ARCHIVE_DIR=`date +%F_%T` || exit -1
-mkdir -p archive/${ARCHIVE_DIR} || exit -1
-mv *.* archive/${ARCHIVE_DIR} || exit -1
-cp archive/${ARCHIVE_DIR}/*.hash . || exit -1
-cp ${LOCAL_QA_GIT_PATH}qa/test_output.css .
-echo '<html><head></head><body><h1>Testing in progress</h1><a href="archive/">previous runs</a></body></html>' > test.html
+mkdir -p archive/$ARCHIVE_DIR || exit -1
+mv *.* archive/$ARCHIVE_DIR || exit -1
+cp archive/$ARCHIVE_DIR/*.hash . || exit -1
+echo "*** Test archived"
+
+echo "*** Setting up new output"
+cp $LOCAL_QA_GIT_PATH/qa/test_output.css .
+echo '<html><head></head><body><h1>Testing in progress</h1><a href="archive/">Previous runs...</a></body></html>' > test.html
ln -s test.html index.html
-ssh ${TARGET_USER}@${TARGET_HOST} ${TARGET_PATH}installer_installer.sh 2>&1 | tee output.txt
-${LOCAL_QA_GIT_PATH}qa/test_output_webifier.pl output.txt
+echo "*** Ready to test!"
+
+echo -n "*** Test starting ... "
+ssh $TARGET_USER@$TARGET_HOST $TARGET_PATH/installer_installer.sh 2>&1 > output.txt
+echo "test run complete."
+
+echo "*** Creating web output"
+$LOCAL_QA_GIT_PATH/qa/test_output_webifier.pl output.txt
+