]> gitweb.fluxo.info Git - puppet-drupal.git/commitdiff
Checking for existing installations on drupal script
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 29 Dec 2009 21:09:03 +0000 (19:09 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 29 Dec 2009 21:09:03 +0000 (19:09 -0200)
templates/drupal.sh.erb

index e5956c8781b7d9f2c2f5cf735e53a1f2bf74e237..34a619890ad48c2a3888d222c4fbd07256cc06bc 100644 (file)
@@ -7,10 +7,18 @@ BASE="<%= apache_www_folder %>"
 SERIES="5 6"
 
 # Get drupal major version
-function get_major {
+function drupal_get_major {
   echo $1 | sed -e 's/\(^.\).*/\1/'
 }
 
+# Check for existing installations
+function drupal_check_existing {
+  if [ -e "$BASE/drupal-$1" ]; then
+    echo "Folder $BASE/drupal-$1 already exist, skipping"
+    exit 1
+  fi  
+}
+
 # Deploy a fresh drupal tree
 function drupal_deploy {
   if [ "$#" != "1" ]; then
@@ -21,6 +29,7 @@ function drupal_deploy {
   # Setup
   new="$1"
   cd $BASE
+  drupal_check_existing $new
 
   # Deploy a fresh drupal tree
   wget http://ftp.drupal.org/files/projects/drupal-$new.tar.gz
@@ -32,8 +41,14 @@ function drupal_deploy {
 # Update all drupal instances in the host
 function drupal_update {
   for version in $SERIES; do
-    # Setup base and sites folders
+    # Setup base folder
     base="$BASE/drupal-$version"
+
+    if [ ! -d "$base/sites" ]; then
+      break
+    fi
+
+    # Setup site folders
     cd $base/sites
     drupals="`ls -I default -I all`"
   
@@ -62,14 +77,16 @@ function drupal_upgrade {
   # Setup
   old="$1"
   new="$2"
-  old_major="`get_major $old`"
-  new_major="`get_major $new`"
+  old_major="`drupal_get_major $old`"
+  new_major="`drupal_get_major $new`"
   extra_folders=""
   
   if [ "$old_major" != "$new_major" ]; then
     echo "Major versions doesn't match"
     exit 1
   fi
+
+  drupal_check_existing $new
   
   # Set drupal series
   if [ "$new_major" == "4" ]; then