Server Promote Shell Script

#!/bin/bash
# author
# Script that will update the production Runway servers from an updated svn checkout.
. /etc/profile
export HOME=/var/www
if [ -e /tmp/runway_promote ]
then
echo "Promote process already running. Please check with teammates to coordinate when the promote process may be run again."
exit 1
fi
touch /tmp/runway_promote
echo "Creating SVN tag..." 2>&1 | tee /var/log/runway_sync.log
svn copy -m "Tagging current version $(date '+%Y-%m-%d_%H:%M')" https://utility01/repos/runway/trunk https://utility01/repos/runway/tags/$(date '+%Y-%m-%d_%H:%M') 2>&1 | tee -a /var/log/runway_sync.log
if [ ${PIPESTATUS[0]} -ne 0 ]
then
echo "svn tagging command failed. Please check log files." 2>&1 | tee -a /var/log/runway_sync.log
rm /tmp/runway_promote
exit 1
fi
echo "Updating code base from SVN..." 2>&1 | tee -a /var/log/runway_sync.log
svn update --non-interactive /usr/local/runway 2>&1 | tee -a /var/log/runway_sync.log
if [ ${PIPESTATUS[0]} -ne 0 ]
then
echo "svn update /usr/local/runway command failed. Please check log files." 2>&1 | tee -a /var/log/runway_sync.log
rm /tmp/runway_promote
exit 1
fi
echo "Syncing with first app server..." 2>&1 | tee -a /var/log/runway_sync.log
rsync -avl --delete --exclude *.svn* /usr/local/runway/sites/ root@app01:/var/www/html/ 2>&1 | tee -a /var/log/runway_sync.log
if [ ${PIPESTATUS[0]} -ne 0 ]
then
echo "rsync of app01 failed. Please check log files." 2>&1 | tee -a /var/log/runway_sync.log
rm /tmp/runway_promote
exit 1
fi
echo "Syncing with second app server..." 2>&1 | tee -a /var/log/runway_sync.log
rsync -avl --delete --exclude *.svn* /usr/local/runway/sites/ root@app02:/var/www/html/ 2>&1 | tee -a /var/log/runway_sync.log
if [ ${PIPESTATUS[0]} -ne 0 ]
then
echo "rsync of app02 failed. Please check log files." 2>&1 | tee -a /var/log/runway_sync.log
rm /tmp/runway_promote
exit 1
fi
rm /tmp/runway_promote


Posted on 1 Oct 2009, 12:06 - Category: Shell
Comments - Edit - Delete


Pages: [1]
Loading