Created
May 12, 2017 19:35
-
-
Save dasginganinja/5090d6bebe85eb43a7a56e1e8fb11ad5 to your computer and use it in GitHub Desktop.
Bash Script for running multisite drush in parallel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DRUPALPATH=$1 | |
shift | |
if [ "$DRUPALPATH" == "" ] | |
then | |
echo "Usage: $0 drupal-path drush-command with-args?" | |
exit 1 | |
fi | |
DRUSHCOMMAND=$@ | |
if [ "$DRUSHCOMMAND" == "" ] | |
then | |
echo "Usage: $0 drush-command with-args?" | |
exit 1 | |
fi | |
function parallel_drush_cmd() { | |
SITE=$(basename $1) | |
OUTPUT=$(sudo drush -r $DRUPALPATH -l $SITE $DRUSHCOMMAND 2>&1) | |
echo "$SITE - $DRUSHCOMMAND" | |
echo "$OUTPUT" | |
echo "----" | |
return 0 | |
} | |
export DRUPALPATH | |
export DRUSHCOMMAND | |
export -f parallel_drush_cmd | |
SITES=$(find $DRUPALPATH/sites/ -mindepth 1 -maxdepth 1 -type d -not -name "skel" -not -name "all" -not -name "default" -print) | |
echo "$SITES" | xargs -I{} -P 4 bash -c 'parallel_drush_cmd {}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment