Skip to content

Instantly share code, notes, and snippets.

@foospidy
Last active February 25, 2019 13:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save foospidy/7b88a1cfed223d4d4caa9f4598d1a405 to your computer and use it in GitHub Desktop.
Save foospidy/7b88a1cfed223d4d4caa9f4598d1a405 to your computer and use it in GitHub Desktop.
Copy all users from a site to other sites.
#!/usr/bin/env bash
###################
# Signal Sciences helper script:
# sigsci-copy-users.sh
# For a given site, copy all users to specified sites.
# Requires:
# - pysigsci (https://pypi.org/project/pysigsci/)
# - jq (https://stedolan.github.io/jq/)
# short name of site that has users you want to copy
SITE="site_short_name"
# array of site short names that all users are to be copied to.
# example: SITE_ARRAY=("site_one", "site_two", "site_three")
SITE_ARRAY=()
for user in `pysigsci --get site-members --site $SITE | jq ".data[] | \"\(.user.email),\(.role)\""`;
do
user=`echo $user | sed -e 's/\"//g'`
IFS=',' read -r -a array <<< "$user"
for site in ${SITE_ARRAY[@]};
do
JSON="{\"role\": \"${array[1]}\"}"
pysigsci --add site-member --site $site --email ${array[0]} --data "$JSON"
done;
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment