-
Notifications
You must be signed in to change notification settings - Fork 254
/
omsagent_shim.sh
32 lines (25 loc) · 952 Bytes
/
omsagent_shim.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
# The entry point for the OMS extension through which the correct python version (if any) is used to invoke omsagent.py.
# We default to python2 and always invoke with the versioned python command to accomodate the RHEL 8+ python strategy.
# Control arguments passed to the shim are redirected to omsagent.py without validation.
COMMAND="./omsagent.py"
PYTHON=""
ARG="$@"
function find_python() {
local python_exec_command=$1
if command -v python2 >/dev/null 2>&1 ; then
eval ${python_exec_command}="python2"
elif command -v python3 >/dev/null 2>&1 ; then
eval ${python_exec_command}="python3"
fi
}
find_python PYTHON
if [ -z "$PYTHON" ]
then
echo "No Python interpreter found, which is an OMS extension dependency. Please install either Python 2 or 3." >&2
exit 52 # Missing Dependency
else
${PYTHON} --version 2>&1
fi
PYTHONPATH=${PYTHONPATH} ${PYTHON} ${COMMAND} ${ARG}
exit $?