Skip to content

Commit

Permalink
[BUG][Mountscript] Exit on Unsupported Distro (#146)
Browse files Browse the repository at this point in the history
* Bug Fix

* Bug Fix Unknown Linux Distro

* remove extra line

* update with comments, adding AZNFS_FORCE_PACKAGE_MANAGER

* syntax fix

* readme edit

* addressing online comments

* online review

* online review

* review online

* update

* update readme

* update

* remove blank lines

* adding error catch statement, removing centro as recog distro (for testing)

* update env variable usage

* addressing review comments
  • Loading branch information
palashvij-msft authored Nov 5, 2024
1 parent 9066360 commit c5b4568
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ IP prefixes with either 2 or 3 octets can be set `f.e. 10.100 10.100.100 172.16
It starts a systemd service named **aznfswatchdog** which monitors the change in IP address for all the mounted Azure
Blob NFS shares. If it detects a change in endpoint IP, aznfswatchdog will update the iptables DNAT rule and NFS
traffic will be forwarded to new endpoint IP.
> [!NOTE]
> After an Azure Blob NFS endpoint is unmounted, the local proxy IP-to-endpoint mapping remains cached in the mountmap for 5 minutes. If the same endpoint is remounted within this period, it will automatically reuse the previous proxy IP address. During this period, it will ignore `AZNFS_IP_PREFIXES` environment variable if it is set.
## Limitations

Expand Down
48 changes: 45 additions & 3 deletions scripts/aznfs_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,57 @@ ensure_pkg()
fi
apt=1
apt install -y $pkg
install_error=$?
elif [ "$distro" == "centos" -o "$distro" == "rocky" -o "$distro" == "rhel" -o "$distro" == "mariner" ]; then
# lsb_release package is called redhat-lsb-core in redhat/centos.
if [ "$pkg" == "lsb-release" ]; then
pkg="redhat-lsb-core"
fi
use_dnf_or_yum
$yum install -y $pkg
install_error=$?
elif [ "$distro" == "sles" ]; then
zypper=1
zypper install -y $pkg
install_error=$?
elif [ -n "$AZNFS_FORCE_PACKAGE_MANAGER" ]; then
case "$AZNFS_FORCE_PACKAGE_MANAGER" in
apt)
apt=1
wecho "[WARNING] Forcing package manager '$AZNFS_FORCE_PACKAGE_MANAGER' on unsupported distro <$distro>"
wecho "[WARNING] Proceeding with the AZNFS installation, please contact Microsoft support in case of any issues."
apt install -y $pkg
install_error=$?
;;
yum|dnf)
yum=$AZNFS_FORCE_PACKAGE_MANAGER
wecho "[WARNING] Forcing package manager '$AZNFS_FORCE_PACKAGE_MANAGER' on unsupported distro <$distro>"
wecho "[WARNING] Proceeding with the AZNFS installation, please contact Microsoft support in case of any issues."
$yum install -y $pkg
install_error=$?
;;
zypper)
zypper=1
wecho "[WARNING] Forcing package manager '$AZNFS_FORCE_PACKAGE_MANAGER' on unsupported distro <$distro>"
wecho "[WARNING] Proceeding with the AZNFS installation, please contact Microsoft support in case of any issues."
zypper install -y $pkg
install_error=$?
;;
*)
eecho "[FATAL] Unsupported value for AZNFS_FORCE_PACKAGE_MANAGER <$AZNFS_FORCE_PACKAGE_MANAGER>. Use 'apt', 'yum', 'dnf', or 'zypper'"
exit 1
;;
esac
else
eecho "[FATAL] Unsupported linux distro <$distro>"
pecho "Check 'https://github.com/Azure/AZNFS-mount/blob/main/README.md#supported-distros' to see the list of supported distros"
pecho "Download .deb/.rpm package based on your distro from 'https://github.com/Azure/AZNFS-mount/releases/latest' or try running install after setting env variable 'AZNFS_FORCE_PACKAGE_MANAGER' to one of 'apt', 'yum', 'dnf', or 'zypper'"
exit 1
fi

if [ $install_error -ne 0 ]; then
eecho "[FATAL] Error installing $pkg (Error: $install_error)"
exit 1
fi
}

Expand Down Expand Up @@ -382,8 +423,9 @@ case "${__m}:${__s}" in
distro_id=$(canonicalize_distro_id $distro_id)
else
eecho "[FATAL] Unknown linux distro, /etc/os-release not found!"
pecho "Download .deb/.rpm package based on your distro from 'https://github.com/Azure/AZNFS-mount/releases/latest'"
pecho "Download .deb/.rpm package based on your distro from 'https://github.com/Azure/AZNFS-mount/releases/latest' or try running install after setting env variable 'AZNFS_FORCE_PACKAGE_MANAGER' to one of 'apt', 'yum', 'dnf', or 'zypper'"
pecho "If the problem persists, contact Microsoft support."
exit 1
fi
;;
*)
Expand Down Expand Up @@ -457,8 +499,8 @@ elif [ $zypper -eq 1 ]; then
perform_aznfs_update

else
install_cmd="yum"
current_version=$(yum info aznfs 2>/dev/null | grep "^Version" | tr -d " " | cut -d ':' -f2)
install_cmd=$yum
current_version=$($install_cmd info aznfs 2>/dev/null | grep "^Version" | tr -d " " | cut -d ':' -f2)
# Without current version, auto-update cannot proceed.
if [ "$RUN_MODE" == "auto-update" ] && [ -z "$current_version" ]; then
eecho "Unable to retrieve the current version of AZNFS, exiting!"
Expand Down

0 comments on commit c5b4568

Please sign in to comment.