From 3e1f6d3f414b809ba4ed1631d49dbb428f79ee7b Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 9 Mar 2010 16:47:39 -0300 Subject: Adding cron handling into drupal script --- templates/drupal.sh.erb | 59 +++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/templates/drupal.sh.erb b/templates/drupal.sh.erb index 26060fd..3a10864 100644 --- a/templates/drupal.sh.erb +++ b/templates/drupal.sh.erb @@ -14,36 +14,13 @@ function drupal_get_major { # Check for existing installations function drupal_check_existing { if [ -e "$BASE/drupal-$1" ]; then - echo "Folder $BASE/drupal-$1 already exist, skipping" + echo "Folder $BASE/drupal-$1 already exists, skipping" exit 1 fi } -# Deploy a fresh drupal tree -function drupal_deploy { - if [ "$#" != "1" ]; then - echo "Usage: `basename $0` deploy " - exit 1 - fi - - # 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 - tar zxvf drupal-$new.tar.gz && rm drupal-$new.tar.gz - chown -R root.root drupal-$new/ - cd drupal-$new && rm -rf sites -} - -# Update all drupal instances in the host -function drupal_update { - if [ -z "$update" ]; then - update="update" - fi - +# Iterate through all drupal instances +function drupal_iterate { for version in $SERIES; do # Setup base folder base="$BASE/drupal-$version" @@ -61,7 +38,7 @@ function drupal_update { # Ignore symlinks so sites are updated just once if [ ! -h "$drupal" ] || [ ! -h "`readlink $drupal`" ]; then echo "Processing $drupal..." - drush -l $drupal $update + drush -l $drupal $* fi done @@ -75,6 +52,25 @@ function drupal_update { done } +# Deploy a fresh drupal tree +function drupal_deploy { + if [ "$#" != "1" ]; then + echo "Usage: `basename $0` deploy " + exit 1 + fi + + # 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 + tar zxvf drupal-$new.tar.gz && rm drupal-$new.tar.gz + chown -R root.root drupal-$new/ + cd drupal-$new && rm -rf sites +} + # Upgrade a drupal instance using upstream source. function drupal_upgrade { if [ "$#" != "2" ]; then @@ -150,18 +146,19 @@ function drupal_upgrade { # Main procedure if [ -z "$1" ]; then - echo "Usage: `basename $0` [arguments]" + echo "Usage: `basename $0` [arguments]" exit 1 +elif [ "$1" == "cron" ]; then + drupal_iterate cron elif [ "$1" == "deploy" ]; then shift drupal_deploy $* elif [ "$1" == "update" ]; then shift - drupal_update $* + drupal_iterate update $* elif [ "$1" == "updatedb" ]; then shift - update="updatedb" - drupal_update $* + drupal_iterate updatedb $* elif [ "$1" == "upgrade" ]; then shift drupal_upgrade $* -- cgit v1.2.3