Skip to content

Instantly share code, notes, and snippets.

@soreana
Created March 9, 2021 10:00
Show Gist options
  • Save soreana/7c20dd1b5bca00cfdfee5018c13add6a to your computer and use it in GitHub Desktop.
Save soreana/7c20dd1b5bca00cfdfee5018c13add6a to your computer and use it in GitHub Desktop.
#!/bin/bash
templatefilters=("all" "featured" "self" "selfexecutable" "sharedexecutable" "executable" "community")
accounts=("admin" "test" "test2")
if [[ '-h' == $1 ]]; then
echo -e "Usage explained:"
echo -e "\t-h shows this help"
echo -e "\t'./listTemplates.sh' list all filter"
echo -e "\t'./listTemplates.sh <account name>' list all templates using all possible filters for <account name>"
echo -e "\t'./listTemplates.sh <template filter>' list all templates for accounts in ('admin' 'test' 'test2') using <template filter>"
echo -e "\t'./listTemplates.sh <account name> <template filter>' list all templates for <accounts name> using <template filter>"
exit
fi
if [ $# -eq 0 ]; then
for filter in ${templatefilters[@]}; do
echo "***************************************** $filter ****************************************"
for account in ${accounts[@]}; do
echo -e "\n\n********** $account"
cmk set profile "$account"
cmk list templates templatefilter="$filter" filter=name
done
done
elif [ $# -eq 2 ]; then
account=$1
filter=$2
cmk set profile "$1"
cmk list templates templatefilter="$filter" filter=name
elif [[ ${accounts[*]} =~ $1 ]]; then
account=$1
cmk set profile "$account"
for filter in ${templatefilters[@]}; do
echo -e "\n\n********** $filter"
cmk list templates templatefilter="$filter" filter=name
done
else
filter=$1
for account in ${accounts[@]}; do
echo -e "\n\n********** $account"
cmk set profile "$account"
cmk list templates templatefilter="$filter" filter=name
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment