# script run on main server to shutdown all servers and update them
# to the latest binary server code.  Does NOT update game data for the servers.


# shuts down each server and rebuilds them, one by one, allowing
# players to continue playing on the other servers in the mean time





echo "" 
echo "Re-compiling non-running local server code base as a sanity check"
echo ""

cd ~/checkout/minorGems
~/checkout/OneLifeWorking/scripts/gitPullComplete.sh

cd ~/checkout/OneLife/server
~/checkout/OneLifeWorking/scripts/gitPullComplete.sh

./configure 1
make


echo "About to post and tag server code."
echo ""
echo -n "Hit [ENTER] when ready: "
read



wipeMaps=0

echo ""
echo ""
echo "Auto wipe maps as part of process?"
echo ""
echo "Enter WIPE to wipe, or press [ENTER] to skip."
echo ""
echo -n "Wipe maps: "
read wipeMapsWord

if [ "$wipeMapsWord" = "WIPE" ]
then
	echo
	echo "Auto-wiping maps."
	echo
	wipeMaps=1
else
	echo
	echo "NOT Auto-wiping maps."
	echo
fi





echo "" 
echo "Tagging live server code with OneLife_liveServer"
echo ""

cd ~/checkout/OneLife


git tag -fa AnotherPlanet_liveServer -m "Tag automatically generated by server code update script."


echo "" 
echo "Pushing tag change to central git server"
echo ""

git push
git push origin -f --tags



echo "" 
echo "Tagging live minorGems code with OneLife_liveServer"
echo ""

cd ~/checkout/minorGems


git tag -fa AnotherPlanet_liveServer -m "Tag automatically generated by data-only diffBundle script."


echo "" 
echo "Pushing tag change to central git server"
echo ""

git push
git push origin -f --tags




~/checkout/OneLifeWorking/scripts/updateServerCodeAHAPStep1.sh

~/checkout/OneLifeWorking/scripts/updateServerCodeAHAPStep2.sh $wipeMaps









echo "" 
echo "Done updating code on all AHAP servers."
echo ""
