Skip to content

Instantly share code, notes, and snippets.

@ngmaloney
Created March 18, 2010 16:03
Show Gist options
  • Save ngmaloney/336504 to your computer and use it in GitHub Desktop.
Save ngmaloney/336504 to your computer and use it in GitHub Desktop.
Drupal Drush Update Script
#!/bin/bash
DRUSH="$(which drush)"
BASEDIR="/var/www/vhosts/mysite.com/httpdocs"
cd $BASEDIR
#Iterate through sites and put in offline mode
ls $BASEDIR/sites |while read line
do
if [[ "$line" != "all" && "$line" != "default" && "$line" != "CVS" ]]
then
#Put Site Offline
offline_cmd="$DRUSH --uri=$line vset site_offline 1 -y"
$offline_cmd
fi
done
#Iterate through sites update
ls $BASEDIR/sites |while read line
do
if [[ "$line" != "all" && "$line" != "default" && "$line" != "CVS" ]]
then
#Update Site
update_cmd="$DRUSH --uri=$line up -y"
$update_cmd
#UpdateDB
updatedb_cmd="$DRUSH --uri=$line updatedb -y"
$updatedb_cmd
fi
done
#Iterate through sites and put back online
ls $BASEDIR/sites |while read line
do
if [[ "$line" != "all" && "$line" != "default" && "$line" != "CVS" ]]
then
#Put Site Back Online
online_cmd="$DRUSH --uri=$line vset site_offline 0 -y"
$online_cmd
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment