Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/bash
- #===========================================================================
- # Deployment Script for EDB Drupal Site
- # Usage: execute this script with elevated privileges
- # - e.g. 'sudo ./[this_script] [branch_to_deploy]'
- #===========================================================================
- REPOSITORY_ROOT="/var/www/repo/enterprise-db"
- DRUPAL_ROOT="/var/www/html"
- DEPLOY_BRANCH="$1"
- # Set default branch if not provided via command argument
- if [ "$DEPLOY_BRANCH" = "" ]; then
- set DEPLOY_BRANCH="production"
- fi
- # Download latest code from specified branch in remote repository
- cd $REPOSITORY_ROOT
- git checkout $DEPLOY_BRANCH
- git pull origin $DEPLOY_BRANCH
- # Enable Maintenance Mode
- cd $DRUPAL_ROOT
- drush vset maintenance_mode 1
- # Sync downloaded repository files over to webroot
- rsync -avh "$REPOSITORY_ROOT/simplesamlphp/" /var/www/simplesamlphp/ --delete
- rsync -avh --exclude '.git' --exclude 'sites/default/files' --exclude 'sites/default/files-private' "$REPOSITORY_ROOT/docroot/" $DRUPAL_ROOT --delete
- # Install environment-specific database settings
- cp -fv /var/www/repo/local.db.inc "$DRUPAL_ROOT/sites/default/local.db.inc"
- # Remove one Simplesaml implementation and symlink to the other
- rm "$DRUPAL_ROOT/simplesaml"
- ln -s /var/www/simplesamlphp/www "$DRUPAL_ROOT/simplesaml"
- # Lock down Drupal settings file and default site directory
- chmod 644 "$DRUPAL_ROOT/sites/default/settings.php"
- chmod 755 "$DRUPAL_ROOT/sites/default"
- # Run Registry Rebuild in case our code update has created changes that might prevent
- # Drupal from being able to bootstrap. This will also flush site caches.
- drush rr
- # After all files have been deployed and caches cleared, we set correct ownership and permissions
- # in various areas to ensure the system will function normally.
- # Set default ownership for entire Drupal installation
- chown -R root:apache $DRUPAL_ROOT
- # Set directory permissions for Drupal public and private file system
- find "$DRUPAL_ROOT/sites/default/files" -type d -exec chmod 775 {} +
- find "$DRUPAL_ROOT/sites/default/files-private" -type d -exec chmod 775 {} +
- # Set file permissions for Drupal public and private file system
- find "$DRUPAL_ROOT/sites/default/files" -type f -exec chmod 664 {} +
- find "$DRUPAL_ROOT/sites/default/files-private" -type f -exec chmod 664 {} +
- # Run any pending database updates
- drush updb -y
- # Disable Maintenance Mode, only if the previous command was successful
- lastCode=$?
- if [[ $lastCode != 0 ]]; then
- echo "ERROR: Drush exited with code $lastCode"
- exit $lastCode
- fi
- drush vset maintenance_mode 0
Advertisement
Add Comment
Please, Sign In to add comment