first stab at a common functions library. include argument parsing and a few definitions wired up. closes #932. closes #945

This commit is contained in:
Michael Hobbs
2015-02-05 11:32:46 -08:00
parent 72a58bbda3
commit 6ad65dd9b4
13 changed files with 140 additions and 62 deletions

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../common/functions"
restart_nginx () {
case "$DOKKU_DISTRO" in
@@ -62,7 +63,7 @@ EOF
NONSSL_VHOSTS=$(egrep -v "^${SSL_HOSTNAME}$|^${SSL_HOSTNAME_ALT}$" $VHOST_PATH || exit 0)
while read line; do
echo "-----> Configuring SSL for $line..."
info1 "Configuring SSL for $line..."
SSL_SERVER_NAME=$line
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
done <<< "$SSL_VHOSTS"
@@ -70,7 +71,7 @@ EOF
APP_NGINX_TEMPLATE="$DOKKU_ROOT/$APP/nginx.conf.template"
if [[ -f $APP_NGINX_TEMPLATE ]]; then
echo "-----> Overriding default nginx.conf with detected nginx.conf.template"
info1 "Overriding default nginx.conf with detected nginx.conf.template"
NGINX_CONF=$APP_NGINX_TEMPLATE
fi
@@ -79,11 +80,11 @@ EOF
NOSSL_SERVER_NAME=$(echo $NONSSL_VHOSTS $SSL_VHOSTS| tr '\n' ' ')
if [[ -n "$DOKKU_APP_LISTEN_PORT" ]] && [[ -n "$DOKKU_APP_LISTEN_IP" ]]; then
echo "-----> Creating $SCHEME nginx.conf"
info1 "Creating $SCHEME nginx.conf"
echo "upstream $APP { server $DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT; }" > $DOKKU_ROOT/$APP/nginx.conf
eval "cat <<< \"$(< $NGINX_CONF)\" >> $DOKKU_ROOT/$APP/nginx.conf"
echo "-----> Running nginx-pre-reload"
info1 "Running nginx-pre-reload"
pluginhook nginx-pre-reload $APP $DOKKU_APP_LISTEN_PORT $DOKKU_APP_LISTEN_IP
echo " Reloading nginx"
@@ -91,14 +92,14 @@ EOF
fi
else
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
echo "-----> VHOST support disabled, deleting $APP/VHOST"
info1 "VHOST support disabled, deleting $APP/VHOST"
rm "$DOKKU_ROOT/$APP/VHOST"
fi
if [[ -f "$DOKKU_ROOT/$APP/nginx.conf" ]]; then
echo "-----> VHOST support disabled, deleting nginx.conf"
info1 "VHOST support disabled, deleting nginx.conf"
rm "$DOKKU_ROOT/$APP/nginx.conf"
echo "-----> VHOST support disabled, reloading nginx after nginx.conf deletion"
info1 "VHOST support disabled, reloading nginx after nginx.conf deletion"
restart_nginx
fi
fi
@@ -106,7 +107,7 @@ EOF
nginx:import-ssl)
[[ -z $2 ]] && echo "Please specify an app to run the command on" && exit 1
[[ ! -d "$DOKKU_ROOT/$2" ]] && echo "App $2 does not exist" && exit 1
verify_app_name "$2"
[[ -t 0 ]] && echo "Tar archive containing server.crt and server.key expected on stdin" && exit 1
APP="$2"

View File

@@ -1,12 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../common/functions"
APP="$1"; PORT="$2"; IP="$3"
set +e; NO_VHOST=$(dokku config:get $APP NO_VHOST); set -e
if [[ -n "$NO_VHOST" ]]; then
echo "-----> NO_VHOST config detected"
info1 "NO_VHOST config detected"
elif [[ ! -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
dokku domains:setup $APP
fi

View File

@@ -1,5 +1,6 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$(dirname $0)/../common/functions"
APP="$1"