Skip to content

Commit

Permalink
Merge pull request #19 from franrou/feature/multisite-commands
Browse files Browse the repository at this point in the history
Issue #18: Feature/multisite commands
  • Loading branch information
juanjol authored Dec 11, 2024
2 parents facf97d + 08efb4c commit 24431c8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
26 changes: 26 additions & 0 deletions commands/host/all-sites-drush
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
#ddev-generated
## Description: Launches a drush command on all of the sites
## Usage: all-sites-drush [drush command]

source "$(dirname "$0")/includes/aljibe_includes"

ENV='local'
COMMAND=''
SITES=()

COMMAND=$@;
if [ -z "$COMMAND" ]; then
echo "Please provide a drush command"
exit
fi

## Get all sites from the drush/sites folder.
set_sites_variable

## Run the command in all sites.
for SITE in "${SITES[@]}"; do
SITE_ALIAS=$SITE.$ENV
echo "Running drush $COMMAND in $SITE"
ddev drush @${SITE_ALIAS} $COMMAND
done
7 changes: 6 additions & 1 deletion commands/host/includes/aljibe_includes
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ run_hooks() {
echo -e "\033[32mRunning $1 commands: \033[0m\n"
readarray -t CMDS < <(ddev aljibe-config hooks.$1)
run_commands "${CMDS[@]}"
}
}

## Get all sites list from the drush/sites folder.
set_sites_variable() {
mapfile -t SITES < <(find drush/sites -name '*.site.yml' -exec basename {} \; | cut -d'.' -f1)
}
2 changes: 1 addition & 1 deletion commands/host/setup
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,4 @@ if [ "$NO_INSTALL" -eq 0 ]; then
fi

# Launch post setup hooks
run_hooks "post_setup"
run_hooks "post_setup"

0 comments on commit 24431c8

Please sign in to comment.