Skip to content

Instantly share code, notes, and snippets.

@aanklewicz
Created January 16, 2021 03:17
Show Gist options
  • Save aanklewicz/a208d93058af1e7a509582c4b985e353 to your computer and use it in GitHub Desktop.
Save aanklewicz/a208d93058af1e7a509582c4b985e353 to your computer and use it in GitHub Desktop.
This script will create an account in Google Apps or whatever it's called now, it adds them to their groups and then creates an account on ManageBac
#!/bin/sh
# This script will create an account in Google Apps or whatever it's called now, it adds them to their groups and then creates an account on ManageBac
# Usage ./Onboarding\ newstaff.sh -f Jean-Luc -l Picard -o "/Teachers"
# -o can be "/Teachers" or "/Admin Staff"
while getopts "f:l:o:" opt; do
case $opt in
f) FIRSTNAME=$OPTARG ;;
l) LASTNAME=$OPTARG ;;
o) ORG=$OPTARG ;;
*) echo 'error' >&2
exit 1
esac
done
set -x
# Managebac API goes here
MB="apikeyhere"
EMAIL="${FIRSTNAME:0:1}.${LASTNAME}@domain.com"
PASSWORD=$(curl https://www.dinopass.com/password/simple)
# org is either /Teachers or /Admin Staff
# create the user
~/bin/gam/gam create user ${EMAIL} firstname ${FIRSTNAME} lastname ${LASTNAME} password ${PASSWORD} changepassword on org "${ORG}"
# Add to group(s)
~/bin/gam/gam update group group1@domain.com add member user ${EMAIL}
if [ $0 = "/Admin Staff" ] ; then
~/bin/gam/gam update group extragroup@domain.com add member user ${EMAIL}
fi
# Create the teacher in MB
curl --request POST \
--url https://api.managebac.com/v2/teachers \
--header "auth-token: ${MB}" \
--header 'content-type: application/json' \
--data "{
\"teacher\": {
\"first_name\": \"${FIRSTNAME}\",
\"last_name\": \"${LASTNAME}\",
\"email\": \"${EMAIL}\"
}
}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment