From 1b8b9da24e1337fcea57bcef67a45e35defba78b Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 29 Dec 2009 19:09:03 -0200 Subject: Checking for existing installations on drupal script --- templates/drupal.sh.erb | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/templates/drupal.sh.erb b/templates/drupal.sh.erb index e5956c8..34a6198 100644 --- a/templates/drupal.sh.erb +++ b/templates/drupal.sh.erb @@ -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 -- cgit v1.2.3