Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Terje Tjervaag - Bouvet 2011
- #
- # This script takes an Escenic development server online or
- # offline. Going offline, the script copies the staging database
- # and multimedia files locally for offline access.
- # Going back online, the script reconnects to the staging database
- # and remounts the multimedia share.
- #
- # To use this script, the following must be set up:
- #
- # Make two copies of /opt/escenic/engine/localconfig/Database.properties:
- #
- # /opt/escenic/engine/localconfig/Database.properties.local
- # /opt/escenic/engine/localconfig/Database.properties.staging
- #
- # Delete the original and modify these files to point to the local and
- # staging environments respectively.
- #
- # Similarily, make two copies of /opt/tomcat/conf/server.xml:
- #
- # /opt/tomcat/conf/server.xml.local
- # /opt/tomcat/conf/server.xml.staging
- #
- # Delete the original and modify these files to point to the local and
- # staging environments respectively.
- #
- # Create the folders
- #
- # /opt/escenic/publications_local
- # /opt/escenic/publications_share
- #
- # Finally, the mount point /opt/escenic/publications_share must point to the
- # staging multimedia share.
- # /opt/escenic/publications will be created as a symlink to one of these two.
- # Configure these
- PUBLICATION_NAME=publication_name
- STAGING_SERVER=server.local
- STAGING_USER=username
- STAGING_DB_NAME=database_name
- STAGING_DB_USER=username
- STAGING_DB_PASS=password
- LOCAL_DB_NAME=database_name
- LOCAL_DB_USER=username
- LOCAL_DB_PASS=password
- ECE_STOP_CMD=~/ece_stop.sh
- ECE_START_CMD=~/ece_start.sh
- E_BADARGS=65
- if [ ! -n "$1" ]
- then
- echo "Usage: `basename $0` [offline|online]"
- echo " offline: copies the database from staging to the development environment"
- echo " online: resets the environment to use the staging DB"
- exit $E_BADARGS
- fi
- if [ "$1" == "offline" ]
- then
- echo "Going offline..."
- echo "Copying DB from staging"
- mysqldump -h $STAGING_SERVER --user=$STAGING_DB_USER --password=$STAGING_DB_PASS $STAGING_DB_NAME | mysql -u $LOCAL_DB_USER -p$LOCAL_DB_PASS --database $LOCAL_DB_NAME
- echo "Reconfiguring Escenic database connection"
- rm /opt/tomcat/conf/server.xml
- ln -s /opt/tomcat/conf/server.xml.local /opt/tomcat/conf/server.xml
- rm /opt/escenic/engine/localconfig/Database.properties
- ln -s /opt/escenic/engine/localconfig/Database.properties.local /opt/escenic/engine/localconfig/Database.properties
- echo "Copying multimedia files to local computer"
- scp -r $STAGING_USER@$STAGING_SERVER:/var/publications/$PUBLICATION_NAME/* /opt/escenic/publications_local/$PUBLICATION_NAME
- rm /opt/escenic/publications
- ln -s /opt/escenic/publications_local /opt/escenic/publications
- echo "Restarting Escenic"
- $ECE_STOP_CMD
- $ECE_START_CMD
- fi
- if [ "$1" == "online" ]
- then
- echo "Going online..."
- echo "Reconfiguring Escenic database connection"
- rm /opt/tomcat/conf/server.xml
- ln -s /opt/tomcat/conf/server.xml.staging /opt/tomcat/conf/server.xml
- rm /opt/escenic/engine/localconfig/Database.properties
- ln -s /opt/escenic/engine/localconfig/Database.properties.local /opt/escenic/engine/localconfig/Database.properties
- echo "Reattaching Escenic to staging multimedia share"
- rm /opt/escenic/publications
- ln -s /opt/escenic/publications_share /opt/escenic/publications
- echo "Restarting Escenic"
- $ECE_STOP_CMD
- $ECE_START_CMD
- fi
Add Comment
Please, Sign In to add comment