Last active
February 25, 2019 13:37
-
-
Save foospidy/7b88a1cfed223d4d4caa9f4598d1a405 to your computer and use it in GitHub Desktop.
Copy all users from a site to other sites.
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
#!/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