From 5242eeeb86a43a207e048538e93c93c854a51b09 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 24 Feb 2018 16:43:32 -0500 Subject: [PATCH] feat: source /etc/defaults/dokku if available This allows users to override - at a top-level - the DOKKU_ROOT, DOKKU_LIB_ROOT, and other configuration variables. If specified, this should begin to enable users to move their Dokku installations to mounted drives. Note that items installed from packages may not respect these paths, so further work may be in order. Closes #2958 --- contrib/dokku-update | 25 +++++++++++++++++++++++-- debian/postinst | 5 +++++ dokku | 5 +++++ rpm/dokku.postinst | 5 +++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/contrib/dokku-update b/contrib/dokku-update index b07b9e790..31c3c97fe 100755 --- a/contrib/dokku-update +++ b/contrib/dokku-update @@ -2,9 +2,30 @@ set -eo pipefail shopt -s nullglob +if [[ -r /etc/defaults/dokku ]]; then + # shellcheck disable=SC1091 + source /etc/defaults/dokku +fi + export DOKKU_ROOT=${DOKKU_ROOT:=~dokku} -[[ -f $DOKKU_ROOT/dokkurc ]] && source "$DOKKU_ROOT/dokkurc" -[[ -d $DOKKU_ROOT/.dokkurc ]] && for f in $DOKKU_ROOT/.dokkurc/*; do source "$f"; done +if [[ -f "$DOKKU_ROOT/dokkurc" ]]; then + if [[ -r $DOKKU_ROOT/dokkurc ]]; then + source "$DOKKU_ROOT/dokkurc" + else + echo "Unable to read $DOKKU_ROOT/dokkurc for sourcing" 1>&2 + exit 1 + fi +fi +if [[ -d $DOKKU_ROOT/.dokkurc ]]; then + for f in $DOKKU_ROOT/.dokkurc/*; do + if [[ -r "$f" ]]; then + source "$f" + else + echo "Unable to read $f for sourcing" 1>&2 + exit 1 + fi + done +fi [[ $DOKKU_TRACE ]] && set -x export DOKKU_LIB_ROOT=${DOKKU_LIB_PATH:="/var/lib/dokku"} diff --git a/debian/postinst b/debian/postinst index 88650ad02..bbd9dd714 100755 --- a/debian/postinst +++ b/debian/postinst @@ -6,6 +6,11 @@ if [[ -e /usr/share/debconf/confmodule ]]; then . /usr/share/debconf/confmodule fi +if [[ -r /etc/defaults/dokku ]]; then + # shellcheck disable=SC1091 + source /etc/defaults/dokku +fi + readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}" diff --git a/dokku b/dokku index b8735131e..38a30067f 100755 --- a/dokku +++ b/dokku @@ -2,6 +2,11 @@ set -eo pipefail shopt -s nullglob +if [[ -r /etc/defaults/dokku ]]; then + # shellcheck disable=SC1091 + source /etc/defaults/dokku +fi + export DOKKU_ROOT=${DOKKU_ROOT:=~dokku} if [[ -f "$DOKKU_ROOT/dokkurc" ]]; then if [[ -r $DOKKU_ROOT/dokkurc ]]; then diff --git a/rpm/dokku.postinst b/rpm/dokku.postinst index 8638a9065..9b484d74c 100644 --- a/rpm/dokku.postinst +++ b/rpm/dokku.postinst @@ -50,6 +50,11 @@ setup-version() { } main() { + if [[ -r /etc/defaults/dokku ]]; then + # shellcheck disable=SC1091 + source /etc/defaults/dokku + fi + readonly DOKKU_ROOT="${DOKKU_ROOT:-/home/dokku}" readonly DOKKU_LIB_ROOT="${DOKKU_LIB_PATH:-/var/lib/dokku}"