Skip to content

Commit ba41dc6

Browse files
authored
Removemigrateshellck (#755)
1 parent c5c1fa3 commit ba41dc6

28 files changed

+1669
-1808
lines changed

logging/bin/apiaccess-include.sh

Lines changed: 203 additions & 207 deletions
Large diffs are not rendered by default.

logging/bin/change_internal_password.sh

Lines changed: 217 additions & 222 deletions
Large diffs are not rendered by default.

logging/bin/common.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#! /bin/bash
2+
13
# Copyright © 2020, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
24
# SPDX-License-Identifier: Apache-2.0
35

@@ -8,21 +10,23 @@ if [ "$SAS_LOGGING_COMMON_SOURCED" = "" ]; then
810
source bin/common.sh
911

1012
if [ -f "$USER_DIR/logging/user.env" ]; then
11-
userEnv=$(grep -v '^[[:blank:]]*$' $USER_DIR/logging/user.env | grep -v '^#' | xargs)
13+
userEnv=$(grep -v '^[[:blank:]]*$' "$USER_DIR/logging/user.env" | grep -v '^#' | xargs)
14+
1215
log_verbose "Loading user environment file: $USER_DIR/logging/user.env"
1316
if [ "$userEnv" ]; then
14-
export $userEnv
17+
# shellcheck disable=SC2086,SC2163
18+
export $userEnv
1519
fi
1620
fi
1721

1822
#Check for obsolete env var
19-
if [ -n "$LOG_SEARCH_BACKEND" ]; then
23+
if [ -n "$LOG_SEARCH_BACKEND" ]; then
2024
log_error "Support for the LOG_SEARCH_BACKEND environment variable has been removed."
2125
log_error "This script is only appropriate for use with OpenSearch as the search back-end."
2226
log_error "The LOG_SEARCH_BACKEND environment variable is currently set to [$LOG_SEARCH_BACKEND]"
2327
exit 1
2428
fi
25-
29+
2630
export LOG_NS="${LOG_NS:-logging}"
2731

2832
#if TLS (w/in cluster; for all monitoring components) is requested, require TLS into OSD pod, too
@@ -47,7 +51,7 @@ if [ "$SAS_LOGGING_COMMON_SOURCED" = "" ]; then
4751
export V4M_NS=$LOG_NS
4852

4953
if [ "$AIRGAP_DEPLOYMENT" == "true" ]; then
50-
source bin/airgap-include.sh
54+
source bin/airgap-include.sh
5155
fi
5256

5357
source bin/version-include.sh
@@ -56,4 +60,3 @@ if [ "$SAS_LOGGING_COMMON_SOURCED" = "" ]; then
5660

5761
fi
5862
echo ""
59-

logging/bin/create_openshift_route.sh

Lines changed: 57 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
# Copyright © 2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
cd "$(dirname $BASH_SOURCE)/../.."
6+
cd "$(dirname "$BASH_SOURCE")/../.." || exit 1
77
source logging/bin/common.sh
88

9-
this_script=`basename "$0"`
9+
this_script=$(basename "$0")
1010

1111
log_debug "Script [$this_script] has started [$(date)]"
1212

@@ -15,131 +15,98 @@ log_debug "Script [$this_script] has started [$(date)]"
1515
##################################
1616

1717
if [ "$OPENSHIFT_CLUSTER" != "true" ]; then
18-
if [ "${CHECK_OPENSHIFT_CLUSTER:-true}" == "true" ]; then
19-
log_error "This script should only be run on OpenShift clusters"
20-
exit 1
21-
fi
18+
if [ "${CHECK_OPENSHIFT_CLUSTER:-true}" == "true" ]; then
19+
log_error "This script should only be run on OpenShift clusters"
20+
exit 1
21+
fi
2222
fi
2323

2424
app=${1}
25-
app=$(echo "$app"| tr '[:lower:]' '[:upper:]')
25+
app=$(echo "$app" | tr '[:lower:]' '[:upper:]')
2626

2727
case "$app" in
28-
"KIBANA"|"KB")
29-
namespace="$LOG_NS"
30-
service_name="v4m-es-kibana-svc"
31-
port="kibana-svc"
32-
tls_enable="true"
33-
tls_secret="kibana-tls-secret"
34-
ingress_tls_secret="kibana-ingress-tls-secret"
35-
route_name="$service_name"
36-
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
37-
route_host=${OPENSHIFT_ROUTE_HOST_KIBANA:-v4m-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
38-
route_path="/kibana"
39-
else
40-
route_host=${OPENSHIFT_ROUTE_HOST_KIBANA:-$service_name-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
41-
route_path="/"
42-
fi
43-
;;
44-
"ELASTICSEARCH"|"ES")
45-
namespace="$LOG_NS"
46-
service_name="v4m-es-client-service"
47-
port="http"
48-
tls_enable="true"
49-
tls_secret="es-rest-tls-secret"
50-
ingress_tls_secret="elasticsearch-ingress-tls-secret"
51-
route_name="$service_name"
52-
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
53-
route_host=${OPENSHIFT_ROUTE_HOST_ELASTICSEARCH:-v4m-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
54-
route_path="/elasticsearch"
55-
else
56-
route_host=${OPENSHIFT_ROUTE_HOST_ELASTICSEARCH:-$service_name-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
57-
route_path="/"
58-
fi
59-
;;
60-
"OPENSEARCH"|"OS")
61-
namespace="$LOG_NS"
62-
service_name="v4m-search"
63-
port="http"
64-
tls_enable="true"
65-
tls_secret="es-rest-tls-secret"
66-
ingress_tls_secret="elasticsearch-ingress-tls-secret"
67-
route_name="$service_name"
68-
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
28+
"OPENSEARCH" | "OS")
29+
namespace="$LOG_NS"
30+
service_name="v4m-search"
31+
port="http"
32+
tls_enable="true"
33+
tls_secret="es-rest-tls-secret"
34+
ingress_tls_secret="elasticsearch-ingress-tls-secret"
35+
route_name="$service_name"
36+
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
6937
route_host=${OPENSHIFT_ROUTE_HOST_ELASTICSEARCH:-v4m-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
7038
route_path="/opensearch"
71-
else
39+
else
7240
route_host=${OPENSHIFT_ROUTE_HOST_ELASTICSEARCH:-$service_name-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
7341
route_path="/"
74-
fi
75-
;;
76-
"OSD"|"OPENSEARCHDASHBOARD"|"OPENSEARCHDASHBOARDS")
77-
namespace="$LOG_NS"
78-
service_name="v4m-osd"
79-
port="http"
80-
tls_enable="true"
81-
tls_secret="kibana-tls-secret"
82-
ingress_tls_secret="kibana-ingress-tls-secret"
83-
route_name="$service_name"
84-
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
42+
fi
43+
;;
44+
"OSD" | "OPENSEARCHDASHBOARD" | "OPENSEARCHDASHBOARDS")
45+
namespace="$LOG_NS"
46+
service_name="v4m-osd"
47+
port="http"
48+
tls_enable="true"
49+
tls_secret="kibana-tls-secret"
50+
ingress_tls_secret="kibana-ingress-tls-secret"
51+
route_name="$service_name"
52+
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
8553
route_host=${OPENSHIFT_ROUTE_HOST_KIBANA:-v4m-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
8654
route_path="/dashboards"
87-
else
55+
else
8856
route_host=${OPENSHIFT_ROUTE_HOST_KIBANA:-$service_name-$namespace.$OPENSHIFT_ROUTE_DOMAIN}
8957
route_path="/"
90-
fi
91-
;;
92-
""|*)
93-
log_error "Application name is invalid or missing."
94-
log_error "The APPLICATION NAME is required; valid values are: OpenSearch or OpenSearchDashboards"
95-
exit 1
96-
;;
58+
fi
59+
;;
60+
"" | *)
61+
log_error "Application name is invalid or missing."
62+
log_error "The APPLICATION NAME is required; valid values are: OpenSearch or OpenSearchDashboards"
63+
exit 1
64+
;;
9765
esac
9866

