From 38da58b854cb7e9bf73af63027ba93024431bfbf Mon Sep 17 00:00:00 2001 From: Brian Weaver <weaver.299@osu.edu> Date: Thu, 17 Jun 2021 15:40:28 -0400 Subject: [PATCH] add which_sites_use_module.sh --- scripts/which_sites_use_module.sh | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 scripts/which_sites_use_module.sh diff --git a/scripts/which_sites_use_module.sh b/scripts/which_sites_use_module.sh new file mode 100755 index 0000000000..0c5300edf0 --- /dev/null +++ b/scripts/which_sites_use_module.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +if [[ -z $1 ]]; then + echo; echo "Usage: $0 'module_name'"; + echo; echo; + exit 1; +fi + + +LOG_FILE=$1-sites-`date +%Y%m%d_%H%M`.txt; +echo "log file: $LOG_FILE"; echo; + +SITES=$(terminus org:site:list ohio-state-arts-and-sciences --upstream=b9baf7af-eb2c-4db5-81e6-32d3d9042572 --fields=name --format=string | sort); + + +parallel --delay 0.1 --tag "terminus remote:drush {}.live pm:list -- --format=table --fields=status,name |grep $1" ::: $SITES | tee $LOG_FILE + + +ENABLED_COUNT=$(grep -i 'enabled' $LOG_FILE | wc -l); +DISABLED_COUNT=$(grep -i 'disabled' $LOG_FILE | wc -l); +UNINSTALLED_COUNT=$(grep -i 'not installed' $LOG_FILE | wc -l); + + +# perl -pi -e 's/^[-\w]+\s+enabled\s+\w+\s*\n//;' $LOG_FILE; +# perl -pi -e 's/^[-\w]+\s+disabled\s+\w+\s*\n//;' $LOG_FILE; +# perl -pi -e 's/^[-\w]+\s+not installed\s+\w+\s*\n//;' $LOG_FILE; + +echo; + +if [ -s $LOG_FILE ]; then + echo; echo "===================================="; + cat $LOG_FILE; + echo "====================================";echo; +else + echo "Pruned log file is empty. Deleted."; echo; + # rm $LOG_FILE; +fi + +echo "$ENABLED_COUNT - enabled."; +echo "$DISABLED_COUNT - disabled."; +echo "$UNINSTALLED_COUNT - not installed."; + +echo;echo; + -- GitLab