-
Notifications
You must be signed in to change notification settings - Fork 11
/
start.sh
executable file
·1118 lines (982 loc) · 42.6 KB
/
start.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
#
# do not delete this comment --> m4_ignore([
die()
{
local _ret=$2
test -n "$_ret" || _ret=1
test "$_PRINT_HELP" = yes && print_help >&2
echo "$1" >&2
exit ${_ret}
}
warn()
{
test -n "$_ret" || _ret=1
test "$_PRINT_HELP" = yes && print_help >&2
echo "$1" >&2
}
begins_with_short_option()
{
local first_option all_short_options='cPupadsbh'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_use_encoded_credentials=false
_arg_controller_host=
_arg_controller_port=8090
_arg_use_https=false
_arg_account="customer1"
_arg_username=
_arg_password=
_arg_use_proxy=false
_arg_proxy_url=
_arg_proxy_port=
_arg_application_name=
_arg_configure_bt=false
_arg_bt_only=false
_arg_health_rules_only=false
_arg_health_rules_overwrite=true
_arg_health_rules_delete=
_arg_use_branding=true
_arg_logo_name=
_arg_background_name=
_arg_suppress_action=false
_arg_suppress_start=
_arg_suppress_duration=
_arg_suppress_upload_files=false
_arg_suppress_name=
_arg_suppress_delete=
_arg_upload_custom_dashboard=false
_arg_upload_default_dashboard=true
_arg_include_database=false
_arg_database_name=
_arg_include_sim=false
_valid_rbac_actions=("role-saml" "license-rule") # array of valid rbac actions e.g. ("role" "role-saml" "saml")
_arg_rbac_only=false
_arg_rbac_action="role-saml" # the only action for now in rbac module is "role-saml"
_arg_rbac_role_name=
_arg_rbac_role_description=
_arg_rbac_saml_group_name=
_arg_rbac_license_rule_name=
_arg_debug=false
_arg_controller_port_explicitly_set=false
_arg_use_encoded_credentials_explicitly_set=false
_arg_use_https_explicitly_set=false
_arg_account_explicitly_set=false
_arg_use_proxy_explicitly_set=false
_arg_include_database_explicitly_set=false
_arg_include_sim_explicitly_set=false
_arg_configure_bt_explicitly_set=false
_arg_use_branding_explicitly_set=false
_arg_bt_only_explicitly_set=false
_arg_suppress_action_explicitly_set=false
_arg_suppress_upload_files_explicitly_set=false
_arg_upload_default_dashboard_explicitly_set=false
_arg_upload_custom_dashboard_explicitly_set=false
_arg_health_rules_only_explicitly_set=false
_arg_health_rules_overwrite_explicitly_set=false
_arg_rbac_only_explicitly_set=false
_arg_rbac_action_explicitly_set=false
print_help()
{
printf '%s\n' "ConfigMyApp - Self-service configuration tool."
#printf 'Usage: %s [-c|--controller-host <arg>] [-P|--controller-port <arg>] [-u|--username <arg>] [-p|--password <arg>] [--(no-)use-proxy] [--proxy-url <arg>] [--proxy-port <arg>] [-a|--application-name <arg>] [--(no-)include-database] [-d|--database-name <arg>] [-s|--(no-)include-sim] [-b|--(no-)configure-bt] [-h|--help]\n' "$0"
printf '%s\n' ""
printf '%s\n' "Connection options:"
printf '\t%s\n' "-c, --controller-host: controller host (no default)"
printf '\t%s\n' "-P, --controller-port: controller port (${_arg_controller_port} by default)"
printf '\t%s\n' "--use-https, --no-use-https: if on, specifies that the agent should use SSL (${_arg_use_https} by default)"
printf '%s\n' "Account options:"
printf '\t%s\n' "--account: account help (${_arg_account} by default)"
printf '\t%s\n' "-u, --username: AppDynamics' user username (no default)"
printf '\t%s\n' "-p, --password: AppDynamics' user password (no default)"
printf '\t%s\n' "--use-encoded-credentials, --no-use-encoded-credentials: use encoded credentials (${_arg_use_encoded_credentials} by default)"
printf '%s\n' "Proxy options:"
printf '\t%s\n' "--use-proxy, --no-use-proxy: use proxy optional argument (${_arg_use_proxy} by default)"
printf '\t%s\n' "--proxy-url: proxy url (no default)"
printf '\t%s\n' "--proxy-port: proxy port (no default)"
printf '%s\n' "Branding options:"
printf '\t%s\n' "--use-branding, --no-use-branding: enable branding (${_arg_use_branding} by default)"
printf '\t%s\n' "--logo-name: logo image file name (no default)"
printf '\t%s\n' "--background-name: background image file name (no default)"
printf '%s\n' "Application options:"
printf '\t%s\n' "-a, --application-name: application name (no default)"
#todo --configure-bt flag to be depreciated
printf '\t%s\n' "-b, --configure-bt, --no-configure-bt: configure busness transactions (${_arg_configure_bt} by default)"
printf '\t%s\n' "--bt-only, --no-bt-only: Configure business transactions only (${_arg_bt_only} by default)"
printf '%s\n' "Health rules options:"
printf '\t%s\n' "--health-rules-only, --no-health-rules-only: configure health rules only (${_arg_health_rules_only} by default)"
printf '\t%s\n' "--health-rules-overwrite, --no-health-rules-overwrite: overwrite health rules if exist (${_arg_health_rules_overwrite} by default)"
printf '\t%s\n' "--health-rules-delete: health rule names to delete, array of strings (no default)"
printf '\t%s\n' "-s, --include-sim, --no-include-sim: include server visibility (${_arg_include_sim} by default)"
printf '%s\n' "Action suppression options:"
printf '\t%s\n' "--suppress-action, --no-suppress-action: use application action suppression (${_arg_suppress_action} by default)"
printf '\t%s\n' "--suppress-start: application suppression start date in \"yyyy-MM-ddThh:mm:ss+0000\" format (GMT) (current datetime by default)"
printf '\t%s\n' "--suppress-duration: application suppression duration in minutes (one hour by default)"
printf '\t%s\n' "--suppress-name: custom name of the supression action, if none specified name is auto-generated"
printf '\t%s\n' "--suppress-upload-files, --no-suppress-upload-files: upload action suppression files from a folder (${_arg_suppress_upload_files} by default)"
printf '\t%s\n' "--suppress-delete: delete action suppression by passing action name to this parameter (no default)"
printf '%s\n' "Dashboard options:"
printf '\t%s\n' "--upload-custom-dashboard, --no-upload-custom-dashboard: creates custom dashboard(s) from a file (${_arg_upload_custom_dashboard} by default)"
printf '\t%s\n' "--upload-default-dashboard, --no-upload-default-dashboard: creates default dashboard (${_arg_upload_default_dashboard} by default)"
printf '\t%s\n' "--include-database, --no-include-database: set true to include database (${_arg_include_database} by default)"
printf '\t%s\n' "-d, --database-name: mandatory if --include-database set to true (no default)"
printf '\t%s\n' "-s, --include-sim, --no-include-sim: include server visibility (${_arg_include_sim} by default)"
printf '%s\n' "Role-Based Access Control (RBAC) options:"
printf '\t%s\n' "--rbac-only, --no-rbac-only: configure RBAC (${_arg_rbac_only} by default)"
printf '\t%s\n' "--rbac-action: RBAC action to be performed ('${_arg_rbac_action}' by default)"
printf '\t%s\n' "--rbac-role-name: RBAC role name (auto-generated by default)"
printf '\t%s\n' "--rbac-role-description: RBAC role description, not mandatory (no default)"
printf '\t%s\n' "--rbac-saml-group-name: RBAC SAML group name (auto-generated by default)"
printf '\t%s\n' "--rbac-license-rule-name: License rule name (auto-generated by default)"
printf '%s\n' "Help options:"
printf '\t%s\n' "-h, --help: Prints help"
printf '\t%s\n' "--debug, --no-debug: Run in debug mode (${_arg_debug} by default)"
printf '%s\n' ""
}
parse_commandline()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
--no-use-encoded-credentials|--use-encoded-credentials)
_arg_use_encoded_credentials_explicitly_set=true
_arg_use_encoded_credentials=true
test "${1:0:5}" = "--no-" && _arg_use_encoded_credentials=false
;;
--no-bt-only|--bt-only)
_arg_bt_only_explicitly_set=true
_arg_bt_only=true
test "${1:0:5}" = "--no-" && _arg_bt_only=false
;;
-c|--controller-host)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_controller_host="$2"
shift
;;
--controller-host=*)
_arg_controller_host="${_key##--controller-host=}"
;;
-c*)
_arg_controller_host="${_key##-c}"
;;
-P|--controller-port)
_arg_controller_port_explicitly_set=true
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_controller_port="$2"
shift
;;
--controller-port=*)
_arg_controller_port_explicitly_set=true
_arg_controller_port="${_key##--controller-port=}"
;;
-P*)
_arg_controller_port_explicitly_set=true
_arg_controller_port="${_key##-P}"
;;
--account)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_account="$2"
shift
;;
--account=*)
_arg_account_explicitly_set=true
_arg_account="${_key##--account=}"
;;
--no-use-https|--use-https)
_arg_use_https_explicitly_set=true
_arg_use_https=true
test "${1:0:5}" = "--no-" && _arg_use_https=false
;;
-u|--username)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_username="$2"
shift
;;
--username=*)
_arg_username="${_key##--username=}"
;;
-u*)
_arg_username="${_key##-u}"
;;
-p|--password)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_password="$2"
shift
;;
--password=*)
_arg_password="${_key##--password=}"
;;
-p*)
_arg_password="${_key##-p}"
;;
--no-use-proxy|--use-proxy)
_arg_use_proxy=true
_arg_use_proxy_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_use_proxy=false
;;
--proxy-url)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_proxy_url="$2"
shift
;;
--proxy-url=*)
_arg_proxy_url="${_key##--proxy-url=}"
;;
--proxy-port)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_proxy_port="$2"
shift
;;
--proxy-port=*)
_arg_proxy_port="${_key##--proxy-port=}"
;;
-a|--application-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_application_name="$2"
shift
;;
--application-name=*)
_arg_application_name="${_key##--application-name=}"
;;
-a*)
_arg_application_name="${_key##-a}"
;;
--no-include-database|--include-database)
_arg_include_database=true
_arg_include_database_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_include_database=false
;;
-d|--database-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_database_name="$2"
shift
;;
--database-name=*)
_arg_database_name="${_key##--database-name=}"
;;
-d*)
_arg_database_name="${_key##-d}"
;;
-s|--no-include-sim|--include-sim)
_arg_include_sim=true
_arg_include_sim_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_include_sim=false
;;
-s*)
_arg_include_sim=true
_next="${_key##-s}"
if test -n "$_next" -a "$_next" != "$_key"
then
{ begins_with_short_option "$_next" && shift && set -- "-s" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
fi
;;
-b|--no-configure-bt|--configure-bt)
_arg_configure_bt=true
_arg_configure_bt_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_configure_bt=false
;;
-b*)
_arg_configure_bt=true
_next="${_key##-b}"
if test -n "$_next" -a "$_next" != "$_key"
then
{ begins_with_short_option "$_next" && shift && set -- "-b" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
fi
;;
--no-use-branding|--use-branding)
_arg_use_branding=true
_arg_use_branding_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_use_branding=false
;;
--logo-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_logo_name="$2"
shift
;;
--logo-name=*)
_arg_logo_name="${_key##--logo-name=}"
;;
--background-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_background_name="$2"
shift
;;
--background-name=*)
_arg_background_name="${_key##--background-name=}"
;;
--no-health-rules-only|--health-rules-only)
_arg_health_rules_only=true
_arg_health_rules_only_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_health_rules_only=false
;;
--no-overwrite-health-rules|--overwrite-health-rules)
_arg_health_rules_overwrite=true
_arg_health_rules_overwrite_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_health_rules_overwrite=false
;;
--no-health-rules-overwrite|--health-rules-overwrite)
_arg_health_rules_overwrite=true
_arg_health_rules_overwrite_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_health_rules_overwrite=false
;;
--health-rules-delete)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_health_rules_delete="$2"
shift
;;
--health-rules-delete=*)
_arg_health_rules_delete="${_key##--health-rules-delete=}"
;;
--no-suppress-action|--suppress-action)
_arg_suppress_action=true
_arg_suppress_action_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_suppress_action=false
;;
--suppress-start)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_suppress_start="$2"
shift
;;
--suppress-start=*)
_arg_suppress_start="${_key##--suppress-start=}"
;;
--suppress-duration)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_suppress_duration="$2"
shift
;;
--suppress-duration=*)
_arg_suppress_duration="${_key##--suppress-duration=}"
;;
--no-suppress-upload-files|--suppress-upload-files)
_arg_suppress_upload_files=true
_arg_suppress_upload_files_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_suppress_upload_files=false
;;
--suppress-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_suppress_name="$2"
shift
;;
--suppress-name=*)
_arg_suppress_name="${_key##--suppress-name=}"
;;
--suppress-delete)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_suppress_delete="$2"
shift
;;
--suppress-delete=*)
_arg_suppress_delete="${_key##--suppress-delete=}"
;;
--no-upload-custom-dashboard|--upload-custom-dashboard)
_arg_upload_custom_dashboard=true
_arg_upload_custom_dashboard_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_upload_custom_dashboard=false
;;
--no-upload-default-dashboard|--upload-default-dashboard)
_arg_upload_default_dashboard=true
_arg_upload_default_dashboard_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_upload_default_dashboard=false
;;
--no-rbac-only|--rbac-only)
_arg_rbac_only=true
_arg_rbac_only_explicitly_set=true
test "${1:0:5}" = "--no-" && _arg_rbac_only=false
;;
--rbac-action)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_rbac_action="$2"
shift
;;
--rbac-action=*)
_arg_rbac_action_explicitly_set=true
_arg_rbac_action="${_key##--rbac-action=}"
;;
--rbac-role-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_rbac_role_name="$2"
shift
;;
--rbac-role-name=*)
_arg_rbac_role_name="${_key##--rbac-role-name=}"
;;
--rbac-role-description)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_rbac_role_description="$2"
shift
;;
--rbac-role-description=*)
_arg_rbac_role_description="${_key##--rbac-role-description=}"
;;
--rbac-saml-group-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_rbac_saml_group_name="$2"
shift
;;
--rbac-saml-group-name=*)
_arg_rbac_saml_group_name="${_key##--rbac-saml-group-name=}"
;;
--rbac-license-rule-name)
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_arg_rbac_license_rule_name="$2"
shift
;;
--rbac-license-rule-name=*)
_arg_rbac_license_rule_name="${_key##--rbac-license-rule-name=}"
;;
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
--no-debug|--debug)
_arg_debug=true
test "${1:0:5}" = "--no-" && _arg_debug=false
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}
handle_passed_args_dependency()
{
# warning
if ([ $_arg_use_https = false ] && [ ! $_arg_controller_port = "8090" ]); then
_PRINT_HELP=no warn "WARNING: Value of --controller-port is "${_arg_controller_port}" - note that for on-premises controllers, port 8090 is the default for HTTP"
fi
if ([ $_arg_use_https = true ] && ([ ! $_arg_controller_port = "8181" ] && [ ! $_arg_controller_port = "443" ] )); then
_PRINT_HELP=no warn "WARNING: Value of --controller-port is "${_arg_controller_port}" - note that for on-premises and SaaS controllers, ports 8181 and 443, respectively, are defaults for HTTPS"
fi
# error
if [ $_arg_include_database = true ]; then
test -z "${_arg_database_name// }" && _PRINT_HELP=yes die "FATAL ERROR: When value of --inlude-database is "${_arg_include_database}" - we require database name to be set (namely: --database-name)" 1
fi
if [ $_arg_use_proxy = true ]; then
test -z "${_arg_proxy_url// }" -o -z "${_arg_proxy_port// }" && _PRINT_HELP=yes die "FATAL ERROR: When value of --use-proxy is "${_arg_use_proxy}" - we require proxy details to be set (namely: --proxy-url and --proxy-port)" 1
fi
}
handle_mandatory_args()
{
test -z "${_arg_controller_host// }" && _PRINT_HELP=no die "FATAL ERROR: Controller host must be set" 1
test -z "${_arg_controller_port// }" && _PRINT_HELP=no die "FATAL ERROR: Controller port must be set" 1
test -z "${_arg_account// }" && _PRINT_HELP=no die "FATAL ERROR: Account must be set" 1
test -z "${_arg_username// }" && _PRINT_HELP=no die "FATAL ERROR: Username must be set" 1
test -z "${_arg_password// }" && _PRINT_HELP=no die "FATAL ERROR: Password must be set" 1
test -z "${_arg_application_name// }" && _PRINT_HELP=no die "FATAL ERROR: Application name must be set" 1
}
# Additional layer of control when value is set through environment variable or configuration
handle_expected_values_for_args()
{
if ([ ! $_arg_use_encoded_credentials = false ] && [ ! $_arg_use_encoded_credentials = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: -use-encoded-credentials value \"${_arg_use_encoded_credentials}\" not recognized" 1
fi
if ([ ! $_arg_health_rules_only = false ] && [ ! $_arg_health_rules_only = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --health-rules-only value \"${_arg_health_rules_only}\" not recognized" 1
fi
if ([ ! $_arg_health_rules_overwrite = false ] && [ ! $_arg_health_rules_overwrite = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --health-rules-overwrite value \"${_arg_health_rules_overwrite}\" not recognized" 1
fi
if ([ ! $_arg_use_https = false ] && [ ! $_arg_use_https = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --use-https value \"${_arg_use_https}\" not recognized" 1
fi
if ([ ! $_arg_include_database = false ] && [ ! $_arg_include_database = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --include-database value \"${_arg_include_database}\" not recognized" 1
fi
if ([ ! $_arg_use_proxy = false ] && [ ! $_arg_use_proxy = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --use-proxy value \"${_arg_use_proxy}\" not recognized" 1
fi
if ([ ! $_arg_include_sim = false ] && [ ! $_arg_include_sim = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --include-sim value \"${_arg_include_sim}\" not recognized" 1
fi
if ([ ! $_arg_configure_bt = false ] && [ ! $_arg_configure_bt = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --configure-bt value \"${_arg_configure_bt}\" not recognized" 1
fi
if ([ ! $_arg_bt_only = false ] && [ ! $_arg_bt_only = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --bt-only value \"${_arg_bt_only}\" not recognized" 1
fi
if ([ ! $_arg_use_branding = false ] && [ ! $_arg_use_branding = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --use-branding value \"${_arg_use_branding}\" not recognized" 1
fi
if ([ ! $_arg_upload_custom_dashboard = false ] && [ ! $_arg_upload_custom_dashboard = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --upload-custom-dashboardvalue \"${_arg_upload_custom_dashboard}\" not recognized" 1
fi
if ([ ! $_arg_upload_default_dashboard = false ] && [ ! $_arg_upload_default_dashboard = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: --upload-default-dashboard value \"${_arg_upload_default_dashboard}\" not recognized" 1
fi
if ([ ! $_arg_rbac_only = false ] && [ ! $_arg_rbac_only = true ] ); then
_PRINT_HELP=no die "FATAL ERROR: _arg_rbac_only value \"${_arg_rbac_only}\" not recognized" 1
fi
}
### 1 SET PARAMETER VALUES ###
# 1.1 Parse script input arguments
parse_commandline "$@"
# 1.2 If value not set with arguments replace with Environment Variable (if exists)
# Get ConfigMyApp environment variables with: env | grep CMA_
# general
if ([ $_arg_use_encoded_credentials_explicitly_set = false ] && [ ! -z "${CMA_USE_ENCODED_CREDENTIALS// }" ]); then
_arg_use_encoded_credentials=${CMA_USE_ENCODED_CREDENTIALS}
fi
# controller
if ([ -z "${_arg_controller_host// }" ] && [ ! -z "${CMA_CONTROLLER_HOST// }" ]); then
_arg_controller_host=${CMA_CONTROLLER_HOST}
fi
if ([ $_arg_controller_port_explicitly_set = false ] && [ ! -z "${CMA_CONTROLLER_PORT// }" ]); then
_arg_controller_port=${CMA_CONTROLLER_PORT}
fi
if ([ $_arg_use_https_explicitly_set = false ] && [ ! -z "${CMA_USE_HTTPS// }" ]); then
_arg_use_https=${CMA_USE_HTTPS}
fi
# account
if ([ $_arg_account_explicitly_set = false ] && [ ! -z "${CMA_ACCOUNT// }" ]); then
_arg_account=${CMA_ACCOUNT}
fi
if ([ -z "${_arg_username// }" ] && [ ! -z "${CMA_USERNAME// }" ]); then
_arg_username=${CMA_USERNAME}
fi
if ([ -z "${_arg_password// }" ] && [ ! -z "${CMA_PASSWORD// }" ]); then
_arg_password=${CMA_PASSWORD}
fi
# proxy
if ([ $_arg_use_proxy_explicitly_set = false ] && [ ! -z "${CMA_USE_PROXY// }" ]); then
_arg_use_proxy=${CMA_USE_PROXY}
fi
if ([ -z "${_arg_proxy_url// }" ] && [ ! -z "${CMA_PROXY_URL// }" ]); then
_arg_proxy_url=${CMA_PROXY_URL}
fi
if ([ -z "${_arg_proxy_port// }" ] && [ ! -z "${CMA_PROXY_PORT// }" ]); then
_arg_proxy_port=${CMA_PROXY_PORT}
fi
# branding
if ([ $_arg_use_branding_explicitly_set = false ] && [ ! -z "${CMA_USE_BRANDING// }" ]); then
_arg_use_branding=${CMA_USE_BRANDING}
fi
if ([ -z "${_arg_logo_name// }" ] && [ ! -z "${CMA_LOGO_NAME// }" ]); then
_arg_logo_name=${CMA_LOGO_NAME}
fi
if ([ -z "${_arg_background_name// }" ] && [ ! -z "${CMA_BACKGROUND_NAME// }" ]); then
_arg_background_name=${CMA_BACKGROUND_NAME}
fi
# configuration
if ([ -z "${_arg_application_name// }" ] && [ ! -z "${CMA_APPLICATION_NAME// }" ]); then
_arg_application_name=${CMA_APPLICATION_NAME}
fi
if ([ $_arg_include_database_explicitly_set = false ] && [ ! -z "${CMA_INCLUDE_DATABASE// }" ]); then
_arg_include_database=${CMA_INCLUDE_DATABASE}
fi
if ([ -z "${_arg_database_name// }" ] && [ ! -z "${CMA_DATABASE_NAME// }" ]); then
_arg_database_name=${CMA_DATABASE_NAME}
fi
if ([ $_arg_include_sim_explicitly_set = false ] && [ ! -z "${CMA_INCLUDE_SIM// }" ]); then
_arg_include_sim=${CMA_INCLUDE_SIM}
fi
if ([ $_arg_configure_bt_explicitly_set = false ] && [ ! -z "${CMA_CONFIGURE_BT// }" ]); then
_arg_configure_bt=${CMA_CONFIGURE_BT}
fi
if ([ $_arg_bt_only_explicitly_set = false ] && [ ! -z "${CMA_BT_ONLY// }" ]); then
_arg_bt_only=${CMA_BT_ONLY}
fi
# health rules
if ([[ $_arg_health_rules_only_explicitly_set = false ]] && [ ! -z "${CMA_HEALTH_RULES_ONLY// }" ]); then
_arg_health_rules_only=${CMA_HEALTH_RULES_ONLY}
fi
# backwards compatability for varaible name
if ([[ $_arg_health_rules_overwrite_explicitly_set = false ]] && [ -z "${CMA_OVERWRITE_HEALTH_RULES// }" ]); then
_arg_health_rules_overwrite=${CMA_OVERWRITE_HEALTH_RULES}
fi
# but override with newer version if provided
if ([[ $_arg_health_rules_overwrite_explicitly_set = false ]] && [ ! -z "${CMA_HEALTH_RULES_OVERWRITE// }" ]); then
_arg_health_rules_overwrite=${CMA_HEALTH_RULES_OVERWRITE}
fi
if ([[ -z "${_arg_health_rules_delete// }" ]] && [ ! -z "${CMA_HEALTH_RULES_DELETE// }" ]); then
_arg_health_rules_delete=${CMA_HEALTH_RULES_DELETE}
fi
# action suppression
if ([ $_arg_suppress_action_explicitly_set = false ] && [ ! -z "${CMA_SUPPRESS_ACTION// }" ]); then
_arg_suppress_action=${CMA_SUPPRESS_ACTION}
fi
if ([ -z "${_arg_suppress_start// }" ] && [ ! -z "${CMA_SUPPRESS_START// }" ]); then
_arg_suppress_start=${CMA_SUPPRESS_START}
fi
if ([ -z "${_arg_suppress_duration// }" ] && [ ! -z "${CMA_SUPPRESS_DURATION// }" ]); then
_arg_suppress_duration=${CMA_SUPPRESS_DURATION}
fi
if ([ -z "${_arg_suppress_name// }" ] && [ ! -z "${CMA_SUPPRESS_NAME// }" ]); then
_arg_suppress_name=${CMA_SUPPRESS_NAME}
fi
if ([ $_arg_suppress_upload_files_explicitly_set = false ] && [ ! -z "${CMA_SUPPRESS_UPLOAD_FILES// }" ]); then
_arg_suppress_upload_files=${CMA_SUPPRESS_UPLOAD_FILES}
fi
if ([ -z "${_arg_suppress_delete// }" ] && [ ! -z "${CMA_SUPPRESS_DELETE// }" ]); then
_arg_suppress_delete=${CMA_SUPPRESS_DELETE}
fi
# upload custom dashboards
if ([ $_arg_upload_custom_dashboard_explicitly_set = false ] && [ ! -z "${CMA_UPLOAD_CUSTOM_DASHBOARD// }" ]); then
_arg_upload_custom_dashboard=${CMA_UPLOAD_CUSTOM_DASHBOARD}
fi
# upload default dashboards
if ([ $_arg_upload_default_dashboard_explicitly_set = false ] && [ ! -z "${CMA_UPLOAD_DEFAULT_DASHBOARD// }" ]); then
_arg_upload_default_dashboard=${CMA_UPLOAD_DEFAULT_DASHBOARD}
fi
# RBAC
if ([ $_arg_rbac_only_explicitly_set = false ] && [ ! -z "${CMA_RBAC_ONLY// }" ]); then
_arg_rbac_only=${CMA_RBAC_ONLY}
fi
if ([ $_arg_rbac_action_explicitly_set = false ] && [ ! -z "${CMA_RBAC_ACTION// }" ]); then
_arg_rbac_action=${CMA_RBAC_ACTION}
fi
if ([ -z "${_arg_rbac_role_name// }" ] && [ ! -z "${CMA_RBAC_ROLE_NAME// }" ]); then
_arg_rbac_role_name=${CMA_RBAC_ROLE_NAME}
fi
if ([ -z "${_arg_rbac_role_description// }" ] && [ ! -z "${CMA_RBAC_ROLE_DESCRIPTION// }" ]); then
_arg_rbac_role_description=${CMA_RBAC_ROLE_DESCRIPTION}
fi
if ([ -z "${_arg_rbac_saml_group_name// }" ] && [ ! -z "${CMA_RBAC_SAML_GROUP_NAME// }" ]); then
_arg_rbac_saml_group_name=${CMA_RBAC_SAML_GROUP_NAME}
fi
if ([ -z "${_arg_rbac_license_rule_name// }" ] && [ ! -z "${CMA_RBAC_LICENSE_RULE_NAME// }" ]); then
_arg_rbac_license_rule_name=${CMA_RBAC_LICENSE_RULE_NAME}
fi
# 1.3 If value not set replace with configuration file values
conf_file="config.json"
# general
# note: for arguments with default value, set value from config if not explicitly set as argument and environment variable does not exist
if ([ $_arg_use_encoded_credentials_explicitly_set = false ] && [ -z "${CMA_USE_ENCODED_CREDENTIALS}" ]); then
_arg_use_encoded_credentials=$(jq -r '.are_passwords_encoded' <${conf_file})
fi
# if ([ $_arg_health_rules_overwrite_explicitly_set = false ] && [ -z "${CMA_OVERWRITE_HEALTH_RULES}" ]); then
# _arg_health_rules_overwrite=$(jq -r '.overwrite_health_rules' <${conf_file})
# fi
# controller
if [[ -z "${_arg_controller_host// }" ]]; then
_arg_controller_host=$(jq -r '.controller_details[].host' <${conf_file})
fi
if ([ $_arg_controller_port_explicitly_set = false ] && [ -z "${CMA_CONTROLLER_PORT}" ]); then
_arg_controller_port=$(jq -r '.controller_details[].port' <${conf_file})
fi
if ([ $_arg_use_https_explicitly_set = false ] && [ -z "${CMA_USE_HTTPS// }" ]); then
_arg_use_https=$(jq -r '.controller_details[].use_https' <${conf_file})
fi
# account
if ([ $_arg_account_explicitly_set = false ] && [ -z "${CMA_ACCOUNT}" ]); then
_arg_account=$(jq -r '.controller_details[].account' <${conf_file})
fi
if [[ -z "${_arg_username// }" ]]; then
_arg_username=$(jq -r '.controller_details[].username' <${conf_file})
fi
if [[ -z "${_arg_password// }" ]]; then
_arg_password=$(jq -r '.controller_details[].password' <${conf_file})
fi
# proxy
if ([ $_arg_use_proxy_explicitly_set = false ] && [ -z "${CMA_USE_PROXY// }" ]); then
_arg_use_proxy=$(jq -r '.controller_details[].use_proxy' <${conf_file})
fi
if [[ -z "${_arg_proxy_url// }" ]]; then
_arg_proxy_url=$(jq -r '.controller_details[].proxy_url' <${conf_file})
fi
if [[ -z "${_arg_proxy_port// }" ]]; then
_arg_proxy_port=$(jq -r '.controller_details[].proxy_port' <${conf_file})
fi
# branding
if ([ $_arg_use_branding_explicitly_set = false ] && [ -z "${CMA_USE_BRANDING// }" ]); then
_arg_use_branding=$(jq -r '.branding[].enabled' <${conf_file})
fi
if [[ -z "${_arg_logo_name// }" ]]; then
_arg_logo_name=$(jq -r '.branding[].logo_file_name' <${conf_file})
fi
if [[ -z "${_arg_background_name// }" ]]; then
_arg_background_name=$(jq -r '.branding[].background_file_name' <${conf_file})
fi
# configuration
if [[ -z "${_arg_application_name// }" ]]; then
_arg_application_name=$(jq -r '.configuration[].application_name' <${conf_file})
fi
if ([[ $_arg_include_database_explicitly_set = false ]] && [ -z "${CMA_INCLUDE_DATABASE// }" ]); then
_arg_include_database=$(jq -r '.configuration[].include_database' <${conf_file})
fi
if [[ -z "${_arg_database_name// }" ]]; then
_arg_database_name=$(jq -r '.configuration[].database_name' <${conf_file})
fi
if ([[ $_arg_include_sim_explicitly_set = false ]] && [ -z "${CMA_INCLUDE_SIM// }" ]); then
_arg_include_sim=$(jq -r '.configuration[].include_sim' <${conf_file})
fi
if ([[ $_arg_configure_bt_explicitly_set = false ]] && [ -z "${CMA_CONFIGURE_BT// }" ]); then
_arg_configure_bt=$(jq -r '.configuration[].configure_bt' <${conf_file})
fi
if ([[ $_arg_bt_only_explicitly_set = false ]] && [ -z "${CMA_BT_ONLY// }" ]); then
_arg_bt_only=$(jq -r '.configuration[].bt_only' <${conf_file})
fi
# health rules
if ([[ $_arg_health_rules_only_explicitly_set = false ]] && [ -z "${CMA_HEALTH_RULES_ONLY// }" ]); then
_arg_health_rules_only=$(jq -r '.health_rules[].health_rules_only' <${conf_file})
fi
if ([[ $_arg_health_rules_overwrite_explicitly_set = false ]] && [ -z "${CMA_HEALTH_RULES_OVERWRITE// }" ]); then
_arg_health_rules_overwrite=$(jq -r '.health_rules[].health_rules_overwrite' <${conf_file})
fi
if [[ -z "${_arg_health_rules_delete// }" ]]; then
_arg_health_rules_delete=$(jq -r '.health_rules[].health_rules_delete' <${conf_file})
fi
# action suppression
if ([[ $_arg_suppress_action_explicitly_set = false ]] && [ -z "${CMA_SUPPRESS_ACTION// }" ]); then
_arg_suppress_action=$(jq -r '.action_suppression[].suppress_action' <${conf_file})
fi
if [[ -z "${_arg_suppress_start// }" ]]; then
_arg_suppress_start=$(jq -r '.action_suppression[].suppress_start' <${conf_file})
fi
if [[ -z "${_arg_suppress_duration// }" ]]; then
_arg_suppress_duration=$(jq -r '.action_suppression[].suppress_duration' <${conf_file})
fi
if [[ -z "${_arg_suppress_name// }" ]]; then
_arg_suppress_name=$(jq -r '.action_suppression[].suppress_name' <${conf_file})
fi
if ([[ $_arg_suppress_upload_files_explicitly_set = false ]] && [ -z "${CMA_SUPPRESS_UPLOAD_FILES// }" ]); then
_arg_suppress_upload_files=$(jq -r '.action_suppression[].suppress_upload_files' <${conf_file})
fi
if [[ -z "${_arg_suppress_delete// }" ]]; then
_arg_suppress_delete=$(jq -r '.action_suppression[].suppress_delete' <${conf_file})
fi
# upload custom dashboards
if ([[ $_arg_upload_custom_dashboard_explicitly_set = false ]] && [ -z "${CMA_UPLOAD_CUSTOM_DASHBOARD// }" ]); then
_arg_upload_custom_dashboard=$(jq -r '.configuration[].upload_custom_dashboard' <${conf_file})
fi
# upload deafult dashboards
if ([[ $_arg_upload_default_dashboard_explicitly_set = false ]] && [ -z "${CMA_UPLOAD_DEFAULT_DASHBOARD// }" ]); then
_arg_upload_default_dashboard=$(jq -r '.configuration[].upload_default_dashboard' <${conf_file})
fi
# RBAC
if ([[ $_arg_rbac_only_explicitly_set = false ]] && [ -z "${CMA_RBAC_ONLY// }" ]); then
_arg_rbac_only=$(jq -r '.rbac[].rbac_only' <${conf_file})
fi
if ([[ $_arg_rbac_action_explicitly_set = false ]] && [ -z "${CMA_RBAC_ACTION// }" ]); then
_arg_rbac_action=$(jq -r '.rbac[].rbac_action' <${conf_file})
fi
if [[ -z "${_arg_rbac_role_name// }" ]]; then
_arg_rbac_role_name=$(jq -r '.rbac[].rbac_role_name' <${conf_file})
fi
if [[ -z "${_arg_rbac_role_description// }" ]]; then
_arg_rbac_role_description=$(jq -r '.rbac[].rbac_role_description' <${conf_file})
fi
if [[ -z "${_arg_rbac_saml_group_name// }" ]]; then
_arg_rbac_saml_group_name=$(jq -r '.rbac[].rbac_saml_group_name' <${conf_file})
fi
if [[ -z "${_arg_rbac_license_rule_name// }" ]]; then
_arg_rbac_license_rule_name=$(jq -r '.rbac[].rbac_license_rule_name' <${conf_file})
fi
### 2 VALIDATE ###
# 2.1 Check if values are in expected ranges
handle_expected_values_for_args
# 2.2 Check parameter dependency constraints
handle_passed_args_dependency
# 2.3 Check if all mandatory parameters are set
handle_mandatory_args
### END OF ARGS. DO DELETE THIS COMMENT ### ])
# [ <-- needed, do not delete
# <-- needed , do not delete
if [ $_arg_debug = true ]; then
echo "Value of --use-encoded-credentials: $_arg_use_encoded_credentials"
echo "Value of --health-rules-overwrite: $_arg_health_rules_overwrite"
echo "Value of --controller-host: $_arg_controller_host"
echo "Value of --controller-port: $_arg_controller_port"
echo "Value of --use-https: $_arg_use_https"
echo "Value of --account: $_arg_account"
echo "Value of --username: $_arg_username"
#echo "Value of --password: $_arg_password"
echo "Value of --use-proxy: $_arg_use_proxy"
echo "Value of --proxy-url: $_arg_proxy_url"
echo "Value of --proxy-port: $_arg_proxy_port"
echo "Value of --application-name: $_arg_application_name"
echo "Value of --include-database: $_arg_include_database"
echo "Value of --database-name: $_arg_database_name"
echo "Value of --include-sim: $_arg_include_sim"
echo "Value of --configure-bt: $_arg_configure_bt"
echo "Value of --bt-only: $_arg_bt_only"
echo "Value of --health-rules-only: ${_arg_health_rules_only}"
echo "Value of --health-rules-overwrite: ${_arg_health_rules_overwrite}"
echo "Value of --health-rules-delete: ${_arg_health_rules_delete}"
echo "Value of --suppress-action: $_arg_suppress_action"
echo "Value of --suppress-start: $_arg_suppress_start"
echo "Value of --suppress-duration: $_arg_suppress_duration"
echo "Value of --suppress-name: $_arg_suppress_name"
echo "Value of --suppress-delete: $_arg_suppress_delete"
echo "Value of --use-branding: $_arg_use_branding"
echo "Value of --logo-name: $_arg_logo_name"
echo "Value of --background-name: $_arg_background_name"
echo "Value of --upload-custom-dashboard: $_arg_upload_custom_dashboard"
echo "Value of --upload-default-dashboard: $_arg_upload_default_dashboard"
echo "Value of --rbac-only: $_arg_rbac_only"
echo "Value of --rbac-action: $_arg_rbac_action"
echo "Value of --rbac-role-name: $_arg_rbac_role_name"
echo "Value of --rbac-role-description: $_arg_rbac_role_description"
echo "Value of --rbac-saml-group-name: $_arg_rbac_saml_group_name"
echo "Value of --rbac-license-rule-name: $_arg_rbac_license_rule_name"
fi
### 3 PREPARE PARAMETERS ###
# 3.1 Prepare user credentials
# remove anything after '@' in username (in case that account is set as part of username value)
_arg_username="$(echo $_arg_username | sed -e 's|@.*$||')"
# decode passwords if encoded
if [ "$_arg_use_encoded_credentials" = true ]; then
_arg_password=$(eval echo ${_arg_password} | base64 --decode)
fi
# build user credentials
_arg_user_credentials="$_arg_username@$_arg_account:$_arg_password"
# 3.2 Set protocol
# extract protocol based on input flags
if [ $_arg_use_https = true ]; then
protocol="https"
else
protocol="http"
fi
# extract protocol from controller host variable, without trailing :// and convert to lower caps
_arg_controller_host_protocol="$(echo $_arg_controller_host | grep :// | sed -e's,^\(.*://\).*,\1,g' | sed 's/.\{3\}$//' | tr '[:upper:]' '[:lower:]')"
# if host url does not contain protocol
if [ -z "${_arg_controller_host_protocol}" ]; then
_arg_controller_host_protocol=$protocol
fi
# 3.3 Prepare controller url
# remove anything before // (protocol) and after : or / (path and/or port) in hostname - to keep only domain name
_arg_controller_host="$(echo $_arg_controller_host | sed -e 's|^[^/]*//||' -e 's|/.*$||' -e 's|:.*$||')"
_arg_controller_url="$_arg_controller_host_protocol://$_arg_controller_host:$_arg_controller_port/controller"
if [ "${protocol}" != "${_arg_controller_host_protocol}" ]; then
echo "WARNING --use-https / --no-use-https flag value '${protocol}' does not match controller host protocol '${_arg_controller_host_protocol}'."
echo " Note that controller host protocol takes precedence and final URL to connect to is: '${_arg_controller_url}'."
fi
# 3.4 Prepare proxy details
if [ $_arg_use_proxy = true ]; then
_arg_proxy_details="-x $_arg_proxy_url:$_arg_proxy_port"
else
_arg_proxy_details=""
fi
# 3.5 Prepare branding
_arg_logo_name="./branding/$_arg_logo_name"
_arg_background_name="./branding/$_arg_background_name"
if [ $_arg_debug = true ]; then
echo ''
echo "Config details:"
echo "User credentials: $_arg_user_credentials"
echo "Controller URL: $_arg_controller_url"
echo "Proxy details: $_arg_proxy_details"
echo "Configure BTs: $_arg_configure_bt"
fi
# 3.5 Prepare action supression
if [ $_arg_suppress_action = true ]; then
if [ -z "${_arg_suppress_start// }" ]; then
# set to current datetime if empty
# UTC / GMT
_arg_suppress_start=$(date -u +%FT%T+0000)
echo "DEF|Default action suppression start time created '${_arg_suppress_start}'"
fi
if [ -z "${_arg_suppress_duration// }" ]; then
# set to one hour if empty
_arg_suppress_duration=60
echo "DEF|Default action suppression duration created '${_arg_suppress_duration}'"
fi
fi
# 3.6 Prepare RBAC
if [ $_arg_rbac_only = true ]; then
# validate action (check if valid option)
if [[ ! " ${_valid_rbac_actions[@]} " =~ " ${_arg_rbac_action} " ]]; then
# whatever you want to do when array doesn't contain value
_PRINT_HELP=no die "FATAL ERROR: --rbac-action value \"${_arg_rbac_action}\" not recognized" 1