forked from Azure/azure-linux-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shim.sh
38 lines (30 loc) · 924 Bytes
/
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
33
34
35
36
37
38
#!/usr/bin/env bash
# The shim scripts provide a single entry point for CSE and will invoke the customscript.py entry point using the
# appropriate python interpreter version.
# Arguments passed to the shim layer are redirected to the invoked script without any validation.
COMMAND="./customscript.py"
PYTHON=""
ARG="$@"
function find_python(){
local python_exec_command=$1
# Check if there is python defined.
if command -v python >/dev/null 2>&1 ; then
eval ${python_exec_command}="python"
else
# Python was not found. Searching for Python3 now.
if command -v python3 >/dev/null 2>&1 ; then
eval ${python_exec_command}="python3"
fi
fi
}
find_python PYTHON
if [ -z "$PYTHON" ]
then
echo "No Python interpreter found on the box" >&2
exit 51 # Not Supported
else
echo "Found: `${PYTHON} --version`"
fi
${PYTHON} ${COMMAND} ${ARG}
exit $?
# DONE