@@ -15,11 +15,6 @@ if ! cmd=$(command -v "tar") || [ ! -x "$cmd" ]; then
15
15
exit 1
16
16
fi
17
17
18
- if ! cmd=$( command -v " wget" ) || [ ! -x " $cmd " ]; then
19
- echo " wget command not found. Install wget to run this script."
20
- exit 1
21
- fi
22
-
23
18
NGINX_CERT_PATH=" /etc/ssl/nginx/nginx-repo.crt"
24
19
NGINX_CERT_KEY_PATH=" /etc/ssl/nginx/nginx-repo.key"
25
20
LICENSE_JWT_PATH=" "
@@ -34,14 +29,14 @@ NGINX_PLUS_VERSION="latest"
34
29
NIM_SM_VERSION=" latest"
35
30
CLICKHOUSE_VERSION=" latest"
36
31
CLICKHOUSE_LATEST_VERSION=" 24.9.2.42"
37
- NGINX_LATEST_VERSION=1.25.5 -1
38
- NIM_LATEST_VERSION=2.18 .0
32
+ NGINX_LATEST_VERSION=1.27.3 -1
33
+ NIM_LATEST_VERSION=2.19 .0
39
34
CURRENT_TIME=$( date +%s)
40
35
TEMP_DIR=" /tmp/${CURRENT_TIME} "
41
36
TARGET_DISTRIBUTION=" "
42
37
PACKAGE_INSTALLER=" "
43
38
NMS_NGINX_MGMT_BLOCK=" mgmt { \n usage_report endpoint=127.0.0.1 interval=30m; \n ssl_verify off; \n}" ;
44
-
39
+ NIM_FQDN= " "
45
40
46
41
# Added to account for the renaming of the adc dimension from application to app.
47
42
if [ -f " /usr/share/nms/catalogs/dimensions/application.yml" ]; then
117
112
118
113
createNginxMgmtFile (){
119
114
# Check if the mgmt block exists in the file
120
- if grep -Eq ' ^[[:space:]]*#mgmt' " /etc/nginx/nginx.conf" ; then
121
- printf " nginx management block disabled, enabling mgmt block"
115
+ if grep -Eq ' ^[[:space:]]*mgmt' " /etc/nginx/nginx.conf" ; then
116
+ printf " Nginx 'mgmt' block found, skipping addition of nginx 'mgmt' block"
117
+ elif grep -Eq ' ^[[:space:]]*#mgmt' " /etc/nginx/nginx.conf" ; then
118
+ printf " Nginx 'mgmt' block disabled, enabling 'mgmt' block"
122
119
sed -i ' /#mgmt {/,/#}/d' /etc/nginx/nginx.conf
123
120
# shellcheck disable=SC2059
124
121
printf " ${NMS_NGINX_MGMT_BLOCK} " | tee -a /etc/nginx/nginx.conf
125
122
else
126
- printf " nginx management block not found, adding mgmt block"
123
+ printf " Nginx 'mgmt' block not found, adding ' mgmt' block"
127
124
# shellcheck disable=SC2059
128
125
printf " ${NMS_NGINX_MGMT_BLOCK} " | tee -a /etc/nginx/nginx.conf
129
126
fi
@@ -334,25 +331,32 @@ installBundleForDebianDistro() {
334
331
debian_install_nginx
335
332
debian_install_clickhouse
336
333
debian_install_nim
334
+ echo " security module installation opted : ${USE_SM_MODULE} "
337
335
if [ " ${USE_SM_MODULE} " == " true" ]; then
338
- printf " Installing security module...\n "
339
- if [ " ${NIM_SM_VERSION} " == " latest " ] ; then
340
- apt-get install -y nms-sm
341
- check_last_command_status " apt-get install -y nms-sm " $?
336
+ nim_major_version= $( nms-core --version | grep -oE ' [0-9]+\.[0-9]+\.[0-9]+ ' | awk -F. ' {print $1} ' )
337
+ nim_minor_version= $( nms-core --version | grep -oE ' [0-9]+\.[0-9]+\.[0-9]+ ' | awk -F. ' {print $2} ' )
338
+ if [[ $nim_major_version -ge 2 && $nim_minor_version -ge 19 ]] ; then
339
+ echo " Note: NGINX Instance Manager version 2.19.0 or later comes with security monitoring installed. skipping installing security monitoring "
342
340
else
343
- sm_pkg_version=$( findVersionForPackage " nms-sm" " ${NIM_SM_VERSION} " )
344
- cmd_status=$?
345
- if [ $cmd_status -ne 0 ]; then
346
- echo " Package nms-sm with version ${NIM_SM_VERSION} not found"
347
- exit $cmd_status
341
+ printf " Installing security module...\n"
342
+ if [ " ${NIM_SM_VERSION} " == " latest" ]; then
343
+ apt-get install -y nms-sm
344
+ check_last_command_status " apt-get install -y nms-sm" $?
345
+ else
346
+ sm_pkg_version=$( findVersionForPackage " nms-sm" " ${NIM_SM_VERSION} " )
347
+ cmd_status=$?
348
+ if [ $cmd_status -ne 0 ]; then
349
+ echo " Package nms-sm with version ${NIM_SM_VERSION} not found"
350
+ exit $cmd_status
351
+ fi
352
+ apt-get install -y nms-sm=" ${sm_pkg_version} "
353
+ check_last_command_status " apt-get install -y nms-sm=${NIM_SM_VERSION} " $?
348
354
fi
349
- apt-get install -y nms-sm=" ${sm_pkg_version} "
350
- check_last_command_status " apt-get install -y nms-sm=${NIM_SM_VERSION} " $?
355
+ systemctl restart nms
356
+ sleep 5
357
+ systemctl restart nginx
358
+ systemctl start nms-sm
351
359
fi
352
- systemctl restart nms
353
- sleep 5
354
- systemctl restart nginx
355
- systemctl start nms-sm
356
360
else
357
361
systemctl restart nms
358
362
sleep 5
@@ -393,7 +397,7 @@ installBundleForRPMDistro(){
393
397
fi
394
398
printf " [nginx-plus]\nname=nginx-plus repo\nbaseurl=https://pkgs.nginx.com/plus/$os_type /\$ releasever/\$ basearch/\nsslclientcert=/etc/ssl/nginx/nginx-repo.crt\nsslclientkey=/etc/ssl/nginx/nginx-repo.key\ngpgcheck=0\nenabled=1" >> /etc/yum.repos.d/nginx-plus.repo
395
399
396
- yum install -y yum-utils wget epel-release ca-certificates
400
+ yum install -y yum-utils curl epel-release ca-certificates
397
401
yum-config-manager --enable nginx-stable
398
402
yum-config-manager --enable nginx-plus
399
403
@@ -449,7 +453,7 @@ installBundleForRPMDistro(){
449
453
systemctl start clickhouse-server
450
454
check_last_command_status " systemctl start clickhouse-server" $?
451
455
452
- wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/nms.repo
456
+ curl -o /etc/yum.repos.d/nms.repo https://cs.nginx.com/static/files/nms.repo
453
457
check_last_command_status " get -P /etc/yum.repos.d https://cs.nginx.com/static/files/nms.repo" $?
454
458
455
459
if cat /etc/* -release | grep -iq ' Amazon Linux' ; then
@@ -471,8 +475,33 @@ installBundleForRPMDistro(){
471
475
echo " Restarting NGINX Instance Manager"
472
476
systemctl restart nms
473
477
478
+ if [ " ${USE_SM_MODULE} " == " true" ]; then
479
+ nim_major_version=$( nms-core --version | grep -oE ' [0-9]+\.[0-9]+\.[0-9]+' | awk -F. ' {print $1}' )
480
+ nim_minor_version=$( nms-core --version | grep -oE ' [0-9]+\.[0-9]+\.[0-9]+' | awk -F. ' {print $1}' )
481
+ if [[ $nim_major_version -ge 2 && $nim_minor_version -ge 19 ]]; then
482
+ echo " Note: NGINX Instance Manager version 2.19.0 or later comes with security monitoring installed. skipping installing security monitoring"
483
+ else
484
+ printf " Installing security module...\n"
485
+ if [ " ${NIM_SM_VERSION} " == " latest" ]; then
486
+ yum install -y nms-sm
487
+ check_last_command_status " yum install -y nms-sm" $?
488
+ else
489
+ sm_pkg_version=$( findVersionForPackage " nms-sm" " ${NIM_SM_VERSION} " )
490
+ cmd_status=$?
491
+ if [ $cmd_status -ne 0 ]; then
492
+ echo " Package nms-sm with version ${NIM_SM_VERSION} not found"
493
+ exit $cmd_status
494
+ fi
495
+ yum install -y nms-sm=" ${sm_pkg_version} "
496
+ check_last_command_status " yum install -y nms-sm=${NIM_SM_VERSION} " $?
497
+ fi
498
+ systemctl restart nms
499
+ sleep 5
500
+ systemctl restart nginx
501
+ systemctl start nms-sm
502
+ fi
503
+ fi
474
504
sleep 5
475
-
476
505
echo " Restarting nginx API gateway"
477
506
systemctl restart nginx
478
507
}
@@ -495,30 +524,51 @@ install_nim_online(){
495
524
PACKAGE_INSTALLER=" rpm"
496
525
installBundleForRPMDistro
497
526
generate
527
+
498
528
else
499
529
printf " Unsupported distribution"
500
530
exit 1
501
531
fi
532
+ if [[ -n ${NIM_FQDN} ]] ; then
533
+ /etc/nms/scripts/certs.sh ${NIM_FQDN}
534
+ fi
535
+ curl -s -o /dev/null --cert ${NGINX_CERT_PATH} --key ${NGINX_CERT_KEY_PATH} " https://pkgs.nginx.com/nms/?using_install_script=true&app=nim&mode=online"
502
536
}
503
537
504
538
printUsageInfo (){
505
- echo " Usage: $0 [-c /path/to/nginx-repo.crt] [-k /path/to/nginx-repo.key] [-p nginx_plus_version] [-s security_module_version] -i [installable_tar_file_path] [-n nginx_oss_version] [-m mode(online/offline)]
506
- [-d distribution (ubuntu20.04,ubuntu22.04,ubuntu24.04,debian11,debian12,centos8,rhel8,rhel9,oracle7,oracle8,amzn2)] [-h print help]"
507
- printf " \n -m <mode> Online/Offline. Controls whether to install from the internet or from a package created using this script. \n"
539
+ echo " Usage: $0 [-c /path/to/nginx-repo.crt] [-k /path/to/nginx-repo.key] [-p nginx_plus_version] [-s security_module_version] -i [installable_tar_file_path] [-n nginx_oss_version] [-m mode(online/offline)] [-d distribution (ubuntu20.04,ubuntu22.04,ubuntu24.04,debian11,debian12,centos8,rhel8,rhel9,oracle7,oracle8,amzn2)] [-h print help]"
540
+ printf " \n\n -m <mode> online/offline. Controls whether to install from the internet or from a package created using this script. \n"
508
541
printf " \n -c /path/to/your/<nginx-repo.crt> file.\n"
509
542
printf " \n -k /path/to/your/<nginx-repo.key> file.\n"
510
543
printf " \n -p <nginx_plus_version>. Include NGINX Plus version to install as an API gateway. Valid values are 'latest' and specific versions like R32. For a list, see https://docs.nginx.com/nginx/releases/. Supersedes -n.\n"
511
544
printf " \n -n <nginx_oss_version>. Provide NGINX OSS version to install as an API gateway. Valid values are 'latest' or a specific version like 1.27.1. Ignored if you use -p to specify an NGINX Plus version. For a list, see https://nginx.org/en/download.html .\n"
512
- printf " \n -s <security-module-version>. Installs a security module along with NGINX Instance Manager. You can specify latest or a version specified in https://docs.nginx.com/nginx-management-suite/ security/releases/release-notes/.\n"
545
+ printf " \n -s <security-module-version>. Installs a security module along with NGINX Instance Manager. You can specify latest or a version specified in https://docs.nginx.com/nginx-instance-manager/monitoring/ security-monitoring /releases/release-notes/.\n"
513
546
printf " \n -i <installable_tar_file_path>. Include the path with an archive file to support NGINX Instance Manager installation. Requires -m Offline."
514
547
printf " \n -d <distribution>. Include the label of a distribution. Requires -m Offline. This creates a file with NGINX Instance Manager dependencies and NGINX Instance Manager install packages for the specified distribution.\n"
515
548
printf " \n -v <NIM_VERSION>. NGINX Instance Manager version to install/package.\n"
516
- printf " \n -j <JWT_TOKEN_FILE_PATH>. Path to the JWT token file used for license and usage consumption reporting.' \n"
549
+ printf " \n -j <JWT_TOKEN_FILE_PATH>. Path to the JWT token file used for license and usage consumption reporting.\n"
517
550
printf " \n -r To uninstall NGINX Instance Manager and its dependencies. \n"
551
+ printf " \n -l Print supported operating systems.\n"
518
552
printf " \n -h Print this help message.\n"
519
553
exit 0
520
554
}
521
555
556
+ printSupportedOS (){
557
+ printf " This script can be run on the following operating systems"
558
+ printf " \n 1. ubuntu20.04(focal)"
559
+ printf " \n 2. ubuntu22.04(jammy)"
560
+ printf " \n 3. ubuntu24.04(noble)"
561
+ printf " \n 4. debian11(bullseye)"
562
+ printf " \n 5. debian12(bookworm)"
563
+ printf " \n 6. centos8(CentOS 8)"
564
+ printf " \n 7. rhel8(Redhat Enterprise Linux Version 8)"
565
+ printf " \n 8. rhel9( Redhat Enterprise Linux Version 9)"
566
+ printf " \n 9. oracle7(Oracle Linux Version 7)"
567
+ printf " \n 10. oracle8(Oracle Linux Version 8)"
568
+ printf " \n 11. amzn2(Amazon Linux 2)\n"
569
+ exit 0
570
+ }
571
+
522
572
check_NIM_status (){
523
573
sleep 5
524
574
GREEN=' \033[0;32m'
@@ -641,7 +691,7 @@ This action deletes all files in the following directories: /etc/nms , /etc/ngin
641
691
fi
642
692
}
643
693
644
- OPTS_STRING=" k:c:m:d:i:s:p:n:hv:t:j:r "
694
+ OPTS_STRING=" k:c:m:d:i:s:p:n:hv:t:j:rf:l "
645
695
while getopts ${OPTS_STRING} opt; do
646
696
case ${opt} in
647
697
c)
@@ -676,6 +726,11 @@ while getopts ${OPTS_STRING} opt; do
676
726
;;
677
727
m)
678
728
MODE=" ${OPTARG} "
729
+ if [[ " ${MODE} " != " online" && " ${MODE} " != " offline" ]]; then
730
+ echo " invalid mode ${MODE} "
731
+ echo " supported values for mode are 'online' or 'offline'"
732
+ exit 1
733
+ fi
679
734
;;
680
735
d)
681
736
TARGET_DISTRIBUTION=${OPTARG}
@@ -692,13 +747,17 @@ while getopts ${OPTS_STRING} opt; do
692
747
r)
693
748
UNINSTALL_NIM=" true"
694
749
;;
750
+ f)
751
+ NIM_FQDN=${OPTARG}
752
+ ;;
695
753
h)
696
- printUsageInfo
697
754
printUsageInfo
698
755
exit 0
699
- printUsageInfo
700
- exit 0
701
756
;;
757
+ l)
758
+ printSupportedOS
759
+ exit 0
760
+ ;;
702
761
:)
703
762
echo " Option -${OPTARG} requires an argument."
704
763
exit 1
@@ -968,5 +1027,6 @@ else
968
1027
echo " Provided install path ${INSTALL_PATH} doesn't exists"
969
1028
exit 1
970
1029
fi
1030
+ curl -s -o /dev/null --cert ${NGINX_CERT_PATH} --key ${NGINX_CERT_KEY_PATH} " https://pkgs.nginx.com/nms/?using_install_script=true&app=nim&mode=online"
971
1031
fi
972
1032
fi
0 commit comments