Skip to content

Instantly share code, notes, and snippets.

@phantomjinx
Created November 6, 2019 12:20
Show Gist options
  • Save phantomjinx/8fca4599773ce0c4ce3ef96d0a2d55d0 to your computer and use it in GitHub Desktop.
Save phantomjinx/8fca4599773ce0c4ce3ef96d0a2d55d0 to your computer and use it in GitHub Desktop.
Bash script for executing install of legacy fuse-online-install template
#!/bin/bash
IGNITE=fuse-ignite-1.8
REDHAT_REGISTRY=registry.redhat.io
#REDHAT_REGISTRY=docker.io
if [ -n "$1" ]; then
if [ -f "$1" ]; then
IGNITE="$1"
else
echo "Error: \"$1\" was specified as the template name but a file of that name does not exist"
exit 1
fi
fi
check_resource() {
local kind=$1
local name=$2
oc get $kind $name -o name >/dev/null 2>&1
if [ $? != 0 ]; then
echo "false"
else
echo "true"
fi
}
# Check whether syndesis-pull-secret secret is present and create
# it otherwise
#
create_secret_if_not_present() {
if $(check_resource secret syndesis-pull-secret) ; then
echo "pull secret 'syndesis-pull-secret' present, skipping creation ..."
else
echo "pull secret 'syndesis-pull-secret' is missing, creating ..."
echo "enter username for registry.redhat.io and press [ENTER]: "
read username
echo "enter password for registry.redhat.io and press [ENTER]: "
read -s password
# Testing access that credentials are correct
local reply=$(curl -IsL -u ${username}:${password} "https://sso.redhat.com/auth/realms/rhcc/protocol/redhat-doc
ker-v2/auth?service=docker-registry&client_id=curl&scope=repository:rhel:pull")
# Does reply contain "200 OK". If not throw error and exit
if [ ! -z "${reply##*200 OK*}" ]; then
echo "ERROR: Credentials cannot be verified with redhat registry."
exit 1
fi
echo "enter email address for registry.redhat.io and press [ENTER]: "
read email
oc create secret docker-registry syndesis-pull-secret --docker-server=${REDHAT_REGISTRY} --docker-username=$use
rname --docker-password=$password --docker-email=$email
SECRET=$(oc get secret syndesis-pull-secret)
if [ -z "${SECRET}" ]; then
echo "Error: Failed to create pull secret"
exit 1
fi
fi
}
PROJECT=$(oc project -q)
if [ -z "${PROJECT}" ]; then
echo "No project selected ... exiting"
exit 1
fi
create_secret_if_not_present
oc secrets link default syndesis-pull-secret --for=pull
oc get sa syndesis-oauth-client > /dev/null
if [ $? > 0 ]; then
oc process -f syndesis-oauth-client.yml | oc create -f -
fi
TOKEN=$(oc sa get-token syndesis-oauth-client)
if [ -z "${TOKEN}" ]; then
echo "Failed to create token ... exiting"
exit 1
fi
oc get template ${IGNITE} > /dev/null
if [ $? > 0 ]; then
oc create -f "${IGNITE}.yml"
fi
oc new-app \
--template=${IGNITE} \
-p OPENSHIFT_OAUTH_CLIENT_SECRET=${TOKEN} \
-p OPENSHIFT_PROJECT=${PROJECT} \
-p SAR_PROJECT=${PROJECT} \
-p ROUTE_HOSTNAME=syndesis-syndesis.birds-of-prey.phantomjinx.org.uk \
-p SYNDESIS_REGISTRY=${REDHAT_REGISTRY} \
-n ${PROJECT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment