Skip to content

Commit 60a408b

Browse files
committed
fix: adding validation for mode and adding missing sm installation for rpm based systems
1 parent 6aa8dc7 commit 60a408b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

static/scripts/install-nim-bundle.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,32 @@ installBundleForRPMDistro(){
474474
echo "Restarting NGINX Instance Manager"
475475
systemctl restart nms
476476

477+
if [ "${USE_SM_MODULE}" == "true" ]; then
478+
nim_major_version=$(nms-core --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | awk -F. '{print $1}')
479+
nim_minor_version=$(nms-core --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | awk -F. '{print $1}')
480+
if [[ $nim_major_version -ge 2 && $nim_minor_version -ge 19 ]]; then
481+
echo "Note: NGINX Instance Manager version 2.19.0 or later comes with security monitoring installed. skipping installing security monitoring"
482+
else
483+
printf "Installing security module...\n"
484+
if [ "${NIM_SM_VERSION}" == "latest" ]; then
485+
yum install -y nms-sm
486+
check_last_command_status "yum install -y nms-sm" $?
487+
else
488+
sm_pkg_version=$(findVersionForPackage "nms-sm" "${NIM_SM_VERSION}")
489+
cmd_status=$?
490+
if [ $cmd_status -ne 0 ]; then
491+
echo "Package nms-sm with version ${NIM_SM_VERSION} not found"
492+
exit $cmd_status
493+
fi
494+
yum install -y nms-sm="${sm_pkg_version}"
495+
check_last_command_status "yum install -y nms-sm=${NIM_SM_VERSION}" $?
496+
fi
497+
systemctl restart nms
498+
sleep 5
499+
systemctl restart nginx
500+
systemctl start nms-sm
501+
fi
502+
477503
sleep 5
478504

479505
echo "Restarting nginx API gateway"
@@ -699,6 +725,11 @@ while getopts ${OPTS_STRING} opt; do
699725
;;
700726
m)
701727
MODE="${OPTARG}"
728+
if [[ "${MODE}" != "online" || "${MODE}" != "offline" ]]; then
729+
echo "invalid mode ${MODE}"
730+
echo "supported values for mode are 'online' or 'offline'"
731+
exit 1
732+
fi
702733
;;
703734
d)
704735
TARGET_DISTRIBUTION=${OPTARG}

0 commit comments

Comments
 (0)