11#! /bin/bash
22
3- # Copyright  © 2021, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3+ # 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
77source logging/bin/common.sh
88
99source logging/bin/apiaccess-include.sh
1010source logging/bin/secrets-include.sh
1111source logging/bin/rbac-include.sh
1212
13- this_script=` basename " $0 " `
13+ this_script=$( basename " $0 " )
1414
1515
1616function show_usage {
@@ -44,7 +44,7 @@ POS_PARMS=""
4444while (( "$# " )) ; do
4545 case " $1 " in
4646 -ns|--namespace)
47- if [ -n " $2 " ] && [ ${2: 0: 1} != " -" ]; then
47+ if [ -n " $2 " ] && [ " ${2: 0: 1} " != " -" ]; then
4848 namespace=$2
4949 shift 2
5050 else
@@ -54,7 +54,7 @@ while (( "$#" )); do
5454 fi
5555 ;;
5656 -t|--tenant)
57- if [ -n " $2 " ] && [ ${2: 0: 1} != " -" ]; then
57+ if [ -n " $2 " ] && [ " ${2: 0: 1} " != " -" ]; then
5858 tenant=$2
5959 shift 2
6060 else
@@ -64,7 +64,7 @@ while (( "$#" )); do
6464 fi
6565 ;;
6666 -u|--user)
67- if [ -n " $2 " ] && [ ${2: 0: 1} != " -" ]; then
67+ if [ -n " $2 " ] && [ " ${2: 0: 1} " != " -" ]; then
6868 createuser=true
6969 inituser=$2
7070 shift 2
@@ -75,7 +75,7 @@ while (( "$#" )); do
7575 fi
7676 ;;
7777 -p|--password)
78- if [ -n " $2 " ] && [ ${2: 0: 1} != " -" ]; then
78+ if [ -n " $2 " ] && [ " ${2: 0: 1} " != " -" ]; then
7979 initpasswd=$2
8080 shift 2
8181 else
124124validateNamespace " $namespace "
125125
126126if [ -n " $tenant " ]; then
127- validateTenantID $tenant
127+ validateTenantID " $tenant "
128128
129129 nst=" ${namespace} _${tenant} "
130130 index_nst=" ${namespace} -__${tenant} __"
131131else
132132 nst=" $namespace "
133+ # shellcheck disable=SC2034
133134 index_nst=" ${namespace} "
134135fi
135136
175176get_kb_api_url
176177
177178# Import appropriate content into OpenSearch Dashboards tenant space
178- ./logging/bin/import_osd_content.sh logging/osd/common $ktenant
179+ ./logging/bin/import_osd_content.sh logging/osd/common " $ktenant "
179180
180181if [ -z " $tenant " ]; then
181- ./logging/bin/import_osd_content.sh logging/osd/namespace $ktenant
182+ ./logging/bin/import_osd_content.sh logging/osd/namespace " $ktenant "
182183else
183- ./logging/bin/import_osd_content.sh logging/osd/tenant $ktenant
184+ ./logging/bin/import_osd_content.sh logging/osd/tenant " $ktenant "
184185fi
185186
186187if [ -d " $USER_DIR /logging/osd" ] && [ " $USER_DIR " != " $( pwd) " ]; then
187188
188189 export IGNORE_NOT_FOUND=" true"
189- ./logging/bin/import_osd_content.sh $USER_DIR /logging/osd/common $ktenant
190+ ./logging/bin/import_osd_content.sh " $USER_DIR " /logging/osd/common " $ktenant "
190191
191192 if [ -z " $tenant " ]; then
192- ./logging/bin/import_osd_content.sh $USER_DIR /logging/osd/namespace $ktenant
193+ ./logging/bin/import_osd_content.sh " $USER_DIR " /logging/osd/namespace " $ktenant "
193194 else
194- ./logging/bin/import_osd_content.sh $USER_DIR /logging/osd/tenant $ktenant
195+ ./logging/bin/import_osd_content.sh " $USER_DIR " /logging/osd/tenant " $ktenant "
195196 fi
196197 unset IGNORE_NOT_FOUND
197198fi
198199
199200# Create access controls
200- ./logging/bin/security_create_rbac.sh $namespace $tenant
201+ ./logging/bin/security_create_rbac.sh " $namespace " " $tenant "
201202
202203# Create an initial user
203204if [ " $createuser " == " true" ]; then
@@ -215,15 +216,15 @@ if [ "$createuser" == "true" ]; then
215216 passwdarg=" "
216217 fi
217218
218- if user_exists $inituser ; then
219+ if user_exists " $inituser " ; then
219220 log_warn " A user with the requested user name of [$inituser ] already exists; the initial user account you requested was NOT created."
220221 log_warn " This existing user may have completely different access controls than you intended for the initial user."
221222 log_warn " You can create a new user with the appropriate access controls by calling the logging/bin/user.sh script directly."
222223 else
223224 if [ -z " $tenant " ]; then
224- ./logging/bin/user.sh CREATE -ns $namespace -u $inituser $passwdarg
225+ ./logging/bin/user.sh CREATE -ns " $namespace " -u " $inituser " " $passwdarg "
225226 else
226- ./logging/bin/user.sh CREATE -ns $namespace -t $tenant -u $inituser $passwdarg
227+ ./logging/bin/user.sh CREATE -ns " $namespace " -t " $tenant " -u " $inituser " " $passwdarg "
227228 fi
228229 fi
229230else
0 commit comments