This repository has been archived by the owner on Mar 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
install.sh
executable file
·79 lines (55 loc) · 2.55 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bash
LATEST="latest"
FABRIC8_VERSION=${1:-${FABRIC8_VERSION-$LATEST}}
if [ "$FABRIC8_VERSION" == "$LATEST" ] || [ "$FABRIC8_VERSION" == "" ] ; then
FABRIC8_VERSION=$(curl -sL http://central.maven.org/maven2/io/fabric8/platform/packages/fabric8-system/maven-metadata.xml | grep '<latest' | cut -f2 -d">"|cut -f1 -d"<")
fi
TEMPLATE="packages/fabric8-system/target/classes/META-INF/fabric8/openshift.yml"
if [ "$FABRIC8_VERSION" == "local" ] ; then
echo "Installing using a local build"
else
echo "Installing fabric8 version: ${FABRIC8_VERSION}"
TEMPLATE="http://central.maven.org/maven2/io/fabric8/platform/packages/fabric8-system/${FABRIC8_VERSION}/fabric8-system-${FABRIC8_VERSION}-openshift.yml"
fi
echo "Using the fabric8 template: ${TEMPLATE}"
echo "enabling CORS in minishift"
minishift openshift config set --patch '{"corsAllowedOrigins": [".*"]}'
sleep 5
oc login -u developer -p developer
oc new-project developer
oc new-project fabric8
APISERVER=$(oc version | grep Server | sed -e 's/.*http:\/\///g' -e 's/.*https:\/\///g')
NODE_IP=$(echo "${APISERVER}" | sed -e 's/:.*//g')
#EXPOSER="NodePort"
EXPOSER="Route"
echo "Connecting to the API Server at: https://${APISERVER}"
echo "Using Node IP ${NODE_IP} and Exposer strategy: ${EXPOSER}"
echo "Using github client ID: ${GITHUB_OAUTH_CLIENT_ID} and secret: ${GITHUB_OAUTH_CLIENT_SECRET}"
GITHUB_ID="${GITHUB_OAUTH_CLIENT_ID}"
GITHUB_SECRET="${GITHUB_OAUTH_CLIENT_SECRET}"
echo "Applying the fabric8 template ${TEMPLATE}"
oc process -f ${TEMPLATE} -p APISERVER_HOSTPORT=${APISERVER} -p NODE_IP=${NODE_IP} -p EXPOSER=${EXPOSER} -p GITHUB_OAUTH_CLIENT_SECRET=${GITHUB_SECRET} -p GITHUB_OAUTH_CLIENT_ID=${GITHUB_ID} | oc apply -f -
echo "Now adding the OAuthClient and cluster-admin role to the init-tenant service account"
oc login -u system:admin
cat <<EOF | oc create -f -
kind: OAuthClient
apiVersion: v1
metadata:
name: fabric8-online-platform
secret: fabric8
redirectURIs:
- "http://$(oc get route keycloak -o jsonpath="{.spec.host}")/auth/realms/fabric8/broker/openshift-v3/endpoint"
grantMethod: prompt
EOF
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:fabric8:init-tenant
oc login -u developer -p developer
echo "Please wait while the pods all startup!"
echo
echo "To watch this happening you can type:"
echo " oc get pod -l provider=fabric8 -w"
echo
echo "Or you can watch in the OpenShift console via:"
echo " minishift console"
echo
echo "Then you should be able the open the fabric8 console here:"
echo " http://`oc get route fabric8 --template={{.spec.host}}`/"