subcommand restructure and bashstyle refactor. closes #1579

This commit is contained in:
Michael S. Hobbs
2016-03-01 13:26:35 -08:00
committed by Michael Hobbs
parent 76e27f0333
commit 89f289b433
105 changed files with 1969 additions and 1306 deletions

View File

@@ -1,65 +1,8 @@
#!/usr/bin/env bash
[[ " domains domains:setup domains:add domains:clear domains:remove domains:disable domains:enable domains:set-global help domains:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
[[ " help domains:help " == *" $1 "* ]] || exit "$DOKKU_NOT_IMPLEMENTED_EXIT"
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
source "$PLUGIN_AVAILABLE_PATH/nginx-vhosts/functions"
case "$1" in
domains)
domains_main "$2"
;;
domains:setup)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_setup "$2"
;;
domains:add)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ -z "${*:3}" ]]; then
echo "Usage: dokku $1 $2 DOMAIN [DOMAIN ...]"
echo "Must specify DOMAIN."
exit 1
fi
shift 1
domains_add "$@"
;;
domains:clear)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_clear "$2"
;;
domains:remove)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ -z "${*:3}" ]]; then
echo "Usage: dokku $1 $2 DOMAIN [DOMAIN ...]"
echo "Must specify DOMAIN."
exit 1
fi
shift 1
domains_remove "$@"
;;
domains:disable)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_disable "$2"
;;
domains:enable)
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_enable "$2"
;;
domains:set-global)
[[ -z $2 ]] && dokku_log_fail "Please specify a global domain name"
domains_set_global "$2"
;;
help | domains:help)
cat<<EOF
domains [<app>], List domains

View File

@@ -61,25 +61,6 @@ domains_setup() {
fi
}
domains_main() {
local desc="print app domains"
local APP="$1"
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
dokku_log_info2_quiet "Global Domain Name"
get_global_vhost
fi
if [[ -n "$APP" ]]; then
verify_app_name "$APP"
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
dokku_log_info2_quiet "$APP Domain Names"
get_app_domains "$APP"
else
dokku_log_fail "No domain names set for $APP"
fi
fi
}
domains_add() {
local desc="add list of domains to app"
verify_app_name "$1"
@@ -103,17 +84,6 @@ domains_add() {
plugn trigger post-domains-update "$APP" "add" "$@"
}
domains_clear() {
local desc="clear all app domains"
verify_app_name "$1"
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
rm -f "$APP_VHOST_PATH"
domains_setup "$APP"
plugn trigger post-domains-update "$APP" "clear"
dokku_log_info1 "Cleared domains in $APP"
}
domains_remove() {
local desc="remove list of app domains"
verify_app_name "$1"

View File

@@ -1,8 +1,9 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
shopt -s nullglob
for app in $DOKKU_ROOT/*/CONTAINER; do
APP=$(basename "$(dirname "$app")");
dokku domains:setup "$APP"
domains_setup "$APP"
done

20
plugins/domains/subcommands/add Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_add_cmd() {
local desc="adds domain to app via command line"
local cmd="domains:add"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ -z "${*:3}" ]]; then
echo "Usage: dokku $1 $2 DOMAIN [DOMAIN ...]"
echo "Must specify DOMAIN."
exit 1
fi
shift 1
domains_add "$@"
}
domains_add_cmd "$@"

View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_clear_cmd() {
local desc="clear all app domains"
local cmd="domains:clear"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
verify_app_name "$2"
local APP="$2"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
rm -f "$APP_VHOST_PATH"
domains_setup "$APP"
plugn trigger post-domains-update "$APP" "clear"
dokku_log_info1 "Cleared domains in $APP"
}
domains_clear_cmd "$@"

View File

@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_main_cmd() {
local desc="print app domains"
local cmd="domains"
local APP="$2"
if [[ "$(is_global_vhost_enabled)" == "true" ]]; then
dokku_log_info2_quiet "Global Domain Name"
get_global_vhost
fi
if [[ -n "$APP" ]]; then
verify_app_name "$APP"
if [[ -f "$DOKKU_ROOT/$APP/VHOST" ]]; then
dokku_log_info2_quiet "$APP Domain Names"
get_app_domains "$APP"
else
dokku_log_fail "No domain names set for $APP"
fi
fi
}
domains_main_cmd "$@"

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_disable_cmd() {
local desc="disable domains/VHOST support via command line"
local cmd="domains:disable"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_disable "$2"
}
domains_disable_cmd "$@"

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_enable_cmd() {
local desc="enable domains/VHOST support via command line"
local cmd="domains:enable"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_enable "$2"
}
domains_enable_cmd "$@"

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_remove_cmd() {
local desc="removes domains from app via command line"
local cmd="domains:remove"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
if [[ -z "${*:3}" ]]; then
echo "Usage: dokku $1 $2 DOMAIN [DOMAIN ...]"
echo "Must specify DOMAIN."
exit 1
fi
shift 1
domains_remove "$@"
}
domains_remove_cmd "$@"

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_set_global_cmd() {
local desc="set global domain name from command line"
local cmd="domains:set-global"
[[ -z $2 ]] && dokku_log_fail "Please specify a global domain name"
domains_set_global "$2"
}
domains_set_global_cmd "$@"

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
source "$PLUGIN_AVAILABLE_PATH/domains/functions"
domains_setup_cmd() {
local desc="setup domains to default state via command line"
local cmd="domains:setup"
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
domains_setup "$2"
}
domains_setup_cmd "$@"