diff options
| author | Silvio Rhatto <rhatto@riseup.net> | 2009-12-29 16:32:29 -0200 |
|---|---|---|
| committer | Silvio Rhatto <rhatto@riseup.net> | 2009-12-29 16:32:29 -0200 |
| commit | 1d663359337b4c5074bb5605851fce0c73ea4445 (patch) | |
| tree | b62bc28e010155b77248c50e40f039c3ea176ac9 /templates/drupal-upgrade.sh.erb | |
| parent | e2a75915f76409cdc75f1b330c635be58f1950cc (diff) | |
| download | puppet-drupal-1d663359337b4c5074bb5605851fce0c73ea4445.tar.gz puppet-drupal-1d663359337b4c5074bb5605851fce0c73ea4445.tar.bz2 | |
New management scripts
Diffstat (limited to 'templates/drupal-upgrade.sh.erb')
| -rw-r--r-- | templates/drupal-upgrade.sh.erb | 74 |
1 files changed, 74 insertions, 0 deletions
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." |
