@@ -15,11 +15,6 @@ if ! cmd=$(command -v "tar") || [ ! -x "$cmd" ]; then
1515 exit 1
1616fi
1717
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-
2318NGINX_CERT_PATH=" /etc/ssl/nginx/nginx-repo.crt"
2419NGINX_CERT_KEY_PATH=" /etc/ssl/nginx/nginx-repo.key"
2520LICENSE_JWT_PATH=" "
@@ -34,14 +29,14 @@ NGINX_PLUS_VERSION="latest"
3429NIM_SM_VERSION=" latest"
3530CLICKHOUSE_VERSION=" latest"
3631CLICKHOUSE_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
3934CURRENT_TIME=$( date +%s)
4035TEMP_DIR=" /tmp/${CURRENT_TIME} "
4136TARGET_DISTRIBUTION=" "
4237PACKAGE_INSTALLER=" "
4338NMS_NGINX_MGMT_BLOCK=" mgmt { \n usage_report endpoint=127.0.0.1 interval=30m; \n ssl_verify off; \n}" ;
44-
39+ NIM_FQDN= " "
4540
4641# Added to account for the renaming of the adc dimension from application to app.
4742if [ -f " /usr/share/nms/catalogs/dimensions/application.yml" ]; then
117112
118113createNginxMgmtFile (){
119114 # 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"
122119 sed -i ' /#mgmt {/,/#}/d' /etc/nginx/nginx.conf
123120 # shellcheck disable=SC2059
124121 printf " ${NMS_NGINX_MGMT_BLOCK} " | tee -a /etc/nginx/nginx.conf
125122 else
126- printf " nginx management block not found, adding mgmt block"
123+ printf " Nginx 'mgmt' block not found, adding ' mgmt' block"
127124 # shellcheck disable=SC2059
128125 printf " ${NMS_NGINX_MGMT_BLOCK} " | tee -a /etc/nginx/nginx.conf
129126 fi
@@ -334,25 +331,32 @@ installBundleForDebianDistro() {
334331 debian_install_nginx
335332 debian_install_clickhouse
336333 debian_install_nim
334+ echo " security module installation opted : ${USE_SM_MODULE} "
337335 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 "
342340 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} " $?
348354 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
351359 fi
352- systemctl restart nms
353- sleep 5
354- systemctl restart nginx
355- systemctl start nms-sm
356360 else
357361 systemctl restart nms
358362 sleep 5
@@ -393,7 +397,7 @@ installBundleForRPMDistro(){
393397 fi
394398 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
395399
396- yum install -y yum-utils wget epel-release ca-certificates
400+ yum install -y yum-utils curl epel-release ca-certificates
397401 yum-config-manager --enable nginx-stable
398402 yum-config-manager --enable nginx-plus
399403
@@ -449,7 +453,7 @@ installBundleForRPMDistro(){
449453 systemctl start clickhouse-server
450454 check_last_command_status " systemctl start clickhouse-server" $?
451455
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
453457 check_last_command_status " get -P /etc/yum.repos.d https://cs.nginx.com/static/files/nms.repo" $?
454458
455459 if cat /etc/* -release | grep -iq ' Amazon Linux' ; then
@@ -471,8 +475,33 @@ installBundleForRPMDistro(){
471475 echo " Restarting NGINX Instance Manager"
472476 systemctl restart nms
473477
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
474504 sleep 5
475-
476505 echo " Restarting nginx API gateway"
477506 systemctl restart nginx
478507}
@@ -495,30 +524,51 @@ install_nim_online(){
495524 PACKAGE_INSTALLER=" rpm"
496525 installBundleForRPMDistro
497526 generate
527+
498528 else
499529 printf " Unsupported distribution"
500530 exit 1
501531 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"
502536}
503537
504538printUsageInfo (){
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"
508541 printf " \n -c /path/to/your/<nginx-repo.crt> file.\n"
509542 printf " \n -k /path/to/your/<nginx-repo.key> file.\n"
510543 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"
511544 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"
513546 printf " \n -i <installable_tar_file_path>. Include the path with an archive file to support NGINX Instance Manager installation. Requires -m Offline."
514547 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"
515548 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"
517550 printf " \n -r To uninstall NGINX Instance Manager and its dependencies. \n"
551+ printf " \n -l Print supported operating systems.\n"
518552 printf " \n -h Print this help message.\n"
519553 exit 0
520554}
521555
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+
522572check_NIM_status (){
523573 sleep 5
524574 GREEN=' \033[0;32m'
@@ -641,7 +691,7 @@ This action deletes all files in the following directories: /etc/nms , /etc/ngin
641691 fi
642692}
643693
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 "
645695while getopts ${OPTS_STRING} opt; do
646696 case ${opt} in
647697 c)
@@ -676,6 +726,11 @@ while getopts ${OPTS_STRING} opt; do
676726 ;;
677727 m)
678728 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
679734 ;;
680735 d)
681736 TARGET_DISTRIBUTION=${OPTARG}
@@ -692,13 +747,17 @@ while getopts ${OPTS_STRING} opt; do
692747 r)
693748 UNINSTALL_NIM=" true"
694749 ;;
750+ f)
751+ NIM_FQDN=${OPTARG}
752+ ;;
695753 h)
696- printUsageInfo
697754 printUsageInfo
698755 exit 0
699- printUsageInfo
700- exit 0
701756 ;;
757+ l)
758+ printSupportedOS
759+ exit 0
760+ ;;
702761 :)
703762 echo " Option -${OPTARG} requires an argument."
704763 exit 1
@@ -968,5 +1027,6 @@ else
9681027 echo " Provided install path ${INSTALL_PATH} doesn't exists"
9691028 exit 1
9701029 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"
9711031 fi
9721032fi
0 commit comments