Skip to content

Commit 38474a1

Browse files
bejjrajeshADubhlaoichmjang
authored
fixing keepalived dependency for offline installation(NIM) (#233)
* fix: fixing nim dependency on keepalived * fix: fixing nim dependency on keepalived * fix: fixing rpm pkg name typo * fix: fixing rpm pkg name typo * fix: fixing keepalived folders * fix: fixing keepalived dependency issue * Apply suggestions from code review * Apply suggestions from code review --------- Co-authored-by: Alan Dooley <[email protected]> Co-authored-by: Mike Jang <[email protected]>
1 parent b16df35 commit 38474a1

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

static/scripts/install-nim-bundle.sh

+47-1
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,41 @@ This action deletes all files in the following directories: /etc/nms , /etc/ngin
697697
fi
698698
}
699699

700+
download_third_party_dependencies(){
701+
if cat /etc/*-release | grep -iq 'debian\|ubuntu'; then
702+
if echo "${target_distribution}" | grep -iq 'debian\|ubuntu'; then
703+
mkdir "${TEMP_DIR}/${target_distribution}/keepalived"
704+
apt-get install --download-only -o Dir::Cache="${TEMP_DIR}/${target_distribution}/keepalived" keepalived
705+
else
706+
if command -v docker >/dev/null 2>&1; then
707+
mkdir "${TEMP_DIR}/${target_distribution}/keepalived"
708+
docker run --rm -it -v "${TEMP_DIR}/${target_distribution}/keepalived":/downloads fedora dnf download --resolve --destdir=/downloads keepalived
709+
else
710+
echo "Cross platform packing requires Docker. Please install Docker and try again."
711+
exit 1
712+
fi
713+
fi
714+
elif cat /etc/*-release | grep -iq 'centos\|fedora\|rhel\|Amazon Linux'; then
715+
if echo "${target_distribution}" | grep -iq 'centos\|fedora\|rhel\|Amazon Linux'; then
716+
mkdir "${TEMP_DIR}/${target_distribution}/keepalived"
717+
yumdownloader --destdir="${TEMP_DIR}/${target_distribution}/keepalived" --resolve keepalived
718+
else
719+
if command -v docker >/dev/null 2>&1; then
720+
mkdir -p "${TEMP_DIR}/keepalived"
721+
docker run --rm -it -v "${TEMP_DIR}/keepalived":/tmp/nim ubuntu bash -c "apt-get update && mkdir -p /tmp/nim && apt-get install -y --download-only -o Dir::Cache=\"/tmp/nim\" keepalived"
722+
mkdir "${TEMP_DIR}/${target_distribution}/keepalived"
723+
mv ${TEMP_DIR}/keepalived/archives/* ${TEMP_DIR}/${target_distribution}/keepalived
724+
else
725+
echo "Cross platform packing requires Docker. Please install Docker and try again."
726+
exit 1
727+
fi
728+
fi
729+
else
730+
printf "Unsupported distribution"
731+
exit 1
732+
fi
733+
}
734+
700735
OPTS_STRING="k:c:m:d:i:s:p:n:hv:t:j:rf:l"
701736
while getopts ${OPTS_STRING} opt; do
702737
case ${opt} in
@@ -938,11 +973,12 @@ else
938973
url_file_download "$file_to_download" "$save_path"
939974
echo "Downloaded NGINX Instance Manager package - $save_path"
940975
done
976+
download_third_party_dependencies
941977
bundle_file="nim-${NIM_VERSION}-${target_distribution}.tar.gz"
942978
echo -n "Creating NGINX Instance Manager install bundle ... ${bundle_file}"
943979
cp ${NGINX_CERT_PATH} "${TEMP_DIR}/${target_distribution}/nginx-repo.crt"
944980
cp ${NGINX_CERT_KEY_PATH} "${TEMP_DIR}/${target_distribution}/nginx-repo.key"
945-
tar -zcf "$bundle_file" -C "${TEMP_DIR}/${target_distribution}" .
981+
tar -zcf "$bundle_file" -C "${TEMP_DIR}/${target_distribution}/" .
946982
echo -e "\nSuccessfully created the NGINX Instance Manager bundle - $bundle_file"
947983
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=offline"
948984

@@ -971,6 +1007,11 @@ else
9711007
DEBIAN_FRONTEND=noninteractive dpkg -i "$pkg_clickhouse_srv"
9721008
check_last_command_status "dpkg -i \"$pkg_clickhouse_srv\"" $?
9731009
done
1010+
if [ -d "${TEMP_DIR}/keepalived" ]; then
1011+
echo "Installing keepalived from ${TEMP_DIR}/keepalived"
1012+
DEBIAN_FRONTEND=noninteractive dpkg -i ${TEMP_DIR}/keepalived/*.deb
1013+
check_last_command_status "dpkg -i ${TEMP_DIR}/keepalived/*.deb" $?
1014+
fi
9741015
for pkg_nim in "${TEMP_DIR}"/nms-instance-manager*.deb; do
9751016
echo "Installing NGINX Instance Manager from ${pkg_nim}"
9761017
DEBIAN_FRONTEND=noninteractive dpkg -i "$pkg_nim"
@@ -1005,6 +1046,11 @@ else
10051046
echo "Installing clickhouse dependencies from ${pkg_clickhouse}"
10061047
yum localinstall -y -v --disableplugin=subscription-manager --skip-broken "$pkg_clickhouse_srv"
10071048
done
1049+
if [ -d "${TEMP_DIR}/keepalived" ]; then
1050+
echo "Installing keepalived from ${TEMP_DIR}/keepalived"
1051+
yum localinstall -y -v --disableplugin=subscription-manager --skip-broken "${TEMP_DIR}/keepalived/*.rpm"
1052+
check_last_command_status "dpkg -i yum localinstall -y -v --disableplugin=subscription-manager --skip-broken ${TEMP_DIR}/keepalived/*.rpm" $?
1053+
fi
10081054
for pkg_nim in "${TEMP_DIR}"/nms-instance-manager*.rpm; do
10091055
echo "Installing NGINX Instance Manager from ${pkg_nim}"
10101056
yum localinstall -y -v --disableplugin=subscription-manager --skip-broken "$pkg_nim"

0 commit comments

Comments
 (0)