-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathsetup.sh
executable file
·1760 lines (1535 loc) · 66.5 KB
/
setup.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------------------
#
# Ranger Admin Setup Script
#
# This script will install policymanager webapplication under tomcat and also, initialize the database with ranger users/tables.
usage() {
[ "$*" ] && echo "$0: $*"
sed -n '/^##/,/^$/s/^## \{0,1\}//p' "$0"
exit 2
} 2>/dev/null
log() {
local prefix="$(date +%Y-%m-%d\ %H:%M:%S,%3N) "
echo "${prefix} $@" >> $LOGFILE
echo "${prefix} $@"
}
get_prop(){
validateProperty=$(sed '/^\#/d' $2 | grep "^$1\s*=" | tail -n 1) # for validation
if test -z "$validateProperty" ; then log "[E] '$1' not found in $2 file while getting....!!"; exit 1; fi
value=$(echo $validateProperty | cut -d "=" -f2-)
if [[ $1 == *password* ]]
then
echo $value
else
echo $value | tr -d \'\"
fi
}
get_prop_or_default() {
validateProperty=$(sed '/^\#/d' $2 | grep "^$1\s*=" | tail -n 1) # for validation
if test -z "$validateProperty" ;
then
value=$3 # default value
else
value=$(echo $validateProperty | cut -d "=" -f2-)
fi
if [[ $1 == *password* ]]
then
echo $value
else
echo $value | tr -d \'\"
fi
}
PROPFILE=${RANGER_ADMIN_CONF:-$PWD}/install.properties
if [ ! -f "${PROPFILE}" ]; then
echo "$PROPFILE file not found....!!"
exit 1;
fi
LOGFILE=$(eval echo " $(get_prop 'LOGFILE' $PROPFILE)")
PYTHON_COMMAND_INVOKER=$(get_prop 'PYTHON_COMMAND_INVOKER' $PROPFILE)
DB_FLAVOR=$(get_prop 'DB_FLAVOR' $PROPFILE)
SQL_CONNECTOR_JAR=$(get_prop 'SQL_CONNECTOR_JAR' $PROPFILE)
CONNECTION_STRING_ADDITIONAL_PARAMS=$(get_prop 'CONNECTION_STRING_ADDITIONAL_PARAMS' $PROPFILE)
db_root_user=$(get_prop 'db_root_user' $PROPFILE)
db_root_password=$(get_prop 'db_root_password' $PROPFILE)
db_host=$(get_prop 'db_host' $PROPFILE)
db_name=$(get_prop 'db_name' $PROPFILE)
db_user=$(get_prop 'db_user' $PROPFILE)
db_password=$(get_prop 'db_password' $PROPFILE)
db_ssl_enabled=$(get_prop 'db_ssl_enabled' $PROPFILE)
db_ssl_required=$(get_prop 'db_ssl_required' $PROPFILE)
db_ssl_verifyServerCertificate=$(get_prop 'db_ssl_verifyServerCertificate' $PROPFILE)
db_ssl_auth_type=$(get_prop 'db_ssl_auth_type' $PROPFILE)
db_ssl_certificate_file=$(get_prop 'db_ssl_certificate_file' $PROPFILE)
javax_net_ssl_trustStore_type=$(get_prop 'javax_net_ssl_trustStore_type' $PROPFILE)
javax_net_ssl_keyStore_type=$(get_prop 'javax_net_ssl_keyStore_type' $PROPFILE)
rangerAdmin_password=$(get_prop 'rangerAdmin_password' $PROPFILE)
rangerTagsync_password=$(get_prop 'rangerTagsync_password' $PROPFILE)
rangerUsersync_password=$(get_prop 'rangerUsersync_password' $PROPFILE)
keyadmin_password=$(get_prop 'keyadmin_password' $PROPFILE)
javax_net_ssl_keyStore=$(get_prop 'javax_net_ssl_keyStore' $PROPFILE)
javax_net_ssl_keyStorePassword=$(get_prop 'javax_net_ssl_keyStorePassword' $PROPFILE)
javax_net_ssl_trustStore=$(get_prop 'javax_net_ssl_trustStore' $PROPFILE)
javax_net_ssl_trustStorePassword=$(get_prop 'javax_net_ssl_trustStorePassword' $PROPFILE)
audit_store=$(get_prop 'audit_store' $PROPFILE)
audit_elasticsearch_urls=$(get_prop 'audit_elasticsearch_urls' $PROPFILE)
audit_elasticsearch_protocol=$(get_prop 'audit_elasticsearch_protocol' $PROPFILE)
audit_elasticsearch_port=$(get_prop 'audit_elasticsearch_port' $PROPFILE)
audit_elasticsearch_user=$(get_prop 'audit_elasticsearch_user' $PROPFILE)
audit_elasticsearch_password=$(get_prop 'audit_elasticsearch_password' $PROPFILE)
audit_elasticsearch_index=$(get_prop 'audit_elasticsearch_index' $PROPFILE)
audit_elasticsearch_bootstrap_enabled=$(get_prop 'audit_elasticsearch_bootstrap_enabled' $PROPFILE)
audit_solr_urls=$(get_prop 'audit_solr_urls' $PROPFILE)
audit_solr_user=$(get_prop 'audit_solr_user' $PROPFILE)
audit_solr_password=$(get_prop 'audit_solr_password' $PROPFILE)
audit_solr_zookeepers=$(get_prop 'audit_solr_zookeepers' $PROPFILE)
audit_cloudwatch_region=$(get_prop 'audit_cloudwatch_region' $PROPFILE)
audit_cloudwatch_log_group=$(get_prop 'audit_cloudwatch_log_group' $PROPFILE)
audit_cloudwatch_log_stream_prefix=$(get_prop 'audit_cloudwatch_log_stream_prefix' $PROPFILE)
policymgr_external_url=$(get_prop 'policymgr_external_url' $PROPFILE)
policymgr_http_enabled=$(get_prop 'policymgr_http_enabled' $PROPFILE)
policymgr_https_keystore_file=$(get_prop 'policymgr_https_keystore_file' $PROPFILE)
policymgr_https_keystore_keyalias=$(get_prop 'policymgr_https_keystore_keyalias' $PROPFILE)
policymgr_https_keystore_password=$(get_prop 'policymgr_https_keystore_password' $PROPFILE)
policymgr_supportedcomponents=$(get_prop 'policymgr_supportedcomponents' $PROPFILE)
unix_user=$(get_prop 'unix_user' $PROPFILE)
unix_user_pwd=$(get_prop 'unix_user_pwd' $PROPFILE)
unix_group=$(get_prop 'unix_group' $PROPFILE)
authentication_method=$(get_prop 'authentication_method' $PROPFILE)
remoteLoginEnabled=$(get_prop 'remoteLoginEnabled' $PROPFILE)
authServiceHostName=$(get_prop 'authServiceHostName' $PROPFILE)
authServicePort=$(get_prop 'authServicePort' $PROPFILE)
ranger_unixauth_keystore=$(get_prop 'ranger_unixauth_keystore' $PROPFILE)
ranger_unixauth_keystore_password=$(get_prop 'ranger_unixauth_keystore_password' $PROPFILE)
ranger_unixauth_truststore=$(get_prop 'ranger_unixauth_truststore' $PROPFILE)
ranger_unixauth_truststore_password=$(get_prop 'ranger_unixauth_truststore_password' $PROPFILE)
xa_ldap_url=$(get_prop 'xa_ldap_url' $PROPFILE)
xa_ldap_userDNpattern=$(get_prop 'xa_ldap_userDNpattern' $PROPFILE)
xa_ldap_groupSearchBase=$(get_prop 'xa_ldap_groupSearchBase' $PROPFILE)
xa_ldap_groupSearchFilter=$(get_prop 'xa_ldap_groupSearchFilter' $PROPFILE)
xa_ldap_groupRoleAttribute=$(get_prop 'xa_ldap_groupRoleAttribute' $PROPFILE)
xa_ldap_base_dn=$(get_prop 'xa_ldap_base_dn' $PROPFILE)
xa_ldap_bind_dn=$(get_prop 'xa_ldap_bind_dn' $PROPFILE)
xa_ldap_bind_password=$(get_prop 'xa_ldap_bind_password' $PROPFILE)
xa_ldap_referral=$(get_prop 'xa_ldap_referral' $PROPFILE)
xa_ldap_userSearchFilter=$(get_prop 'xa_ldap_userSearchFilter' $PROPFILE)
xa_ldap_ad_domain=$(get_prop 'xa_ldap_ad_domain' $PROPFILE)
xa_ldap_ad_url=$(get_prop 'xa_ldap_ad_url' $PROPFILE)
xa_ldap_ad_base_dn=$(get_prop 'xa_ldap_ad_base_dn' $PROPFILE)
xa_ldap_ad_bind_dn=$(get_prop 'xa_ldap_ad_bind_dn' $PROPFILE)
xa_ldap_ad_bind_password=$(get_prop 'xa_ldap_ad_bind_password' $PROPFILE)
xa_ldap_ad_referral=$(get_prop 'xa_ldap_ad_referral' $PROPFILE)
xa_ldap_ad_userSearchFilter=$(get_prop 'xa_ldap_ad_userSearchFilter' $PROPFILE)
XAPOLICYMGR_DIR=$(eval echo "$(get_prop 'XAPOLICYMGR_DIR' $PROPFILE)")
app_home=$(eval echo "$(get_prop 'app_home' $PROPFILE)")
TMPFILE=$(eval echo "$(get_prop 'TMPFILE' $PROPFILE)")
LOGFILES=$(eval echo "$(get_prop 'LOGFILES' $PROPFILE)")
JAVA_BIN=$(get_prop 'JAVA_BIN' $PROPFILE)
JAVA_VERSION_REQUIRED=$(get_prop 'JAVA_VERSION_REQUIRED' $PROPFILE)
JAVA_ORACLE=$(get_prop 'JAVA_ORACLE' $PROPFILE)
java_opts=$(get_prop_or_default 'java_opts' $PROPFILE '')
mysql_core_file=$(get_prop 'mysql_core_file' $PROPFILE)
mysql_audit_file=$(get_prop 'mysql_audit_file' $PROPFILE)
oracle_core_file=$(get_prop 'oracle_core_file' $PROPFILE)
oracle_audit_file=$(get_prop 'oracle_audit_file' $PROPFILE)
postgres_core_file=$(get_prop 'postgres_core_file' $PROPFILE)
postgres_audit_file=$(get_prop 'postgres_audit_file' $PROPFILE)
sqlserver_core_file=$(get_prop 'sqlserver_core_file' $PROPFILE)
sqlserver_audit_file=$(get_prop 'sqlserver_audit_file' $PROPFILE)
sqlanywhere_core_file=$(get_prop 'sqlanywhere_core_file' $PROPFILE)
sqlanywhere_audit_file=$(get_prop 'sqlanywhere_audit_file' $PROPFILE)
cred_keystore_filename=$(eval echo "$(get_prop 'cred_keystore_filename' $PROPFILE)")
sso_enabled=$(get_prop 'sso_enabled' $PROPFILE)
sso_providerurl=$(get_prop 'sso_providerurl' $PROPFILE)
sso_publickey=$(get_prop 'sso_publickey' $PROPFILE)
RANGER_ADMIN_LOG_DIR=$(eval echo "$(get_prop 'RANGER_ADMIN_LOG_DIR' $PROPFILE)")
RANGER_ADMIN_LOGBACK_CONF_FILE=$(eval echo "$(get_prop 'RANGER_ADMIN_LOGBACK_CONF_FILE' $PROPFILE)")
RANGER_PID_DIR_PATH=$(eval echo "$(get_prop 'RANGER_PID_DIR_PATH' $PROPFILE)")
spnego_principal=$(get_prop 'spnego_principal' $PROPFILE)
spnego_keytab=$(get_prop 'spnego_keytab' $PROPFILE)
token_valid=$(get_prop 'token_valid' $PROPFILE)
cookie_domain=$(get_prop 'cookie_domain' $PROPFILE)
cookie_path=$(get_prop 'cookie_path' $PROPFILE)
admin_principal=$(get_prop 'admin_principal' $PROPFILE)
admin_keytab=$(get_prop 'admin_keytab' $PROPFILE)
lookup_principal=$(get_prop 'lookup_principal' $PROPFILE)
lookup_keytab=$(get_prop 'lookup_keytab' $PROPFILE)
hadoop_conf=$(get_prop 'hadoop_conf' $PROPFILE)
audit_solr_collection_name=$(get_prop 'audit_solr_collection_name' $PROPFILE)
audit_solr_config_name=$(get_prop 'audit_solr_config_name' $PROPFILE)
audit_solr_configset_location=$(get_prop 'audit_solr_configset_location' $PROPFILE)
audit_solr_no_shards=$(get_prop 'audit_solr_no_shards' $PROPFILE)
audit_solr_no_replica=$(get_prop 'audit_solr_no_replica' $PROPFILE)
audit_solr_max_shards_per_node=$(get_prop 'audit_solr_max_shards_per_node' $PROPFILE)
audit_solr_acl_user_list_sasl=$(get_prop 'audit_solr_acl_user_list_sasl' $PROPFILE)
audit_solr_bootstrap_enabled=$(get_prop 'audit_solr_bootstrap_enabled' $PROPFILE)
xa_webapp_contextName=$(get_prop 'xa.webapp.contextName' $PROPFILE)
DB_HOST="${db_host}"
check_ret_status(){
if [ $1 -ne 0 ]; then
log "[E] $2";
exit 1;
fi
}
check_ret_status_for_groupadd(){
# 9 is the response if the group exists
if [ $1 -ne 0 ] && [ $1 -ne 9 ]; then
log "[E] $2";
exit 1;
fi
}
check_user_pwd(){
if [ -z "$1" ]; then
log "[E] The unix user password is empty. Please set user password.";
exit 1;
fi
}
is_command () {
log "[I] check if command $1 exists"
type "$1" >/dev/null
}
get_distro(){
log "[I] Checking distribution name.."
ver=$(cat /etc/*{issues,release,version} 2> /dev/null)
if [[ $(echo $ver | grep DISTRIB_ID) ]]; then
DIST_NAME=$(lsb_release -si)
elif [[ $(echo $ver | grep -E '^NAME=' | cut -d'"' -f2) ]]; then
DIST_NAME=$(echo $ver | grep -E '^NAME=' | cut -d'"' -f2)
else
DIST_NAME=$(echo $ver | cut -d ' ' -f 1 | sort -u | head -1)
fi
export $DIST_NAME
log "[I] Found distribution : $DIST_NAME"
}
#Get Properties from File without erroring out if property is not there
#$1 -> propertyName $2 -> fileName $3 -> variableName $4 -> failIfNotFound
getPropertyFromFileNoExit(){
validateProperty=$(sed '/^\#/d' $2 | grep "^$1\s*=" | tail -n 1) # for validation
if test -z "$validateProperty" ; then
log "[E] '$1' not found in $2 file while getting....!!";
if [ $4 == "true" ] ; then
exit 1;
else
value=""
fi
else
value=$(echo $validateProperty | cut -d "=" -f2-)
fi
eval $3="'$value'"
}
#Get Properties from File
#$1 -> propertyName $2 -> fileName $3 -> variableName
getPropertyFromFile(){
validateProperty=$(sed '/^\#/d' $2 | grep "^$1\s*=" | tail -n 1) # for validation
if test -z "$validateProperty" ; then log "[E] '$1' not found in $2 file while getting....!!"; exit 1; fi
value=$(echo $validateProperty | cut -d "=" -f2-)
eval $3="'$value'"
}
#Update Properties to File
#$1 -> propertyName $2 -> newPropertyValue $3 -> fileName
updatePropertyToFilePy(){
$PYTHON_COMMAND_INVOKER update_property.py $1 "${2}" $3
check_ret_status $? "Update property failed for: " $1
}
init_variables(){
curDt=`date '+%Y%m%d%H%M%S'`
VERSION=`cat ${PWD}/version`
XAPOLICYMGR_DIR=$PWD
RANGER_ADMIN_INITD=ranger-admin-initd
RANGER_ADMIN=ranger-admin
INSTALL_DIR=${XAPOLICYMGR_DIR}
WEBAPP_ROOT=${INSTALL_DIR}/ews/webapp
DB_FLAVOR=`echo $DB_FLAVOR | tr '[:lower:]' '[:upper:]'`
if [ "${DB_FLAVOR}" == "" ]
then
DB_FLAVOR="MYSQL"
fi
log "[I] DB_FLAVOR=${DB_FLAVOR}"
audit_store=`echo $audit_store | tr '[:upper:]' '[:lower:]'`
log "[I] Audit source=${audit_store}"
if [ "${audit_store}" == "solr" ] ;then
if [ "${audit_solr_urls}" == "" ] ;then
log "[I] Please provide valid URL for 'solr' audit store!"
exit 1
fi
fi
if [ "${audit_store}" == "elasticsearch" ] ;then
if [ "${audit_elasticsearch_urls}" == "" ] ;then
log "[I] Please provide valid URL for 'elasticsearch' audit store!"
exit 1
fi
if [ "${audit_elasticsearch_port}" == "" ] ;then
log "[I] Please provide valid port for 'elasticsearch' audit store!"
exit 1
fi
fi
if [ "${audit_store}" == "cloudwatch" ] ;then
if [ "${audit_cloudwatch_region}" == "" ] ;then
log "[I] Please provide valid region for 'amazon cloudwatch' audit store!"
exit 1
fi
if [ "${audit_cloudwatch_log_group}" == "" ] ;then
log "[I] Please provide valid log-group for 'amazon cloudwatch' audit store!"
exit 1
fi
fi
db_ssl_enabled=`echo $db_ssl_enabled | tr '[:upper:]' '[:lower:]'`
if [ "${db_ssl_enabled}" != "true" ]
then
db_ssl_enabled="false"
db_ssl_required="false"
db_ssl_verifyServerCertificate="false"
db_ssl_auth_type="2-way"
db_ssl_certificate_file=''
javax_net_ssl_trustStore_type='jks'
javax_net_ssl_keyStore_type='jks'
fi
if [ "${db_ssl_enabled}" == "true" ]
then
db_ssl_required=`echo $db_ssl_required | tr '[:upper:]' '[:lower:]'`
db_ssl_verifyServerCertificate=`echo $db_ssl_verifyServerCertificate | tr '[:upper:]' '[:lower:]'`
db_ssl_auth_type=`echo $db_ssl_auth_type | tr '[:upper:]' '[:lower:]'`
javax_net_ssl_trustStore_type=`echo $javax_net_ssl_trustStore_type | tr '[:upper:]' '[:lower:]'`
javax_net_ssl_keyStore_type=`echo $javax_net_ssl_keyStore_type | tr '[:upper:]' '[:lower:]'`
if [ "${db_ssl_required}" != "true" ]
then
db_ssl_required="false"
fi
if [ "${db_ssl_verifyServerCertificate}" != "true" ]
then
db_ssl_verifyServerCertificate="false"
fi
if [ "${db_ssl_auth_type}" != "1-way" ]
then
db_ssl_auth_type="2-way"
fi
if [ "${javax_net_ssl_trustStore_type}" == "" ]
then
javax_net_ssl_trustStore_type="jks"
fi
if [ "${javax_net_ssl_keyStore_type}" == "" ]
then
javax_net_ssl_keyStore_type="jks"
fi
fi
}
check_python_command() {
if is_command ${PYTHON_COMMAND_INVOKER} ; then
log "[I] '${PYTHON_COMMAND_INVOKER}' command found"
else
log "[E] '${PYTHON_COMMAND_INVOKER}' command not found"
exit 1;
fi
}
run_dba_steps(){
getPropertyFromFileNoExit 'setup_mode' $PROPFILE setup_mode false
if [ "x${setup_mode}x" == "xSeparateDBAx" ]; then
log "[I] Setup mode is set to SeparateDBA. Not Running DBA steps. Please run dba_script.py before running setup..!";
else
log "[I] Setup mode is not set. Running DBA steps..";
$PYTHON_COMMAND_INVOKER dba_script.py -q
fi
}
check_ranger_version(){
$PYTHON_COMMAND_INVOKER db_setup.py -checkupgrade
}
check_db_connector() {
log "[I] Checking ${DB_FLAVOR} CONNECTOR FILE : ${SQL_CONNECTOR_JAR}"
if test -f "$SQL_CONNECTOR_JAR"; then
log "[I] ${DB_FLAVOR} CONNECTOR FILE : $SQL_CONNECTOR_JAR file found"
else
log "[E] ${DB_FLAVOR} CONNECTOR FILE : $SQL_CONNECTOR_JAR does not exists" ; exit 1;
fi
}
check_java_version() {
#Check for JAVA_HOME
if [ "${JAVA_HOME}" == "" ]
then
log "[E] JAVA_HOME environment property not defined, aborting installation."
exit 1
fi
export JAVA_BIN=${JAVA_HOME}/bin/java
if is_command ${JAVA_BIN} ; then
log "[I] '${JAVA_BIN}' command found"
else
log "[E] '${JAVA_BIN}' command not found"
exit 1;
fi
version=$("$JAVA_BIN" -version 2>&1 | awk -F '"' '/version/ {print $2}')
major=`echo ${version} | cut -d. -f1`
minor=`echo ${version} | cut -d. -f2`
current_java_version="$major.$minor"
num_current_java_version=`echo $current_java_version|awk ' { printf("%3.2f\n", $0); } '`
JAVA_VERSION_REQUIRED=`echo $JAVA_VERSION_REQUIRED | awk '{gsub(/ /,"")}1'`
JAVA_VERSION_REQUIRED=`echo $JAVA_VERSION_REQUIRED | awk '{gsub(/'"'"'/,"")}1'`
num_required_java_version=`echo $JAVA_VERSION_REQUIRED|awk ' { printf("%3.2f\n", $0); } '`
if [ `echo "$num_current_java_version < $num_required_java_version" | bc` -eq 1 ];then
log "[E] The java version must be greater than or equal to $JAVA_VERSION_REQUIRED, the current java version is $version"
exit 1;
fi
if [[ ${JAVA_OPTS} == "" ]] ;then export JAVA_OPTS="${java_opts}" ;fi
}
sanity_check_files() {
if test -d $app_home; then
log "[I] $app_home folder found"
else
log "[E] $app_home does not exists" ; exit 1;
fi
if [ "${DB_FLAVOR}" == "MYSQL" ]
then
if test -f $mysql_core_file; then
log "[I] $mysql_core_file file found"
else
log "[E] $mysql_core_file does not exists" ; exit 1;
fi
fi
if [ "${DB_FLAVOR}" == "ORACLE" ]
then
if test -f ${oracle_core_file}; then
log "[I] ${oracle_core_file} file found"
else
log "[E] ${oracle_core_file} does not exists" ; exit 1;
fi
fi
if [ "${DB_FLAVOR}" == "POSTGRES" ]
then
if test -f ${postgres_core_file}; then
log "[I] ${postgres_core_file} file found"
else
log "[E] ${postgres_core_file} does not exists" ; exit 1;
fi
fi
if [ "${DB_FLAVOR}" == "MSSQL" ]
then
if test -f ${sqlserver_core_file}; then
log "[I] ${sqlserver_core_file} file found"
else
log "[E] ${sqlserver_core_file} does not exists" ; exit 1;
fi
fi
if [ "${DB_FLAVOR}" == "SQLA" ]
then
if [ "${LD_LIBRARY_PATH}" == "" ]
then
log "[E] LD_LIBRARY_PATH environment property not defined, aborting installation."
exit 1
fi
if test -f ${sqlanywhere_core_file}; then
log "[I] ${sqlanywhere_core_file} file found"
else
log "[E] ${sqlanywhere_core_file} does not exists" ; exit 1;
fi
fi
}
create_rollback_point() {
DATE=`date`
BAK_FILE=$APP-$VERSION.$DATE.bak
log "Creating backup file : $BAK_FILE"
cp "$APP" "$BAK_FILE"
}
copy_db_connector(){
log "[I] Copying ${DB_FLAVOR} Connector to $app_home/WEB-INF/lib ";
cp -f $SQL_CONNECTOR_JAR $app_home/WEB-INF/lib
check_ret_status $? "Copying ${DB_FLAVOR} Connector to $app_home/WEB-INF/lib failed"
log "[I] Copying ${DB_FLAVOR} Connector to $app_home/WEB-INF/lib DONE";
}
update_properties() {
newPropertyValue=''
echo "export JAVA_HOME=${JAVA_HOME}" > ${WEBAPP_ROOT}/WEB-INF/classes/conf/java_home.sh
chmod a+rx ${WEBAPP_ROOT}/WEB-INF/classes/conf/java_home.sh
to_file_ranger=$app_home/WEB-INF/classes/conf/ranger-admin-site.xml
if test -f $to_file_ranger; then
log "[I] $to_file_ranger file found"
else
log "[E] $to_file_ranger does not exists" ; exit 1;
fi
to_file_default=$app_home/WEB-INF/classes/conf/ranger-admin-default-site.xml
if test -f $to_file_default; then
log "[I] $to_file_default file found"
else
log "[E] $to_file_default does not exists" ; exit 1;
fi
if [ "${spnego_principal}" != "" ]
then
propertyName=ranger.spnego.kerberos.principal
newPropertyValue="${spnego_principal}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_collection_name}" != "" ]
then
propertyName=ranger.audit.solr.collection.name
newPropertyValue="${audit_solr_collection_name}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_config_name}" != "" ]
then
propertyName=ranger.audit.solr.config.name
newPropertyValue="${audit_solr_config_name}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_configset_location}" != "" ]
then
propertyName=ranger.audit.solr.configset.location
newPropertyValue="${audit_solr_configset_location}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_no_shards}" != "" ]
then
propertyName=ranger.audit.solr.no.shards
newPropertyValue="${audit_solr_no_shards}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_max_shards_per_node}" != "" ]
then
propertyName=ranger.audit.solr.max.shards.per.node
newPropertyValue="${audit_solr_max_shards_per_node}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_no_replica}" != "" ]
then
propertyName=ranger.audit.solr.no.replica
newPropertyValue="${audit_solr_no_replica}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_acl_user_list_sasl}" != "" ]
then
propertyName=ranger.audit.solr.acl.user.list.sasl
newPropertyValue="${audit_solr_acl_user_list_sasl}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${spnego_keytab}" != "" ]
then
propertyName=ranger.spnego.kerberos.keytab
newPropertyValue="${spnego_keytab}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${token_valid}" != "" ]
then
propertyName=ranger.admin.kerberos.token.valid.seconds
newPropertyValue="${token_valid}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${cookie_domain}" != "" ]
then
propertyName=ranger.admin.kerberos.cookie.domain
newPropertyValue="${cookie_domain}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${cookie_path}" != "" ]
then
propertyName=ranger.admin.kerberos.cookie.path
newPropertyValue="${cookie_path}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${admin_principal}" != "" ]
then
propertyName=ranger.admin.kerberos.principal
newPropertyValue="${admin_principal}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${admin_keytab}" != "" ]
then
propertyName=ranger.admin.kerberos.keytab
newPropertyValue="${admin_keytab}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${lookup_principal}" != "" ]
then
propertyName=ranger.lookup.kerberos.principal
newPropertyValue="${lookup_principal}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${lookup_keytab}" != "" ]
then
propertyName=ranger.lookup.kerberos.keytab
newPropertyValue="${lookup_keytab}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${xa_webapp_contextName}" != "" ]
then
propertyName=ranger.contextName
newPropertyValue="${xa_webapp_contextName}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
fi
if [ "${db_ssl_enabled}" != "" ]
then
propertyName=ranger.db.ssl.enabled
newPropertyValue="${db_ssl_enabled}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.db.ssl.required
newPropertyValue="${db_ssl_required}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.db.ssl.verifyServerCertificate
newPropertyValue="${db_ssl_verifyServerCertificate}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.db.ssl.auth.type
newPropertyValue="${db_ssl_auth_type}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
if [ "${db_ssl_certificate_file}" != "" ]
then
propertyName=ranger.db.ssl.certificateFile
newPropertyValue="${db_ssl_certificate_file}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
fi
propertyName=ranger.truststore.file.type
newPropertyValue="${javax_net_ssl_trustStore_type}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.keystore.file.type
newPropertyValue="${javax_net_ssl_keyStore_type}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
fi
if [ "${DB_FLAVOR}" == "MYSQL" ]
then
propertyName=ranger.jpa.jdbc.url
newPropertyValue="jdbc:log4jdbc:mysql://${DB_HOST}/${db_name}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.MySQLPlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.audit.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.MySQLPlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.driver
newPropertyValue="net.sf.log4jdbc.DriverSpy"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.audit.jdbc.driver
newPropertyValue="net.sf.log4jdbc.DriverSpy"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.preferredtestquery
newPropertyValue="select 1"
updatePropertyToFilePy $propertyName "${newPropertyValue}" $to_file_default
fi
if [ "${DB_FLAVOR}" == "ORACLE" ]
then
propertyName=ranger.jpa.jdbc.url
count=$(grep -o ":" <<< "$DB_HOST" | wc -l)
#if [[ ${count} -eq 2 ]] ; then
if [ ${count} -eq 2 ] || [ ${count} -eq 0 ]; then
#jdbc:oracle:thin:@[HOST][:PORT]:SID or #jdbc:oracle:thin:@GL
newPropertyValue="jdbc:oracle:thin:@${DB_HOST}"
else
#jdbc:oracle:thin:@//[HOST][:PORT]/SERVICE
newPropertyValue="jdbc:oracle:thin:@//${DB_HOST}"
fi
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.OraclePlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.audit.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.OraclePlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.driver
newPropertyValue="oracle.jdbc.OracleDriver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.audit.jdbc.driver
newPropertyValue="oracle.jdbc.OracleDriver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.preferredtestquery
newPropertyValue="select 1 from dual"
updatePropertyToFilePy $propertyName "${newPropertyValue}" $to_file_default
fi
if [ "${DB_FLAVOR}" == "POSTGRES" ]
then
if [ "${db_ssl_enabled}" == "true" ]
then
if test -f $db_ssl_certificate_file; then
propertyName=ranger.jpa.jdbc.url
newPropertyValue="jdbc:postgresql://${DB_HOST}/${db_name}?ssl=true&sslmode=verify-full&sslrootcert=${db_ssl_certificate_file}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
else
propertyName=ranger.jpa.jdbc.url
newPropertyValue="jdbc:postgresql://${DB_HOST}/${db_name}?ssl=true&sslmode=verify-full&sslfactory=org.postgresql.ssl.DefaultJavaSSLFactory"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
else
propertyName=ranger.jpa.jdbc.url
newPropertyValue="jdbc:postgresql://${DB_HOST}/${db_name}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
propertyName=ranger.jpa.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.PostgreSQLPlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.audit.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.PostgreSQLPlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.driver
newPropertyValue="org.postgresql.Driver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.audit.jdbc.driver
newPropertyValue="org.postgresql.Driver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.preferredtestquery
newPropertyValue="select 1"
updatePropertyToFilePy $propertyName "${newPropertyValue}" $to_file_default
fi
if [ "${DB_FLAVOR}" == "MSSQL" ]
then
propertyName=ranger.jpa.jdbc.url
if [ "${CONNECTION_STRING_ADDITIONAL_PARAMS}" != "" ]
then
newPropertyValue="jdbc:sqlserver://${DB_HOST};databaseName=${db_name};${CONNECTION_STRING_ADDITIONAL_PARAMS}"
else
newPropertyValue="jdbc:sqlserver://${DB_HOST};databaseName=${db_name}"
fi
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.SQLServerPlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.audit.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.SQLServerPlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.driver
newPropertyValue="com.microsoft.sqlserver.jdbc.SQLServerDriver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.audit.jdbc.driver
newPropertyValue="com.microsoft.sqlserver.jdbc.SQLServerDriver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.preferredtestquery
newPropertyValue="select 1"
updatePropertyToFilePy $propertyName "${newPropertyValue}" $to_file_default
fi
if [ "${DB_FLAVOR}" == "SQLA" ]
then
propertyName=ranger.jpa.jdbc.url
newPropertyValue="jdbc:sqlanywhere:database=${db_name};host=${DB_HOST}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.SQLAnywherePlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.audit.jdbc.dialect
newPropertyValue="org.eclipse.persistence.platform.database.SQLAnywherePlatform"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.driver
newPropertyValue="sap.jdbc4.sqlanywhere.IDriver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.audit.jdbc.driver
newPropertyValue="sap.jdbc4.sqlanywhere.IDriver"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.preferredtestquery
newPropertyValue="select 1"
updatePropertyToFilePy $propertyName "${newPropertyValue}" $to_file_default
fi
if [ "${audit_store}" == "solr" ]
then
propertyName=ranger.audit.solr.urls
newPropertyValue=${audit_solr_urls}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.solr.bootstrap.enabled
newPropertyValue=${audit_solr_bootstrap_enabled}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_store}" == "elasticsearch" ]
then
propertyName=ranger.audit.elasticsearch.urls
newPropertyValue=${audit_elasticsearch_urls}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.elasticsearch.protocol
newPropertyValue=${audit_elasticsearch_protocol}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.elasticsearch.port
newPropertyValue=${audit_elasticsearch_port}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.elasticsearch.user
newPropertyValue=${audit_elasticsearch_user}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.elasticsearch.password
newPropertyValue=${audit_elasticsearch_password}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.elasticsearch.index
newPropertyValue=${audit_elasticsearch_index}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.elasticsearch.bootstrap.enabled
newPropertyValue=${audit_elasticsearch_bootstrap_enabled}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_store}" == "cloudwatch" ]
then
propertyName=ranger.audit.amazon_cloudwatch.region
newPropertyValue=${audit_cloudwatch_region}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.amazon_cloudwatch.log_group
newPropertyValue=${audit_cloudwatch_log_group}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.audit.amazon_cloudwatch.log_stream_prefix
newPropertyValue=${audit_cloudwatch_log_stream_prefix}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_store}" != "" ]
then
propertyName=ranger.audit.source.type
newPropertyValue=${audit_store}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
propertyName=ranger.externalurl
newPropertyValue="${policymgr_external_url}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.service.http.enabled
newPropertyValue="${policymgr_http_enabled}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.supportedcomponents
newPropertyValue="${policymgr_supportedcomponents}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.jdbc.user
newPropertyValue="${db_user}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
##########
keystore="${cred_keystore_filename}"
echo "Starting configuration for Ranger DB credentials:"
db_password_alias=ranger.db.password
if [ "${keystore}" != "" ]
then
mkdir -p `dirname "${keystore}"`
$PYTHON_COMMAND_INVOKER ranger_credential_helper.py -l "cred/lib/*" -f "$keystore" -k "$db_password_alias" -v "$db_password" -c 1
propertyName=ranger.credential.provider.path
newPropertyValue="${keystore}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.jpa.jdbc.credential.alias
newPropertyValue="${db_password_alias}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.credential.provider.path
newPropertyValue="${keystore}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
propertyName=ranger.jpa.jdbc.password
newPropertyValue="_"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
if test -f "${keystore}"; then
#echo "$keystore found."
chown -R ${unix_user}:${unix_group} ${keystore}
chmod 640 ${keystore}
else
propertyName=ranger.jpa.jdbc.password
newPropertyValue="${db_password}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
else
propertyName=ranger.jpa.jdbc.password
newPropertyValue="${db_password}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
###########
if [ "${audit_store}" == "solr" ]
then
if [ "${audit_solr_zookeepers}" != "" ]
then
propertyName=ranger.audit.solr.zookeepers
newPropertyValue=${audit_solr_zookeepers}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
if [ "${audit_solr_user}" != "" ] && [ "${audit_solr_password}" != "" ]
then
propertyName=ranger.solr.audit.user
newPropertyValue=${audit_solr_user}
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
if [ "${keystore}" != "" ]
then
echo "Starting configuration for solr credentials:"
mkdir -p `dirname "${keystore}"`
audit_solr_password_alias=ranger.solr.password
$PYTHON_COMMAND_INVOKER ranger_credential_helper.py -l "cred/lib/*" -f "$keystore" -k "$audit_solr_password_alias" -v "$audit_solr_password" -c 1
propertyName=ranger.solr.audit.credential.alias
newPropertyValue="${audit_solr_password_alias}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_default
propertyName=ranger.solr.audit.user.password
newPropertyValue="_"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
if test -f "${keystore}"; then
chown -R ${unix_user}:${unix_group} ${keystore}
else
propertyName=ranger.solr.audit.user.password
newPropertyValue="${audit_solr_password}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
else
propertyName=ranger.solr.audit.user.password
newPropertyValue="${audit_solr_password}"
updatePropertyToFilePy $propertyName $newPropertyValue $to_file_ranger
fi
fi
fi
if [ "${sso_enabled}" == "" ]
then
sso_enabled="false"
fi
sso_enabled=`echo $sso_enabled | tr '[:upper:]' '[:lower:]'`
if [ "${sso_enabled}" == "true" ]
then
if [ "${sso_providerurl}" == "" ] || [ "${sso_publickey}" == "" ]
then
log "[E] Please provide valid values in SSO config properties!";
exit 1
fi