Skip to content

Commit b065612

Browse files
authored
feat: cert setup features, fixes (#48)
1 parent 1c3f9dc commit b065612

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

cert-setup/csr_generator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SUBJECT="/C=CA/ST=British Columbia/L=Victoria/O=Government of the Province of Br
2525
echo -e "\nSubject: $SUBJECT"
2626

2727
# Accept or create a new subject
28-
echo "Accept subject? (y/n)"
28+
echo "Accept subject? [y/n]"
2929
read ACCEPT
3030
if [[ ! "${ACCEPT}" =~ [Yy] ]]; then
3131
echo "Subject: " && read SUBJECT
@@ -62,7 +62,7 @@ echo ""
6262
echo "- Attach the newly generated CSR file only"
6363

6464
# Open JIRA - optional
65-
echo -e "\nWould you like to be redirected to Natural Resources JIRA? (y/n)"
65+
echo -e "\nWould you like to be redirected to Natural Resources JIRA? [y/n]"
6666
read ACCEPT
6767
if [[ "${ACCEPT}" =~ [Yy] ]]; then
6868
xdg-open 'https://apps.nrs.gov.bc.ca/int/jira/secure/CreateIssue!default.jspa'

cert-setup/install_cert.sh

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ set -euo nounset
1313

1414
# Vanity URL (domain with path)
1515
if [[ -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
1919
else
2020
DOMAIN_WITH_PATH="${1}"
@@ -23,15 +23,18 @@ fi
2323
# Break the URL into domain and (optional) path
2424
[[ ${DOMAIN_WITH_PATH} =~ .*/$ ]] || DOMAIN_WITH_PATH="${DOMAIN_WITH_PATH}/"
2525
DOMAIN=${DOMAIN_WITH_PATH%%/*}
26-
PATH=${DOMAIN_WITH_PATH#*/}
26+
SUBDIR=${DOMAIN_WITH_PATH#*/}
2727

2828
echo -e "\nDomain: ${DOMAIN}"
29-
echo -e "Path: ${PATH}\n"
29+
echo -e "Subdir: ${SUBDIR}\n"
3030

3131
# Service to route/expose
3232
if [[ -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
3639
else
3740
SERVICE="${2}"
@@ -55,8 +58,16 @@ fi
5558
# Install the certificate, modified slightly if a path is present
5659
echo "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
6063
else
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}"
6273
fi

0 commit comments

Comments
 (0)