99-
if oc -n $namespace get route $route_name 2>/dev/null 1>&2; then
100-
log_info "Skipping route creation; the requested route [$route_name] already exists in the namespace [$namespace]."
101-
exit 0
67+
if oc -n "$namespace" get route $route_name > /dev/null 2>&1; then
68+
log_info "Skipping route creation; the requested route [$route_name] already exists in the namespace [$namespace]."
69+
exit 0
10270
fi
10371

10472
if [ "$tls_enable" != "true" ]; then
105-
tls_mode="edge"
73+
tls_mode="edge"
10674
else
107-
if oc -n $namespace get secret $tls_secret 2>/dev/null 1>&2; then
108-
tls_mode="reencrypt"
109-
else
110-
log_error "The specified secret [$tls_secret] does NOT exists in the namespace [$namespace]."
111-
exit 1
112-
fi
75+
if oc -n "$namespace" get secret $tls_secret > /dev/null 2>&1; then
76+
tls_mode="reencrypt"
77+
else
78+
log_error "The specified secret [$tls_secret] does NOT exists in the namespace [$namespace]."
79+
exit 1
80+
fi
11381
fi
11482

115-
oc -n $namespace create route $tls_mode $route_name \
83+
oc -n "$namespace" create route $tls_mode $route_name \
11684
--service $service_name \
11785
--port=$port \
11886
--insecure-policy=Redirect \
119-
--hostname $route_host \
87+
--hostname "$route_host" \
12088
--path $route_path
12189
rc=$?
12290

