diff options
Diffstat (limited to 'templates')
-rw-r--r-- | templates/drupal-deploy.sh.erb | 20 | ||||
-rw-r--r-- | templates/drupal-update.sh (renamed from templates/drush-update.sh.erb) | 0 | ||||
-rw-r--r-- | templates/drupal-upgrade.sh.erb | 74 |
3 files changed, 94 insertions, 0 deletions
diff --git a/templates/drupal-deploy.sh.erb b/templates/drupal-deploy.sh.erb new file mode 100644 index 0000000..e7b51ae --- /dev/null +++ b/templates/drupal-deploy.sh.erb @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Deploy a fresh drupal tree. +# + +if [ "$#" != "1" ]; then + echo "Usage: `basename $0` <version>" + exit 1 +fi + +NEW="$1" +BASE="<%= $apache_www_folder %>" + +cd $BASE + +# Deploy a fresh drupal tree +wget http://ftp.drupal.org/files/projects/drupal-$NEW.tar.gz +tar zxvf drupal-$NEW.tar.gz && rm drupal-$NEW.tar.gz +chown -R root.root drupal-$NEW/ +cd drupal-$NEW && rm -rf sites diff --git a/templates/drush-update.sh.erb b/templates/drupal-update.sh index 75e8381..75e8381 100644 --- a/templates/drush-update.sh.erb +++ b/templates/drupal-update.sh diff --git a/templates/drupal-upgrade.sh.erb b/templates/drupal-upgrade.sh.erb new file mode 100644 index 0000000..670a6e5 --- /dev/null +++ b/templates/drupal-upgrade.sh.erb @@ -0,0 +1,74 @@ +#!/bin/bash +# +# Upgrade a drupal instance using upstream source. +# + +if [ "$#" != "2" ]; then + echo "Usage: `basename $0` <old_version> <new_version>" + exit 1 +fi + +function get_major { + echo $1 | sed -e 's/\(^.\).*/\1/' +} + +OLD="$1" +NEW="$2" +OLD_MAJOR="`get_major $OLD`" +NEW_MAJOR="`get_major $NEW`" +BASE="<%= $apache_www_folder %>" +EXTRA_FOLDERS="" + +if [ "$OLD_MAJOR" != "$NEW_MAJOR" ]; then + echo "Major versions doesn't match" + exit 1 +fi + +# Set drupal series +if [ "$NEW_MAJOR" == "4" ]; then + # Get minor versions + NEW_MINOR="`echo $NEW | sed -e "s/^$NEW_MAJOR\.//"`" + OLD_MINOR="`echo $OLD | sed -e "s/^$OLD_MAJOR\.//"`" + + if [ "$OLD_MINOR" != "$NEW_MINOR" ]; then + echo "Minor versions doesn't match" + exit 1 + fi + DRUPAL_SERIES="$NEW_MAJOR.$MINOR" +else + DRUPAL_SERIES="$NEW_MAJOR" +fi + +cd $BASE + +# Deploy a fresh drupal tree +drupal-deploy.sh $NEW + +# Copy files +cp -Rp ../drupal-$OLD/{.htaccess,favicon.ico,files/,sites/} . &> /dev/null +for extra_folder in $EXTRA_FOLDERS; do + if [ -d ../drupal-$OLD/$extra_folder ]; then + cp -Rp ../drupal-$OLD/$extra_folder . + fi +done + +# Legacy stuff for Drupal 4.x.x +if [ "$NEW_MAJOR" == "4" ]; then + rsync -av ../drupal-$OLD/themes/ themes/ + for module in `ls ../drupal-$OLD/modules`; do + if [ -d "../drupal-$OLD/modules/$module" ]; then + cp -Rp ../drupal-$OLD/modules/$module modules/ + fi + done +fi + +# Copy installation profiles for Drupal 5.x or newer +if [ "$NEW_MAJOR" != "4" ]; then + rsync -av --exclude=default ../drupal-$OLD/profiles/ profiles/ +fi + +# Change symlink to point to the new location +cd $BASE ; rm drupal-$DRUPAL_SERIES && ln -s drupal-$NEW drupal-$DRUPAL_SERIES + +# Done +echo "Check procedure and remove drupal-$OLD once you make sure that everything is fine." |