Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions AzureMonitorAgent/shim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ ARG="$@"

function find_python() {
local python_exec_command=$1

if command -v python3 >/dev/null 2>&1 ; then
if command -v /usr/libexec/platform-python >/dev/null 2>&1 ; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok to check in this order for non-RHEL8 distros?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — with one caveat: this changes behavior only on systems where /usr/libexec/platform-python actually exists. If that path is not present, the logic still falls through to python3 and then python2 as before

# Prefer platform-python when available — this is the python waagent uses (RHEL 8+)
# and ensures AMA uses the same interpreter with the same installed modules.
eval ${python_exec_command}="/usr/libexec/platform-python"
elif command -v python3 >/dev/null 2>&1 ; then
eval ${python_exec_command}="python3"
elif command -v python2 >/dev/null 2>&1 ; then
eval ${python_exec_command}="python2"
elif command -v /usr/libexec/platform-python >/dev/null 2>&1 ; then
# If a user-installed python isn't available, check for a platform-python. This is typically only used in RHEL 8.0.
echo "User-installed python not found. Using /usr/libexec/platform-python as the python interpreter."
eval ${python_exec_command}="/usr/libexec/platform-python"
fi

}

find_python PYTHON
Expand Down