#!/usr/bin/env bash # usage ./mulitsite-drush-command.bash path_to_sites_directory command "paramters" # path_to_sites_directory is the full path drupals sites directory (something like /var/www/drupal/web/sites) # and command is a drush command #switched to actual directories instead of symlinks as we have multiple symlinks for some production directories #excludes the all and the current directory (.). [ $# -lt 2 ] && { echo "Usage: $0 path_to_sites_directory drush_command"; exit 1; } cd "$1" pwd list="$(find ./ -maxdepth 1 -type d)" for link in $list ; do if [ "$(basename "$link")" != "all" ] && [ "$(basename "$link")" != "." ] ; then cd "$link" #pwd echo "Executing Drush command '$2' for site: $link" ../../../vendor/bin/drush "$2" $3 --yes if [ $? -ne 0 ]; then echo "Error: Drush command failed for site: $site_name" fi cd "$1" fi done exit