#!/bin/bash
#
# Script to automate CI deployments. Simply stop all
# servers, change the "current" symlinks to the given
# target folder and finally, start all servers
#
play_home="/home/play"
webapps_folder="${play_home}/webapps"
export JAVA_HOME="/usr/lib/jvm/default-java"
apps=( "bar" "api" "foo" )
for app in ${apps[@]}; do
echo "Stopping server ${app}"
${play_home}/bin/${app} stop
echo "Regenerate current symlink of ${app}"
rm ${webapps_folder}/${app}/current
ln -s ${webapps_folder}/${app}/${1} ${webapps_folder}/${app}/current
echo "Starting server ${app}"
${play_home}/bin/${app} nohup
done
exit 0