aboutsummaryrefslogtreecommitdiff
path: root/templates/drupal-upgrade.sh.erb
diff options
context:
space:
mode:
Diffstat (limited to 'templates/drupal-upgrade.sh.erb')
-rw-r--r--templates/drupal-upgrade.sh.erb74
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."