containerctl: Expand python version check
Signed-off-by: Enno Tensing <tenno@suij.in>
This commit is contained in:
parent
d67137363f
commit
94fcd6828f
1 changed files with 34 additions and 6 deletions
40
containerctl
40
containerctl
|
@ -11,6 +11,39 @@ LOGDIR="/var/log/containerctl"
|
||||||
TODAY="$(date '+%F')"
|
TODAY="$(date '+%F')"
|
||||||
LOG="${LOGDIR}/${TODAY}"
|
LOG="${LOGDIR}/${TODAY}"
|
||||||
|
|
||||||
|
get_python_path()
|
||||||
|
{
|
||||||
|
py="python3"
|
||||||
|
pyver="$(/usr/bin/env "${py}" -c 'import sys; print(sys.version_info.minor)')"
|
||||||
|
if [ "${pyver}" -lt "11" ]
|
||||||
|
then
|
||||||
|
py="python3.13"
|
||||||
|
else
|
||||||
|
printf '%b' "${py}"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if /usr/bin/env "${py}" 2> /dev/null
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
py="python3.12"
|
||||||
|
if /usr/bin/env "${py}" 2> /dev/null
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
py="python3.11"
|
||||||
|
if /usr/bin/env "${py}" 2> /dev/null
|
||||||
|
then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
log_error 'containerctl needs at least Python 3.11 to run!'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
log_error()
|
log_error()
|
||||||
{
|
{
|
||||||
printf '[%b] (EE) %b\n' "${TODAY}" "${@}" | tee -a "${LOG}"
|
printf '[%b] (EE) %b\n' "${TODAY}" "${@}" | tee -a "${LOG}"
|
||||||
|
@ -106,12 +139,7 @@ generate_container()
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mypython="python3"
|
mypython="$(get_python_path)"
|
||||||
pyver="$(/usr/bin/env "${mypython}" -c 'import sys; print(sys.version_info.minor)')"
|
|
||||||
if [ "${pyver}" -lt "11" ]
|
|
||||||
then
|
|
||||||
mypython="python3.11"
|
|
||||||
fi
|
|
||||||
/usr/bin/env "${mypython}" "${BASEDIR}/generate/generate.py" \
|
/usr/bin/env "${mypython}" "${BASEDIR}/generate/generate.py" \
|
||||||
"${CONFIGDIR}/${config}" "${LOG}" "${CONTAINERDIR}"
|
"${CONFIGDIR}/${config}" "${LOG}" "${CONTAINERDIR}"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue