]> gitweb.fluxo.info Git - puppet-drupal.git/commitdiff
New management scripts
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 29 Dec 2009 18:32:29 +0000 (16:32 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 29 Dec 2009 18:32:29 +0000 (16:32 -0200)
manifests/init.pp
templates/drupal-deploy.sh.erb [new file with mode: 0644]
templates/drupal-update.sh [moved from templates/drush-update.sh.erb with 100% similarity]
templates/drupal-upgrade.sh.erb [new file with mode: 0644]

index 8c928ff315c0b7afe16ce83c9f74493097f5b7a9..a501b0c0dc0b52e2d5c2e26ae5ca50d38b91f3a5 100644 (file)
@@ -9,12 +9,30 @@ class drupal inherits pear {
       ensure => installed,
   }
 
-  # Drush update
-  file { "/usr/local/bin/drush-update.sh":
+  # Drupal update script
+  file { "/usr/local/bin/drupal-update.sh":
     ensure  => present,
     content => template('drupal/drush-update.sh'),
     user    => root,
     group   => root,
     mode    => 755,
   }
+
+  # Drupal upgrade script
+  file { "/usr/local/bin/drupal-upgrade.sh":
+    ensure  => present,
+    content => template('drupal/drush-upgrade.sh'),
+    user    => root,
+    group   => root,
+    mode    => 755,
+  }
+
+  # Drupal deployment script
+  file { "/usr/local/bin/drupal-deploy.sh":
+    ensure  => present,
+    content => template('drupal/drupal-deploy.sh'),
+    user    => root,
+    group   => root,
+    mode    => 755,
+  }
 }
diff --git a/templates/drupal-deploy.sh.erb b/templates/drupal-deploy.sh.erb
new file mode 100644 (file)
index 0000000..e7b51ae
--- /dev/null
@@ -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/drupal-upgrade.sh.erb b/templates/drupal-upgrade.sh.erb
new file mode 100644 (file)
index 0000000..670a6e5
--- /dev/null
@@ -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."