12391
if [ "$OPENSHIFT_PATH_ROUTES" == "true" ]; then
124-
oc -n $namespace annotate route $route_name "haproxy.router.openshift.io/rewrite-target=/"
92+
oc -n "$namespace" annotate route $route_name "haproxy.router.openshift.io/rewrite-target=/"
12593
fi
12694

12795
if [ "$rc" != "0" ]; then
128-
log_error "There was a problem creating the route for [$route_name]. [$rc]"
129-
exit 1
96+
log_error "There was a problem creating the route for [$route_name]. [$rc]"
97+
exit 1
13098
fi
13199

132100
if [ "$tls_enable" == "true" ]; then
133-
# identify secret containing destination CA
134-
oc -n $namespace annotate route $route_name cert-utils-operator.redhat-cop.io/destinationCA-from-secret=$tls_secret
101+
# identify secret containing destination CA
102+
oc -n "$namespace" annotate route $route_name cert-utils-operator.redhat-cop.io/destinationCA-from-secret=$tls_secret
135103
fi
136104

137-
138-
if oc -n $namespace get secret $ingress_tls_secret 2>/dev/null 1>&2; then
139-
# Add annotation to identify secret containing TLS certs
140-
oc -n $namespace annotate route $route_name cert-utils-operator.redhat-cop.io/certs-from-secret=$ingress_tls_secret
105+
if oc -n "$namespace" get secret $ingress_tls_secret > /dev/null 2>&1; then
106+
# Add annotation to identify secret containing TLS certs
107+
oc -n "$namespace" annotate route $route_name cert-utils-operator.redhat-cop.io/certs-from-secret=$ingress_tls_secret
141108
else
142-
log_debug "The ingress secret [$ingress_tls_secret] does NOT exists, omitting annotation [certs-from-secret]."
109+
log_debug "The ingress secret [$ingress_tls_secret] does NOT exists, omitting annotation [certs-from-secret]."
143110
fi
144111

145112
log_info "OpenShift Route [$route_name] has been created."

0 commit comments

Comments
 (0)