@@ -13,8 +13,8 @@ set -euo nounset
1313
1414# Vanity URL (domain with path)
1515if [[ -z " ${1:- } " ]]; then
16- echo " Enter the fully qualified domain name (FQDN) and any path for the certificate:"
17- echo " E.g. <app>.nrs.gov.bc.ca/<path >"
16+ echo " Enter the fully qualified domain name (FQDN) and any path/subdir for the certificate:"
17+ echo " E.g. <app>.nrs.gov.bc.ca/<subdir >"
1818 read DOMAIN_WITH_PATH
1919else
2020 DOMAIN_WITH_PATH=" ${1} "
2323# Break the URL into domain and (optional) path
2424[[ ${DOMAIN_WITH_PATH} =~ .* /$ ]] || DOMAIN_WITH_PATH=" ${DOMAIN_WITH_PATH} /"
2525DOMAIN=${DOMAIN_WITH_PATH%%/* }
26- PATH =${DOMAIN_WITH_PATH#*/ }
26+ SUBDIR =${DOMAIN_WITH_PATH#*/ }
2727
2828echo -e " \nDomain: ${DOMAIN} "
29- echo -e " Path : ${PATH } \n"
29+ echo -e " Subdir : ${SUBDIR } \n"
3030
3131# Service to route/expose
3232if [[ -z " ${2:- } " ]]; then
33- echo " Enter the OpenShift service name to expose:"
34- echo " E.g. nr-<app>-prod-frontend"
33+ echo -e " Services:"
34+ oc get services -o name | sed ' s|service/| |g'
35+
36+ echo -e " \nEnter the OpenShift service name to expose:"
37+ echo -e " E.g. nr-<app>-prod-frontend"
3538 read SERVICE
3639else
3740 SERVICE=" ${2} "
5558# Install the certificate, modified slightly if a path is present
5659echo " Installing route"
5760# https://docs.openshift.com/container-platform/4.15/networking/routes/secured-routes.html#nw-ingress-creating-an-edge-route-with-a-custom-certificate_secured-routes
58- if [ -z " ${PATH } " ]; then
61+ if [ -z " ${SUBDIR } " ]; then
5962 oc create route edge --service=${SERVICE} --cert=${DOMAIN} .cert --key=${DOMAIN} .key --ca-cert=${DOMAIN} .ca-cert --hostname=${DOMAIN} ${SERVICE} -vanity
6063else
61- oc create route edge --service=${SERVICE} --cert=${DOMAIN} .cert --key=${DOMAIN} .key --ca-cert=${DOMAIN} .ca-cert --hostname=${DOMAIN} --path=${PATH} ${SERVICE} -vanity
64+ oc create route edge --service=${SERVICE} --cert=${DOMAIN} .cert --key=${DOMAIN} .key --ca-cert=${DOMAIN} .ca-cert --hostname=${DOMAIN} --path=${SUBDIR} ${SERVICE} -vanity
65+ fi
66+
67+ # Visit and confirm the new route
68+ echo -e " \nWould you like to be redirected to the new route?"
69+ echo -e " => https://${DOMAIN_WITH_PATH} [y/n]"
70+ read ACCEPT
71+ if [[ " ${ACCEPT} " =~ [Yy] ]]; then
72+ xdg-open " https://${DOMAIN_WITH_PATH} "
6273fi
0 commit comments