Guest User

Untitled

a guest
Jan 23rd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Terje Tjervaag - Bouvet 2011
  4. #
  5. # This script takes an Escenic development server online or
  6. # offline. Going offline, the script copies the staging database
  7. # and multimedia files locally for offline access.
  8. # Going back online, the script reconnects to the staging database
  9. # and remounts the multimedia share.
  10. #
  11. # To use this script, the following must be set up:
  12. #
  13. # Make two copies of /opt/escenic/engine/localconfig/Database.properties:
  14. #
  15. # /opt/escenic/engine/localconfig/Database.properties.local
  16. # /opt/escenic/engine/localconfig/Database.properties.staging
  17. #
  18. # Delete the original and modify these files to point to the local and
  19. # staging environments respectively.
  20. #
  21. # Similarily, make two copies of /opt/tomcat/conf/server.xml:
  22. #
  23. # /opt/tomcat/conf/server.xml.local
  24. # /opt/tomcat/conf/server.xml.staging
  25. #
  26. # Delete the original and modify these files to point to the local and
  27. # staging environments respectively.
  28. #
  29. # Create the folders
  30. #
  31. # /opt/escenic/publications_local
  32. # /opt/escenic/publications_share
  33. #
  34. # Finally, the mount point /opt/escenic/publications_share must point to the
  35. # staging multimedia share.
  36. # /opt/escenic/publications will be created as a symlink to one of these two.
  37.  
  38. # Configure these
  39. PUBLICATION_NAME=publication_name
  40.  
  41. STAGING_SERVER=server.local
  42. STAGING_USER=username
  43. STAGING_DB_NAME=database_name
  44. STAGING_DB_USER=username
  45. STAGING_DB_PASS=password
  46.  
  47. LOCAL_DB_NAME=database_name
  48. LOCAL_DB_USER=username
  49. LOCAL_DB_PASS=password
  50.  
  51. ECE_STOP_CMD=~/ece_stop.sh
  52. ECE_START_CMD=~/ece_start.sh
  53.  
  54. E_BADARGS=65
  55.  
  56. if [ ! -n "$1" ]
  57. then
  58. echo "Usage: `basename $0` [offline|online]"
  59. echo " offline: copies the database from staging to the development environment"
  60. echo " online: resets the environment to use the staging DB"
  61. exit $E_BADARGS
  62. fi
  63.  
  64. if [ "$1" == "offline" ]
  65. then
  66. echo "Going offline..."
  67. echo "Copying DB from staging"
  68. 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
  69. echo "Reconfiguring Escenic database connection"
  70. rm /opt/tomcat/conf/server.xml
  71. ln -s /opt/tomcat/conf/server.xml.local /opt/tomcat/conf/server.xml
  72. rm /opt/escenic/engine/localconfig/Database.properties
  73. ln -s /opt/escenic/engine/localconfig/Database.properties.local /opt/escenic/engine/localconfig/Database.properties
  74.  
  75. echo "Copying multimedia files to local computer"
  76. scp -r $STAGING_USER@$STAGING_SERVER:/var/publications/$PUBLICATION_NAME/* /opt/escenic/publications_local/$PUBLICATION_NAME
  77. rm /opt/escenic/publications
  78. ln -s /opt/escenic/publications_local /opt/escenic/publications
  79.  
  80. echo "Restarting Escenic"
  81. $ECE_STOP_CMD
  82. $ECE_START_CMD
  83. fi
  84.  
  85. if [ "$1" == "online" ]
  86. then
  87. echo "Going online..."
  88. echo "Reconfiguring Escenic database connection"
  89. rm /opt/tomcat/conf/server.xml
  90. ln -s /opt/tomcat/conf/server.xml.staging /opt/tomcat/conf/server.xml
  91. rm /opt/escenic/engine/localconfig/Database.properties
  92. ln -s /opt/escenic/engine/localconfig/Database.properties.local /opt/escenic/engine/localconfig/Database.properties
  93.  
  94. echo "Reattaching Escenic to staging multimedia share"
  95. rm /opt/escenic/publications
  96. ln -s /opt/escenic/publications_share /opt/escenic/publications
  97.  
  98. echo "Restarting Escenic"
  99. $ECE_STOP_CMD
  100. $ECE_START_CMD
  101. fi
Add Comment
Please, Sign In to add comment