Blame | Last modification | View Log | RSS feed
#!/bin/bashif [ $# -ne 1 ]thenecho "Usage: $0 <DEPLOY|ROLLBACK>"exit 1fiACTION=$1if [ $ACTION != "DEPLOY" -a $ACTION != "ROLLBACK" ]thenecho "Wrong input"echo "Usage: $0 <DEPLOY|ROLLBACK>"exit 1fi# Define your function hereReadUserInput () {read userinputwhile [ $userinput != "yes" -a $userinput != "no" ]doecho "Wrong input. Please try again [yes/no] : "read userinputdoneecho $userinput}PROD_SERVERS="prod1 prod2 prod3"for PROD_SERVER in ${PROD_SERVERS}doecho "Deploying on server: ${PROD_SERVER}. R you sure ? [yes/no] \n"response=$(ReadUserInput)echo $responseif [ "$response" = "yes" ]thenecho "Stopping apache on server"ssh ${PROD_SERVER} "/etc/init.d/apache2 stop"echo "Stopped apache on server"echo "Deploying on server"ssh ${PROD_SERVER} "/root/code/trunk/runutils/deploy-everything.sh DEPLOY"echo "Deployed on server."echo "Please test everything on the ${PROD_SERVER} using 8080 port."echo "Is everything fine on ${PROD_SERVER} ? [yes/no]"depstatus=$(ReadUserInput)if [ "$depstatus" = "no" ]thenecho "Want to rollback on ${PROD_SERVER} ? [yes/no]"rollback=$(ReadUserInput)if [ "$rollback" = "yes" ]thenssh ${PROD_SERVER} "/root/code/trunk/runutils/deploy-everything.sh ROLLBACK"echo "You have rolled back to the previous version. Please verify it using 8080 port and start apache manually."elseecho "You have chosen to not to roll back. Please verify it using 8080 port and start apache manually."fielseecho "Starting apache on server"ssh ${PROD_SERVER} "/etc/init.d/apache2 start"echo "Started apache on server"fielseecho "Nothing to deploy"exit 1fidone