From 50863a9b7636ad68d4cae6b79522e430a7a38fad Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 17 Oct 2019 14:24:47 -0400 Subject: [PATCH] fix: detect correct python binary to use Ideally python usage goes away - the dokku-installer should become a mandatory cli command, and the plugin is rewritten in golang - but for now, we need to use the correct binary when running dokku. Closes #3714 --- debian/postinst | 6 ++++++ plugins/scheduler-docker-local/scheduler-inspect | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/debian/postinst b/debian/postinst index de453d037..94257e24c 100755 --- a/debian/postinst +++ b/debian/postinst @@ -92,6 +92,12 @@ setup-dokku-installer() { NGINX_ROOT="/etc/nginx" [[ -x /usr/bin/openresty ]] && NGINX_ROOT="/usr/local/openresty/nginx/conf" + if command -v "python3" &>/dev/null; then + sed -i '1 s/^.*$/#!\/usr\/bin\/env python3/' /usr/share/dokku/contrib/dokku-installer.py + elif command -v "python2.7" &>/dev/null; then + sed -i '1 s/^.*$/#!\/usr\/bin\/env python2.7/' /usr/share/dokku/contrib/dokku-installer.py + fi + if [[ -f "$NGINX_ROOT/conf.d/dokku-installer.conf" ]]; then echo "Setting up dokku-installer" /usr/share/dokku/contrib/dokku-installer.py onboot diff --git a/plugins/scheduler-docker-local/scheduler-inspect b/plugins/scheduler-docker-local/scheduler-inspect index c6ef49d06..bb79895ef 100755 --- a/plugins/scheduler-docker-local/scheduler-inspect +++ b/plugins/scheduler-docker-local/scheduler-inspect @@ -48,7 +48,15 @@ EOF for CONTAINER_FILE in $CONTAINER_FILES; do CIDS+="$(<"$DOKKU_ROOT/$APP/$CONTAINER_FILE")" done - "$DOCKER_BIN" container inspect "${CIDS[@]}" | python2.7 "$TMP_INSPECT_CMD" + + local PYTHON_BIN=python + if command -v "python3" &>/dev/null; then + PYTHON_BIN=python3 + elif command -v "python2.7" &>/dev/null; then + PYTHON_BIN=python2.7 + fi + + "$DOCKER_BIN" container inspect "${CIDS[@]}" | "$PYTHON_BIN" "$TMP_INSPECT_CMD" }