diff options
Diffstat (limited to 'shib_secondary/deploy.sh')
-rwxr-xr-x | shib_secondary/deploy.sh | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/shib_secondary/deploy.sh b/shib_secondary/deploy.sh new file mode 100755 index 0000000..536f221 --- /dev/null +++ b/shib_secondary/deploy.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +destination= +domain= +master= +secret= + +while (( $# > 0 )); do + case "$1" in + --dest*) + destination="$2" + shift + ;; + --domain) + domain="$2" + shift + ;; + --master) + master="$2" + shift + ;; + --secret) + secret="$2" + shift + ;; + *) + echo "WAAAAT? NO MAHNEEY?" + exit 1 + esac + shift +done + +if ! [[ $destination =~ ^[a-z0-9_]+@[a-z0-9_.-]+$ ]] \ + || [ -z "$domain" ] \ + || [ -z "$secret" ] \ + || ! [[ "$master" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Usage: $0 --dest user@4.5.6.7 --domain foo.bar.example.com --master 1.2.3.4 --secret your_master_secret" + exit 1 +fi + +if [[ $destination == root@* ]]; then + sudo= +else + echo "+++++++++++++++++++++++++++++++++++++++++++++++++++++" + echo "Using sudo on the remote server to gain root privs..." + sudo="sudo " +fi + +echo + +if ! ssh "$destination" "$sudo rm -rf -- /tmp/shib_deploy"; then + echo "Remote access for preparation failed :-(" + exit 1 +fi + +if ! scp -r "$( dirname -- "${BASH_SOURCE[0]}" )/remote" "${destination}:/tmp/shib_deploy"; then + echo "Copying data to $destination failed" + exit 1 +fi + +if ! ssh "$destination" "$sudo /tmp/shib_deploy/install.sh --domain '$domain' --master '$master' --secret '$secret'"; then + echo "Remote install failed :-(" + exit 1 +fi + +echo "------------------------------------------------------" +echo +echo "Success" +echo +echo +echo "Remember to make sure the new R/O instance's IP address" +echo "is allowed to pull the data from $master, and added to" +echo "the trusted proxy IP addresses." +echo "(RemoteIPInternalProxy)" +echo |