This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 0e021b3 Use Python shebang in Python Postinstall (#6107)
0e021b3 is described below
commit 0e021b3c386748494c5d6e535f84891be63a07d9
Author: Zach Hoffman <[email protected]>
AuthorDate: Mon Aug 16 14:53:29 2021 -0600
Use Python shebang in Python Postinstall (#6107)
* Use Python shebang in Python Postinstall
* Search for Python 3.7 and 3.9, too
---
traffic_ops/install/bin/_postinstall.py | 3 +--
traffic_ops/install/bin/postinstall | 11 +++++++++--
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/traffic_ops/install/bin/_postinstall.py
b/traffic_ops/install/bin/_postinstall.py
index 24a357c..01a2b4e 100755
--- a/traffic_ops/install/bin/_postinstall.py
+++ b/traffic_ops/install/bin/_postinstall.py
@@ -1,5 +1,4 @@
-#!/usr/bin/env bash
-"exec" "bash" "-c" "PATH+=:/usr/libexec/; exec \$(type -p python38 python3.8
python36 python3.6 python3 python27 python2.7 python2 python platform-python38
platform-python3.8 platform-python36 platform-python3.6 platform-python3
platform-python27 platform-python2.7 platform-python2 platform-python | head
-n1) \"$0\" $*"
+#!/usr/bin/env python3
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/traffic_ops/install/bin/postinstall
b/traffic_ops/install/bin/postinstall
index 71295af..74f46d0 100755
--- a/traffic_ops/install/bin/postinstall
+++ b/traffic_ops/install/bin/postinstall
@@ -25,10 +25,17 @@ for arg in "$@"; do
esac
done
+PATH+=:/usr/libexec/
+python_bin="$(command -v {python,platform-python}{3{{.,}{9,8,7,6},},2{7,.7,},}
| head -n1)"
+if [[ -z "$python_bin" ]]; then
+ echo 'No python3 or python2 executable was found. Python is required to
run the Postinstall script.' >/dev/stderr
+ exit 1
+fi
+
# above options don't require any of the extra processing -- just kick off the
script with
# options intact.
if [[ -v action && "$action" == "bypass" ]]; then
- /opt/traffic_ops/install/bin/_postinstall.py "$@"
+ "$python_bin" /opt/traffic_ops/install/bin/_postinstall.py "$@"
exit
fi
@@ -40,7 +47,7 @@ if [[ ! $(su - postgres psql -w -c 'show is_superuser'
</dev/null 2>/dev/null) =
exit 1
fi
-/opt/traffic_ops/install/bin/_postinstall.py "$@"
+"$python_bin" /opt/traffic_ops/install/bin/_postinstall.py "$@"
# should all be owned by trafops user
chown -R trafops:trafops /opt/traffic_ops