Created
October 5, 2011 14:57
-
-
Save zachseifts/1264630 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# migrate.sh - Migrates a site to a new platform | |
# | |
function usage() { | |
cat << EOF | |
usage: | |
${0#$SCRIPTSDIR/bin/} [-h] -s @sitename.appstate.edu | |
Updates a drupal site by creating a new platform and then migrating the site | |
to the new platform. | |
OPTIONS: | |
-h Display this message | |
-s Drush site alias | |
EOF | |
} | |
# Get command line arguments | |
SITE= | |
while getopts "h:s:" OPTION | |
do | |
case $OPTION in | |
h) | |
usage | |
exit 0 | |
;; | |
s) | |
SITE=$OPTARG | |
;; | |
?) | |
usage | |
echo "Invalid option $OPTION specified." | |
exit 1 | |
;; | |
esac | |
done | |
if [[ -z $SITE ]] | |
then | |
usage | |
exit 1 | |
fi | |
exit 1 | |
if [ -e "$HOME/.$NAME-platform" ] | |
then | |
cat $HOME/.$NAME-platform | while read line; do CURRENTPLATFORM="${line}"; done | |
echo $CURRENTPLATFORM | |
fi | |
DRUSH=/opt/drush/drush.php | |
NOW=$(date +%s) | |
PLATFORM=$NAME-$VERSION.x-$BRANCH-$NOW | |
PLATFORM_ROOT=/var/aegir/platforms/$VERSION.x | |
PLATFORM_NAME=platform_$NAME-$VERSION-$BRANCH-$NOW | |
# Create a new platform | |
cd $PLATFORM_ROOT | |
if [ $? -ne 0 ] | |
then | |
echo "cannot cd to $PLATFORM_ROOT" | |
exit 1 | |
fi | |
$DRUSH make $MAKEFILE $PLATFORM | |
if [ $? -ne 0 ] | |
then | |
echo "drush make has failed to build $MAKEFILE" | |
exit 1 | |
fi | |
$DRUSH --root="$PLATFORM_ROOT/$PLATFORM" provision-save "@$PLATFORM_NAME" --context_type="platform" | |
if [ $? -ne 0 ] | |
then | |
echo "Provision has failed" | |
exit 1 | |
fi | |
$DRUSH @hostmaster hosting-import "@$PLATFORM_NAME" | |
if [ $? -ne 0 ] | |
then | |
echo "hosting-import has failed" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment