From b1deb45c8115e8ca7256a479a2287aba035e92c1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 9 Jun 2016 12:40:01 -0400 Subject: [PATCH] Rewrite sshcommand calls to take into account potential locations of sshcommand --- debian/postinst | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/debian/postinst b/debian/postinst index 920be1830..43dc0780b 100755 --- a/debian/postinst +++ b/debian/postinst @@ -6,6 +6,17 @@ set -eo pipefail; [[ $TRACE ]] && set -x readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" +call-sshcommand() { + if [[ -x /usr/local/bin/sshcommand ]]; then + /usr/local/bin/sshcommand "$@" + elif [[ -x /usr/bin/sshcommand ]]; then + /usr/bin/sshcommand "$@" + else + echo "Unable to find sshcommand binary" 1>&2 + exit 1 + fi +} + case "$1" in abort-upgrade|abort-remove|abort-deconfigure) ;; @@ -14,7 +25,8 @@ case "$1" in mandb [ ! -x /usr/bin/docker.io ] || ln -sf /usr/bin/docker.io /usr/local/bin/docker modprobe aufs || echo "WARNING: Restart server to finish installing dokku!" - sshcommand create dokku /usr/local/bin/dokku + call-sshcommand create dokku /usr/bin/dokku + egrep -i "^docker" /etc/group || groupadd docker usermod -aG docker dokku @@ -50,6 +62,13 @@ case "$1" in find -L ${DOKKU_LIB_ROOT} -type l -delete chown dokku:dokku -R ${DOKKU_LIB_ROOT}/plugins ${DOKKU_LIB_ROOT}/core-plugins + echo "Ensure proper sshcommand path" + echo '/usr/bin/dokku' > "${DOKKU_ROOT}/.sshcommand" + if [[ -f .ssh/authorized_keys ]]; then + sed -i.bak 's#/usr/local/bin/dokku#/usr/bin/dokku#' "${DOKKU_ROOT}/.ssh/authorized_keys" + rm "${DOKKU_ROOT}/.ssh/authorized_keys" + fi + echo "Install all core plugins" dokku plugin:install --core @@ -92,7 +111,7 @@ case "$1" in if [ -z "${DEBCONF_RECONFIGURE}" ]; then db_get "dokku/key_file" if [ -f "$RET" ]; then - sshcommand acl-add dokku default < "$RET" || true + call-sshcommand acl-add dokku default < "$RET" || true fi fi ;;