#!/bin/bash #Script for running drush on ALL sites in a multi-site directory. BEWARE. if ! which drush > /dev/null ; then echo "Drush executable not found in your path." exit 1 fi basedir=./ #see if option -d exists while getopts "d:" o; do case $o in d) basedir=$OPTARG esac done shift `echo $OPTIND-1 | bc` commands=$@ cd $basedir if [ $# -lt 1 ]; then echo Usage: drush_multi [-d base_directory] command echo eg: drush_multi modulestatus echo Run drush --help for more info. exit 2 fi echo -n "Are you absolutely sure you want to run 'drush $@' on ALL your sites in `pwd`/sites/? (y/N): " read check if [ $check != 'yes' -a $check != 'y' ]; then echo "Quitting." exit 3 fi #Find all sites dirs. ignore "all", and "default", if it doesn't exist. if [ -f $basedir/sites/default/setting.php ]; then find sites/ -maxdepth 1 -mindepth 1 -type d -o -type l |egrep -v '\ball\b' | \ sed 's/.*\///g'|xargs -I site_dir -t drush -l site_dir $commands else find sites/ -maxdepth 1 -mindepth 1 -type d -o -type l |egrep -v '\b(default|all)\b' | \ sed 's/.*\///g'|xargs -I site_dir -t drush -l site_dir $commands fi