Created
December 3, 2012 16:30
-
-
Save simong/4196111 to your computer and use it in GitHub Desktop.
Hilary scripts
This file contains hidden or 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
| #createTenant.sh | |
| #!/bin/bash | |
| if [ "$1" = "--usage" ] ; then | |
| echo "All parameters are optional. The default options will " | |
| echo "create a cambridge tenant as in the example." | |
| echo "--------------------------------------------------------" | |
| echo "./createTenant.sh <alias:cam> <tenant name:Cambridge> <hostname:cam.oae.com>" | |
| echo "--------------------------------------------------------" | |
| echo "Example:" | |
| echo "" | |
| echo "./createTenant.sh cam Cambridge cam.oae.com" | |
| echo "--------------------------------------------------------" | |
| exit 0 | |
| fi | |
| # Load shared functionality | |
| source ./shared.sh; | |
| TENANT_ALIAS=${1-cam}; | |
| TENANT_NAME=${2-Cambridge} | |
| TENANT_HOST=${3-cam.oae.com} | |
| # Create a tenant. | |
| STATUS=$(curl --silent --output /dev/null --write-out %{http_code} --cookie connect.sid=${ADMIN_COOKIE} -d"alias=${TENANT_ALIAS}" -d"name=${TENANT_NAME}" -d"host=${TENANT_HOST}" http://${GLOBAL_HOST}/api/tenant/create) | |
| output $STATUS 200 "Created a tenant" | |
| #configTenant.sh | |
| #!/bin/bash | |
| if [ "$1" = "--usage" ] ; then | |
| echo "This script will disable the reCaptcha settings." | |
| echo "Only the tenant host is required." | |
| echo "--------------------------------------------------------" | |
| echo "./configTenant.sh <tenant host> " | |
| echo "--------------------------------------------------------" | |
| echo "Example:" | |
| echo "" | |
| echo "./configTenant.sh cam.oae.com" | |
| echo "--------------------------------------------------------" | |
| exit 0 | |
| fi | |
| if [ $# -eq 0 ] ; then | |
| echo "You need to specify the tenant hostname." | |
| exit 1 | |
| fi | |
| source ./shared.sh | |
| STATUS=$(curl --silent --output /dev/null --write-out %{http_code} --cookie connect.sid=${ADMIN_COOKIE} \ | |
| -d"oae-content/default-content-copyright/defaultcopyright=nocopyright" \ | |
| -d"oae-content/contentpermissions/defaultaccess=public" \ | |
| -d"oae-content/documentpermissions/defaultaccess=public" \ | |
| -d"oae-content/linkpermissions/defaultaccess=public" \ | |
| -d"oae-content/collectionpermissions/defaultaccess=public" \ | |
| -d"oae-content/default-content-privacy/defaultprivacy=everyone" \ | |
| -d"oae-content/storage/backend=amazons3" \ | |
| -d"oae-content/storage/local-dir=/opt/sakai/poc/files" \ | |
| -d"oae-content/storage/amazons3-access-key=access" \ | |
| -d"oae-content/storage/amazons3-secret-key=secret" \ | |
| -d"oae-content/storage/amazons3-region=us-east-1" \ | |
| -d"oae-content/storage/amazons3-bucket=oae-performance-files" http://${GLOBAL_HOST}/api/config); | |
| output $STATUS 200 "Configured storage" | |
| STATUS=$(curl --silent --output /dev/null --write-out %{http_code} --cookie connect.sid=${ADMIN_COOKIE} -d"oae-principals/recaptcha/enabled=false" http://${GLOBAL_HOST}/api/config) | |
| output $STATUS 200 "Turned reCaptcha off" | |
| # shared.sh | |
| GLOBAL_HOST=admin.oae.com | |
| TENANT_HOST=cam.oae.com | |
| function output { | |
| if [ "$1" -eq "$2" ] ; then | |
| echo $'\e[32m' " ✓ $3" | |
| else | |
| echo $'\e[31m' "$3 - Expected: $2, Got: $1" | |
| fi | |
| } | |
| ADMIN_COOKIE=$(curl -s --cookie-jar - -d"username=administrator" -d"password=administrator" http://${GLOBAL_HOST}/api/auth/login | grep connect.sid | cut -f 7) | |
| if [ -z "${ADMIN_COOKIE}" ] && [ "${ADMIN_COOKIE+xxx}" = "xxx" ] ; then | |
| echo $'\e[31m' "Could not log in as an admin." | |
| exit 1; | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment