-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmake_github_scripts_tgz.v05.38.00.sh
More file actions
1501 lines (1143 loc) · 58.7 KB
/
make_github_scripts_tgz.v05.38.00.sh
File metadata and controls
1501 lines (1143 loc) · 58.7 KB
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
#
# (C) 2016-2026+ Eric James Beasley, mybasementcloud, https://github.com/mybasementcloud/bash_4_Check_Point_scripts
#
# ALL SCRIPTS ARE PROVIDED AS IS WITHOUT EXPRESS OR IMPLIED WARRANTY OF FUNCTION OR POTENTIAL FOR
# DAMAGE Or ABUSE. AUTHOR DOES NOT ACCEPT ANY RESPONSIBILITY FOR THE USE OF THESE SCRIPTS OR THE
# RESULTS OF USING THESE SCRIPTS. USING THESE SCRIPTS STIPULATES A CLEAR UNDERSTANDING OF RESPECTIVE
# TECHNOLOGIES AND UNDERLYING PROGRAMMING CONCEPTS AND STRUCTURES AND IMPLIES CORRECT IMPLEMENTATION
# OF RESPECTIVE BASELINE TECHNOLOGIES FOR PLATFORM UTILIZING THE SCRIPTS. THIRD PARTY LIMITATIONS
# APPLY WITHIN THE SPECIFICS THEIR RESPECTIVE UTILIZATION AGREEMENTS AND LICENSES. AUTHOR DOES NOT
# AUTHORIZE RESALE, LEASE, OR CHARGE FOR UTILIZATION OF THESE SCRIPTS BY ANY THIRD PARTY.
#
# AUTHOR REQUIRES ALL UTILIZATION FOR TRAINING OF AI OF ANY TYPE TO BE REQUESTED IN WRITING AND
# APPROVED IN WRITING VERIFIABLY BEFORE ANY SUCH AI TRAINING SHALL COMMENCE.
#
#
# -#- Start Making Changes Here -#-
#
# SCRIPT: Make Github scripts tgz file for this version and using relevant date and version information
#
#
# Version created 2026-MM-DD-HHMM hrs TZN
# Version created 2026-02-08-2025 hrs CST
#ScriptDTG=2026-MM-DD-HHMM
ScriptDTG=2026-02-08-2025
ScriptTZ=CST
ScriptDTGTZ=${ScriptDTG}${ScriptTZ}
#
ScriptDate=2026-02-08
ScriptVersion=05.38.00
ScriptRevision=000
ScriptSubRevision=300
TemplateVersion=05.38.00
TemplateLevel=006
SubScriptsLevel=010
SubScriptsVersion=05.38.00
#
export BASHScriptVersion=v${ScriptVersion}
export BASHScriptTemplateVersion=v${TemplateVersion}
export BASHScriptVersionX=v${ScriptVersion//./x}
export BASHScriptTemplateVersionX=v${TemplateVersion//./x}
export BASHScriptTemplateLevel=${TemplateLevel}.v${TemplateVersion}
export BASHSubScriptsVersion=v${SubScriptsVersion}
export BASHSubScriptTemplateVersion=v${TemplateVersion}
export BASHExpectedSubScriptsVersion=${SubScriptsLevel}.v${SubScriptsVersion}
export BASHSubScriptsVersionX=v${SubScriptsVersion//./x}
export BASHSubScriptTemplateVersionX=v${TemplateVersion//./x}
export BASHExpectedSubScriptsVersionX=${SubScriptsLevel}.v${SubScriptsVersion//./x}
export BASHScriptFileNameRoot=make_github_scripts_tgz
export BASHScriptShortName=make_github_scripts_tgz.v${ScriptVersion}
export BASHScriptnohupName=${BASHScriptShortName}
export BASHScriptDescription="Make Githubscripts tgz file for this version and using relevant date and version information"
#export BASHScriptName=${BASHScriptFileNameRoot}.${TemplateLevel}.v${ScriptVersion}
export BASHScriptName=${BASHScriptFileNameRoot}.v${ScriptVersion}
export BASHScriptHelpFilePath=help.v${ScriptVersion}
export BASHScriptHelpFileName=${BASHScriptFileNameRoot}.help
export BASHScriptHelpFile=${BASHScriptHelpFilePath}/${BASHScriptHelpFileName}
export BASHScriptHelpFileExamplesName=${BASHScriptFileNameRoot}.examples.help
export BASHScriptHelpExamplesFile=${BASHScriptHelpFilePath}/${BASHScriptHelpFileExamplesName}
# _api_subscripts|_hostsetupscripts|_hostupdatescripts|_scripting_tools|_subscripts|_template|Common|Config|GAIA|GW|[GW.CORE]|HCP|Health_Check|MDM|MGMT|Patch_Hotfix|scripts_tools|SD-WAN|[SD-WAN.CORE]|Session_Cleanup|SmartEvent|SMS|[SMS.CORE]|SMS.migrate_backup|UserConfig|[UserConfig.CORE_G2.NPM]
export BASHScriptsFolder=.
export BASHScripttftptargetfolder="."
# =================================================================================================
# =================================================================================================
# START: Root Configuration
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Output formating values
# -------------------------------------------------------------------------------------------------
export txtCLEAR=`tput clear`
export txtNORM=`tput sgr0`
export txtBOLD=`tput bold`
export txtDIM=`tput dim`
export txtREVERSE=`tput rev`
export txtULINEbeg=`tput smul`
export txtULINEend=`tput rmul`
export txtSTANDOUTbeg=`tput smso`
export txtSTANDOUTend=`tput rmso`
export getWindowColumns=`tput cols`
export getWindowLines=`tput lines`
#tput setab color Set ANSI Background color
#tput setaf color Set ANSI Foreground color
export txtBLACK=`tput setaf 0`
export txtRED=`tput setaf 1`
export txtGREEN=`tput setaf 2`
export txtYELLOW=`tput setaf 3`
export txtBLUE=`tput setaf 4`
export txtMAGENTA=`tput setaf 5`
export txtCYAN=`tput setaf 6`
export txtWHITE=`tput setaf 7`
export txtDEFAULT=`tput setaf 9`
export txtbkgBLACK=`tput setab 0`
export txtbkgRED=`tput setab 1`
export txtbkgGREEN=`tput setab 2`
export txtbkgYELLOW=`tput setab 3`
export txtbkgBLUE=`tput setab 4`
export txtbkgMAGENTA=`tput setab 5`
export txtbkgCYAN=`tput setab 6`
export txtbkgWHITE=`tput setab 7`
export txtbkgDEFAULT=`tput setab 9`
# -------------------------------------------------------------------------------------------------
# Date variable configuration
# -------------------------------------------------------------------------------------------------
export DATE=`date +%Y-%m-%d-%H%M%Z`
export DATEDTG=`date +%Y-%m-%d-%H%M%Z`
export DATEDTGS=`date +%Y-%m-%d-%H%M%S%Z`
export DATEYMD=`date +%Y-%m-%d`
export DATEUTC=`date -u +%Y-%m-%d-%H%M%Z`
export DATEUTCDTG=`date -u +%Y-%m-%d-%H%M%Z`
export DATEUTCDTGS=`date -u +%Y-%m-%d-%H%M%S%Z`
export DATEUTCYMD=`date -u +%Y-%m-%d`
# -------------------------------------------------------------------------------------------------
# Script key folders and files variable configuration
# -------------------------------------------------------------------------------------------------
export customerpathroot=/var/log/__customer
export customerworkpathroot=${customerpathroot}/package.deploy.B4CP
export scriptspathroot=${customerworkpathroot}/scripts
export subscriptsfolder=_subscripts
export rootscriptconfigfile=__root_script_config.sh
# -------------------------------------------------------------------------------------------------
# Script Operations Control variable configuration
# -------------------------------------------------------------------------------------------------
#
# -#- Start Making Changes Here -#-
#
WAITTIME=20
B4CPSCRIPTVERBOSE=false
# -------------------------------------------------------------------------------------------------
# R8X API variable configuration
# -------------------------------------------------------------------------------------------------
# MODIFIED 2026-02-01:01 -
# R80 version 1.0
# R80.10 version 1.1
# R80.20.M1 version 1.2
# R80.20 GA version 1.3
# R80.20.M2 version 1.4
# R80.30 version 1.5
# R80.40 version 1.6
# R80.40 JHF 78 version 1.6.1
# R81 version 1.7
# R81 JHF 34 version 1.7.1
# R81.10 version 1.8
# R81.10 JHF 79 version 1.8.1
# R81.20 version 1.9
# R81.20 JHF 43 version 1.9.1
# R82.00 version 2.0
# R82.00 JHF 41 version 2.0.1
# R82.10 version 2.1
#
# For common scripts minimum API version at 1.1 should suffice, otherwise get explicit
# To enable use of API Key authentication, at least version 1.6 is required
#
export MinAPIVersionRequired=1.1
# ADDED 2022-03-09 -
#
# mgmt_cli command-name command-parameters optional-switches
#
# optional-switches:
# ---------------
# [--conn-timeout]
# Defines maximum time the request is allowed to take in seconds.
# Default {180}
# Environment variable: MGMT_CLI_CONNECTION_TIMEOUT
#
export APICLIconntimeout=600
# MODIFIED 2026-02-01:01 -
# MaaS (Smart-1 Cloud) current versions
# R81 version 1.7
# R81 JHF 34 version 1.7.1 !! ????
# R81.10 version 1.8
# R81.20 version 1.9
# R81.20 JHF 43 version 1.9.1
# R82.00 version 2.0
# R82.00 JHF 41 version 2.0.1
# R82.10 version 2.1
#
# for MaaS (Smart-1 Cloud) operation assume at least the minimum API version as 1.7 for R81
#
export MinMaaSAPIVersion=1.7
export MaxMaaSAPIVersion=2.1
# If the API version needs to be enforced in commands set this to true
# NOTE not currently used!
#
export ForceAPIVersionToMinimum=false
export R8XRequired=false
export UseR8XAPI=false
export UseJSONJQ=true
export UseJSONJQ16=true
export JQ16Required=false
# -------------------------------------------------------------------------------------------------
# Log file and logging control variables
# -------------------------------------------------------------------------------------------------
# Configure output file folder target
# One of these needs to be set to true, just one
#
export OutputToRoot=false
export OutputToDump=true
export OutputToChangeLog=false
export OutputToOther=false
#
# if OutputToOther is true, then this next value needs to be set
#
export OtherOutputFolder=Specify_The_Folder_Here
# -------------------------------------------------------------------------------------------------
# MODIFIED 2020-11-12 -
# if we are date-time stamping the output location as a subfolder of the
# output folder set this to true, otherwise it needs to be false
#
# OutputEnableLogFile : true|false : log output to log file
#
# OutputYearSubfolder : true|false : Add a folder level with just the year (YYYY)
# OutputYMSubfolder : true|false : Add a folder level with the year-month (YYYY-MM)
# OutputDTGSSubfolder : true|false : Add a folder level with Date Time Group with Seconds (YYYY-MM-DD-HHmmSS)
# Append script name to output subfolder, only one of these should be true, ignored if both are false
# OutputSubfolderScriptName : true|false : Add full script name to folder name of output folder
# :: setting this value true will override OutputSubfolderScriptShortName
# OutputSubfolderScriptShortName : true|false : Add short script name to folder name of output folder
#
# OutputDTGTZinUTC : true|false : Instead of using the local timezone in logs use UTC timezone
#
export OutputEnableLogFile=true
export OutputYearSubfolder=true
export OutputYMSubfolder=true
export OutputDTGSSubfolder=true
export OutputSubfolderScriptName=false
export OutputSubfolderScriptShortName=true
export OutputDTGTZinUTC=false
# -------------------------------------------------------------------------------------------------
# Local initial logfile variables
# -------------------------------------------------------------------------------------------------
export logfilefolderroot=/var/log/tmp/b4CPscripts
export logfilefoldername=${BASHScriptName}
# -------------------------------------------------------------------------------------------------
# logfile configuration
# -------------------------------------------------------------------------------------------------
# ADDED 2020-12-22
# we need the quick version of the gaiaversion
cpreleasefile=/etc/cp-release
export getgaiaquickversion=$(cat ${cpreleasefile} | cut -d " " -f 4)
export gaiaquickversion=${getgaiaquickversion}
# setup initial log file for output logging
export logfilefolder=${logfilefolderroot}/${logfilefoldername}
if $OutputDTGTZinUTC ; then
export logfilepath=${logfilefolder}/${BASHScriptName}.${HOSTNAME}.${gaiaquickversion}.${DATEUTCDTGS}.log
else
export logfilepath=${logfilefolder}/${BASHScriptName}.${HOSTNAME}.${gaiaquickversion}.${DATEDTGS}.log
fi
if ${OutputEnableLogFile} ; then
# We are logging, so create the initial working folder and log file
if [ ! -w ${logfilefolder} ]; then
mkdir -pv ${logfilefolder} > /dev/null
fi
touch ${logfilepath}
echo
else
# We are NOT logging, so don't create the initial working folder and log file
# set the logfilepath to device null /dev/null to squelch the output
export logfilepath=/dev/null
echo
fi
# -------------------------------------------------------------------------------------------------
# Variables for check operation in users home path
# -------------------------------------------------------------------------------------------------
# MODIFIED 2021-02-13 -
export notthispath=/home/
export localdotpathroot=.
# MODIFIED 2020-11-20 -
export localdotpath=`pwd`
export currentlocalpath=${localdotpath}
export workingpath=${currentlocalpath}
# MODIFIED 2021-02-13 -
export expandedpath=$(cd ${localdotpathroot} ; pwd)
export startpathroot=${expandedpath}
# -------------------------------------------------------------------------------------------------
# Gaia and installation type handling
# -------------------------------------------------------------------------------------------------
#
# -#- Start Making Changes Here -#-
#
export UseGaiaVersionAndInstallation=true
export ShowGaiaVersionResults=true
export KeepGaiaVersionResultsFile=false
# -------------------------------------------------------------------------------------------------
# Configure variables for subscripts calls
# -------------------------------------------------------------------------------------------------
# MODIFIED 2020-11-13 -
# Configure basic information for formation of file path for basic script setup handler script
#
# basic_script_setup_handler_root - root path to command line parameter handler script
# basic_script_setup_handler_folder - folder for under root path to command line parameter handler script
# basic_script_setup_handler_file - filename, without path, for command line parameter handler script
#
export basic_script_setup_handler_root=${scriptspathroot}
export basic_script_setup_handler_folder=${subscriptsfolder}
export basic_script_setup_handler_name=basic_script_setup
export basic_script_setup_handler_file=${basic_script_setup_handler_name}.subscript.${SubScriptsLevel}.v${SubScriptsVersion}.sh
# Configure basic information for formation of file path for command line parameter handler script
#
# cli_script_cmdlineparm_handler_root - root path to command line parameter handler script
# cli_script_cmdlineparm_handler_folder - folder for under root path to command line parameter handler script
# cli_script_cmdlineparm_handler_file - filename, without path, for command line parameter handler script
#
export cli_script_cmdlineparm_handler_root=${scriptspathroot}
export cli_script_cmdlineparm_handler_folder=${subscriptsfolder}
export cli_script_cmdlineparm_handler_name=cmd_line_parameters_handler
export cli_script_cmdlineparm_handler_file=${cli_script_cmdlineparm_handler_name}.subscript.${SubScriptsLevel}.v${SubScriptsVersion}.sh
# Configure basic information for formation of file path for configure script output paths and folders handler script
#
# script_output_paths_and_folders_handler_root - root path to configure script output paths and folders handler script
# script_output_paths_and_folders_handler_folder - folder for under root path to configure script output paths and folders handler script
# script_output_paths_and_folders_handler_file - filename, without path, for configure script output paths and folders handler script
#
export script_output_paths_and_folders_handler_root=${scriptspathroot}
export script_output_paths_and_folders_handler_folder=${subscriptsfolder}
export script_output_paths_and_folders_handler_name=script_output_paths_and_folders
export script_output_paths_and_folders_handler_file=${script_output_paths_and_folders_handler_name}.subscript.${SubScriptsLevel}.v${SubScriptsVersion}.sh
# Configure basic information for formation of file path for gaia version and type handler script
#
# gaia_version_type_handler_root - root path to gaia version and type handler script
# gaia_version_type_handler_folder - folder for under root path to gaia version and type handler script
# gaia_version_type_handler_file - filename, without path, for gaia version and type handler script
#
export gaia_version_type_handler_root=${scriptspathroot}
export gaia_version_type_handler_folder=${subscriptsfolder}
export gaia_version_type_handler_name=gaia_version_installation_type
export gaia_version_type_handler_file=${gaia_version_type_handler_name}.subscript.${SubScriptsLevel}.v${SubScriptsVersion}.sh
# Configure basic information for API mgmt_cli operations handler script
#
# mgmt_cli_api_ops_handler_root - root path to API mgmt_cli operations handler script
# mgmt_cli_api_ops_handler_folder - folder for under root path to API mgmt_cli operations handler script
# mgmt_cli_api_ops_handler_file - filename, without path, for API mgmt_cli operations handler script
#
export mgmt_cli_api_ops_handler_root=${scriptspathroot}
export mgmt_cli_api_ops_handler_folder=${subscriptsfolder}
export mgmt_cli_api_ops_handler_name=mgmt_cli_api_operations
export mgmt_cli_api_ops_handler_file=${mgmt_cli_api_ops_handler_name}.subscript.${SubScriptsLevel}.v${SubScriptsVersion}.sh
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# END: Root Configuration
# =================================================================================================
# =================================================================================================
#==================================================================================================
#==================================================================================================
#==================================================================================================
# Start of template
#==================================================================================================
#==================================================================================================
# MOVED 2020-11-12 -
#==================================================================================================
# Announce Script, this should also be the first log entry!
#==================================================================================================
# MODIFIED 2023-02-17:01 -
echo | tee -a -i ${logfilepath}
echo ${txtCYAN}${BASHScriptName}${txtDEFAULT}', script version '${txtYELLOW}${ScriptVersion}${txtDEFAULT}', revision '${txtYELLOW}${ScriptRevision}${txtDEFAULT}', subrevision '${txtGREEN}${ScriptSubRevision}${txtDEFAULT}' from '${txtYELLOW}${ScriptDate}${txtDEFAULT} | tee -a -i ${logfilepath}
echo ${BASHScriptDescription} | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo 'Date Time Group : '${txtCYAN}${DATEDTGS}${txtDEFAULT} | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
# -------------------------------------------------------------------------------------------------
# Quick Gaia main train version check for R8X release
# -------------------------------------------------------------------------------------------------
# MODIFIED/MOVED 2020-12-22 -
if [ -z ${gaiaversion} ] ; then
cpreleasefile=/etc/cp-release
export getgaiaquickversion=$(cat ${cpreleasefile} | cut -d " " -f 4)
export gaiaversion=${getgaiaquickversion}
fi
export checkR77version=`echo "${FWDIR}" | grep -i "R77"`
export checkifR77version=`test -z ${checkR77version}; echo $?`
if [ ${checkifR77version} -eq 1 ] ; then
export isitR77version=true
else
export isitR77version=false
fi
#echo ${isitR77version}
export checkR8Xversion=`echo "${FWDIR}" | grep -i "R8"`
export checkifR8Xversion=`test -z ${checkR8Xversion}; echo $?`
if [ ${checkifR8Xversion} -eq 1 ] ; then
export isitR8Xversion=true
else
export isitR8Xversion=false
fi
#echo ${isitR8Xversion}
if ${isitR77version}; then
echo "This is an R77.X version..." >> ${logfilepath}
export UseR8XAPI=false
export UseJSONJQ=false
export UseJSONJQ16=false
elif ${isitR8Xversion}; then
echo "This is an R8X version..." >> ${logfilepath}
export UseR8XAPI=${UseR8XAPI}
export UseJSONJQ=${UseJSONJQ}
export UseJSONJQ16=${UseJSONJQ16}
else
echo "This is not an R77.X or R8X version ????" >> ${logfilepath}
fi
# =================================================================================================
# =================================================================================================
# START: Local Command Line Parameter Handling and Help Configuration and Local Handling
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Define command line parameters and set appropriate values
# -------------------------------------------------------------------------------------------------
# MODIFIED 2020-11-19 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#
#
# Standard Scripts and R8X API Scripts Command Line Parameters
#
# -? | --help
# -v | --verbose
# -P <web-ssl-port> | --port <web-ssl-port> | -P=<web-ssl-port> | --port=<web-ssl-port>
# -r | --root
# -u <admin_name> | --user <admin_name> | -u=<admin_name> | --user=<admin_name>
# -p <password> | --password <password> | -p=<password> | --password=<password>
# --api-key "<api_key_value>" | --api-key="<api_key_value>"
# -m <server_IP> | --management <server_IP> | -m=<server_IP> | --management=<server_IP>
# -d <domain> | --domain <domain> | -d=<domain> | --domain=<domain>
# -s <session_file_filepath> | --session-file <session_file_filepath> | -s=<session_file_filepath> | --session-file=<session_file_filepath>
# --session-timeout <session_time_out> 10-3600
# -l <log_path> | --log-path <log_path> | -l=<log_path> | --log-path=<log_path>'
#
# -o <output_path> | --output <output_path> | -o=<output_path> | --output=<output_path>
#
# --NOWAIT
#
# --NOSTART
# --RESTART
#
# --NOHUP
# --NOHUP-Script <NOHUP_SCRIPT_NAME> | --NOHUP-Script=<NOHUP_SCRIPT_NAME>
# --NOHUP-DTG <NOHUP_SCRIPT_DATE_TIME_GROUP> | --NOHUP-DTG=<NOHUP_SCRIPT_DATE_TIME_GROUP>
# --NOHUP-PATH <NOHUP_SCRIPT_EXECUTION_PATH> | --NOHUP-PATH=<NOHUP_SCRIPT_EXECUTION_PATH>
#
export SHOWHELP=false
# MODIFIED 2018-09-29 -
#export CLIparm_websslport=443
export CLIparm_websslport=
export CLIparm_rootuser=false
export CLIparm_user=
export CLIparm_password=
export CLIparm_mgmt=
export CLIparm_domain=
export CLIparm_sessionidfile=
export CLIparm_sessiontimeout=
export CLIparm_logpath=
export CLIparm_outputpath=
# ADDED 2020-08-19 -
export CLIparm_api_key=
export CLIparm_use_api_key=false
# --NOWAIT
#
export CLIparm_NOWAIT=false
if [ -z "${NOWAIT}" ]; then
# NOWAIT mode not set from shell level
export CLIparm_NOWAIT=false
export NOWAIT=false
elif [ x"`echo "${NOWAIT}" | tr '[:upper:]' '[:lower:]'`" = x"false" ] ; then
# NOWAIT mode set OFF from shell level
export CLIparm_NOWAIT=false
export NOWAIT=false
elif [ x"`echo "${NOWAIT}" | tr '[:upper:]' '[:lower:]'`" = x"true" ] ; then
# NOWAIT mode set ON from shell level
export CLIparm_NOWAIT=true
export NOWAIT=true
else
# NOWAIT mode set to wrong value from shell level
export CLIparm_NOWAIT=false
export NOWAIT=false
fi
# --NOSTART
#
export CLIparm_NOSTART=false
if [ -z "${NOSTART}" ]; then
# NOSTART mode not set from shell level
export CLIparm_NOSTART=false
export NOSTART=false
elif [ x"`echo "${NOSTART}" | tr '[:upper:]' '[:lower:]'`" = x"false" ] ; then
# NOSTART mode set OFF from shell level
export CLIparm_NOSTART=false
export NOSTART=false
elif [ x"`echo "${NOSTART}" | tr '[:upper:]' '[:lower:]'`" = x"true" ] ; then
# NOSTART mode set ON from shell level
export CLIparm_NOSTART=true
export NOSTART=true
else
# NOSTART mode set to wrong value from shell level
export CLIparm_NOSTART=false
export NOSTART=false
fi
# MODIFIED 2021-02-13 -
export CLIparm_NOHUP=false
export CLIparm_NOHUPScriptName=
export CLIparm_NOHUPDTG=
export CLIparm_NOHUPPATH=
export REMAINS=
#
# /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ MODIFIED 2020-11-19
# -------------------------------------------------------------------------------------------------
# Define local command line parameter CLIparm values
# -------------------------------------------------------------------------------------------------
#
# -#- Start Making Changes Here -#-
#
#export CLIparm_local1=
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# processcliremains - Local command line parameter processor
# -------------------------------------------------------------------------------------------------
#
# -#- Start Making Changes Here -#-
#
processcliremains () {
#
# -------------------------------------------------------------------------------------------------
# Process command line parameters from the REMAINS returned from the standard handler
# -------------------------------------------------------------------------------------------------
while [ -n "$1" ]; do
# Copy so we can modify it (can't modify $1)
OPT="$1"
# testing
echo 'OPT = '${OPT}
#
# Detect argument termination
if [ x"${OPT}" = x"--" ]; then
shift
for OPT ; do
# MODIFIED 2019-03-08
#LOCALREMAINS="${LOCALREMAINS} \"${OPT}\""
LOCALREMAINS="${LOCALREMAINS} ${OPT}"
done
break
fi
# Parse current opt
while [ x"${OPT}" != x"-" ] ; do
case "${OPT}" in
# Help and Standard Operations
'-?' | --help )
SHOWHELP=true
;;
# Handle --flag=value opts like this
-q=* | --qlocal1=* )
CLIparm_local1="${OPT#*=}"
#shift
;;
# and --flag value opts like this
-q* | --qlocal1 )
CLIparm_local1="$2"
shift
;;
# Anything unknown is recorded for later
* )
# MODIFIED 2019-03-08
#LOCALREMAINS="${LOCALREMAINS} \"${OPT}\""
LOCALREMAINS="${LOCALREMAINS} ${OPT}"
break
;;
esac
# Check for multiple short options
# NOTICE: be sure to update this pattern to match valid options
# Remove any characters matching "-", and then the values between []'s
#NEXTOPT="${OPT#-[upmdsor?]}" # try removing single short opt
NEXTOPT="${OPT#-[vrf?]}" # try removing single short opt
if [ x"${OPT}" != x"${NEXTOPT}" ] ; then
OPT="-${NEXTOPT}" # multiple short opts, keep going
else
break # long form, exit inner loop
fi
done
# Done with that param. move to next
shift
done
# Set the non-parameters back into the positional parameters ($1 $2 ..)
eval set -- ${LOCALREMAINS}
export CLIparm_local1=$CLIparm_local1
}
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# dumpcliparmparselocalresults
# -------------------------------------------------------------------------------------------------
#
# -#- Start Making Changes Here -#-
#
# MODIFIED 2020-09-11 \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#
dumpcliparmparselocalresults () {
#
# Testing - Dump acquired local values
#
#
workoutputfile=/var/tmp/workoutputfile.2.${DATEDTGS}.txt
echo > ${workoutputfile}
# Screen width template for sizing, default width of 80 characters assumed
#
# 1111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
echo 'Local CLI Parameters :' >> ${workoutputfile}
echo >> ${workoutputfile}
#echo 'CLIparm_local1 = '$CLIparm_local1 >> ${workoutputfile}
#echo 'CLIparm_local2 = '$CLIparm_local2 >> ${workoutputfile}
echo >> ${workoutputfile}
echo 'LOCALREMAINS = '${LOCALREMAINS} >> ${workoutputfile}
if ${B4CPSCRIPTVERBOSE} ; then
# Verbose mode ON
echo | tee -a -i ${logfilepath}
cat ${workoutputfile} | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
for i ; do echo - $i | tee -a -i ${logfilepath} ; done
echo | tee -a -i ${logfilepath}
echo CLI parms - number "$#" parms "$@" | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
if ! ${NOWAIT} ; then
read -t ${WAITTIME} -n 1 -p "Any key to continue. Automatic continue after ${WAITTIME} seconds : " anykey
echo
fi
echo | tee -a -i ${logfilepath}
echo "End of local execution" | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo '--------------------------------------------------------------------------' | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
else
# Verbose mode OFF
echo >> ${logfilepath}
cat ${workoutputfile} >> ${logfilepath}
echo >> ${logfilepath}
for i ; do echo - $i >> ${logfilepath} ; done
echo >> ${logfilepath}
echo CLI parms - number "$#" parms "$@" >> ${logfilepath}
echo >> ${logfilepath}
fi
rm ${workoutputfile}
}
#
# /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ MODIFIED 2020-09-11
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# End: Local Command Line Parameter Handling and Help Configuration and Local Handling
# =================================================================================================
# =================================================================================================
# =================================================================================================
# =================================================================================================
# START: Command Line Parameter Handling and Help
# =================================================================================================
# -------------------------------------------------------------------------------------------------
# dumprawcliremains
# -------------------------------------------------------------------------------------------------
dumprawcliremains () {
#
if ${B4CPSCRIPTVERBOSE} ; then
# Verbose mode ON
echo | tee -a -i ${logfilepath}
echo "Command line parameters remains : " | tee -a -i ${logfilepath}
echo "Number parms $#" | tee -a -i ${logfilepath}
echo "remains raw : \> $@ \<" | tee -a -i ${logfilepath}
parmnum=0
for k ; do
echo -e "${parmnum} \t ${k}" | tee -a -i ${logfilepath}
parmnum=`expr ${parmnum} + 1`
done
echo | tee -a -i ${logfilepath}
else
# Verbose mode OFF
echo >> ${logfilepath}
echo "Command line parameters remains : " >> ${logfilepath}
echo "Number parms $#" >> ${logfilepath}
echo "remains raw : \> $@ \<" >> ${logfilepath}
parmnum=0
for k ; do
echo -e "${parmnum} \t ${k}" >> ${logfilepath}
parmnum=`expr ${parmnum} + 1`
done
echo >> ${logfilepath}
fi
}
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# CommandLineParameterHandler - Command Line Parameter Handler calling routine
# -------------------------------------------------------------------------------------------------
# MODIFIED 2018-11-20 -\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
#
CommandLineParameterHandler () {
#
# CommandLineParameterHandler - Command Line Parameter Handler calling routine
#
# -------------------------------------------------------------------------------------------------
# Check Command Line Parameter Handlerr action script exists
# -------------------------------------------------------------------------------------------------
# MODIFIED 2018-11-20 -
export configured_handler_root=${cli_script_cmdlineparm_handler_root}
export actual_handler_root=${configured_handler_root}
if [ "${configured_handler_root}" == "." ] ; then
if [ ${ScriptSourceFolder} != ${localdotpath} ] ; then
# Script is not running from it's source folder, might be linked, so since we expect the handler folder
# to be relative to the script source folder, use the identified script source folder instead
export actual_handler_root=${ScriptSourceFolder}
else
# Script is running from it's source folder
export actual_handler_root=${configured_handler_root}
fi
else
# handler root path is not period (.), so stipulating fully qualified path
export actual_handler_root=${configured_handler_root}
fi
export cli_script_cmdlineparm_handler_path=${actual_handler_root}/${cli_script_cmdlineparm_handler_folder}
export cli_script_cmdlineparm_handler=${cli_script_cmdlineparm_handler_path}/${cli_script_cmdlineparm_handler_file}
# Check that we can finde the command line parameter handler file
#
if [ ! -r ${cli_script_cmdlineparm_handler} ] ; then
# no file found, that is a problem
if ${B4CPSCRIPTVERBOSE} ; then
echo | tee -a -i ${logfilepath}
echo 'Command Line Parameter handler script file missing' | tee -a -i ${logfilepath}
echo ' File not found : '${cli_script_cmdlineparm_handler} | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo 'Other parameter elements : ' | tee -a -i ${logfilepath}
echo ' Configured Root path : '${configured_handler_root} | tee -a -i ${logfilepath}
echo ' Actual Script Root path : '${actual_handler_root} | tee -a -i ${logfilepath}
echo ' Root of folder path : '${cli_script_cmdlineparm_handler_root} | tee -a -i ${logfilepath}
echo ' Folder in Root path : '${cli_script_cmdlineparm_handler_folder} | tee -a -i ${logfilepath}
echo ' Folder Root path : '${cli_script_cmdlineparm_handler_path} | tee -a -i ${logfilepath}
echo ' Script Filename : '${cli_script_cmdlineparm_handler_file} | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo 'Critical Error - Exiting Script !!!!' | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo "Log output in file ${logfilepath}" | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
else
echo | tee -a -i ${logfilepath}
echo 'Command Line Parameter handler script file missing' | tee -a -i ${logfilepath}
echo ' File not found : '${cli_script_cmdlineparm_handler} | tee -a -i ${logfilepath}
echo 'Critical Error - Exiting Script !!!!' | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo "Log output in file ${logfilepath}" | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
fi
exit 251
fi
# -------------------------------------------------------------------------------------------------
# Call Command Line Parameter Handlerr action script exists
# -------------------------------------------------------------------------------------------------
if ${B4CPSCRIPTVERBOSE} ; then
echo | tee -a -i ${logfilepath}
echo '--------------------------------------------------------------------------' | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo "Calling external Command Line Paramenter Handling Script" | tee -a -i ${logfilepath}
echo " - External Script : "${cli_script_cmdlineparm_handler} | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
fi
. ${cli_script_cmdlineparm_handler} "$@"
if ${B4CPSCRIPTVERBOSE} ; then
echo | tee -a -i ${logfilepath}
echo "Returned from external Command Line Paramenter Handling Script" | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
if ! ${NOWAIT} ; then
read -t ${WAITTIME} -n 1 -p "Any key to continue. Automatic continue after ${WAITTIME} seconds : " anykey
echo
fi
echo | tee -a -i ${logfilepath}
echo "Starting local execution" | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
echo '--------------------------------------------------------------------------' | tee -a -i ${logfilepath}
echo | tee -a -i ${logfilepath}
fi
}
#
# \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/- MODIFIED 2018-10-03
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Call command line parameter handler action script
# -------------------------------------------------------------------------------------------------
# MODIFIED 2018-10-03 -
CommandLineParameterHandler "$@"
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# -------------------------------------------------------------------------------------------------
# Handle locally defined command line parameters