Add domains:set and domains:set-global commands

This commit is contained in:
Ilya Semenov
2016-11-28 21:55:59 +07:00
parent 8398ff7a76
commit 6a9b3f6df2
7 changed files with 123 additions and 7 deletions

View File

@@ -85,7 +85,7 @@ domains_add() {
fi
done
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
domains_enable "$APP" --no-restart
fi
@@ -105,12 +105,34 @@ domains_remove() {
plugn trigger post-domains-update "$APP" "remove" "$@"
}
domains_set() {
declare desc="set list of domains for app"
verify_app_name "$1"
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
shift 1
for DOMAIN in "$@"; do
if ! (is_valid_hostname "$DOMAIN"); then
dokku_log_fail "$DOMAIN is invalid. exiting..."
fi
done
echo "$*" | tr " " "\n" > "$APP_VHOST_PATH"
dokku_log_info1 "Set $* for $APP"
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
domains_enable "$APP" --no-restart
fi
plugn trigger post-domains-update "$APP" "set" "$@"
}
domains_disable() {
declare desc="disable domains/VHOST support"
verify_app_name "$1"
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]];then
if [[ "$(is_app_vhost_enabled "$APP")" == "true" ]]; then
disable_app_vhost "$APP"
else
dokku_log_info1 "domains (VHOST) support is already disabled for app ($APP)"
@@ -123,7 +145,7 @@ domains_enable() {
local APP="$1"; local APP_VHOST_PATH="$DOKKU_ROOT/$APP/VHOST"
local DEFAULT_VHOSTS="$(get_default_vhosts "$APP")"
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]];then
if [[ "$(is_app_vhost_enabled "$APP")" == "false" ]]; then
if [[ -n "$DEFAULT_VHOSTS" ]]; then
echo "$DEFAULT_VHOSTS" > "$APP_VHOST_PATH"
fi
@@ -163,3 +185,17 @@ domains_remove_global() {
dokku_log_info1 "Removed $DOMAIN"
done
}
domains_set_global() {
declare desc="set list of global domains"
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
for DOMAIN in "$@"; do
if ! (is_valid_hostname "$DOMAIN"); then
dokku_log_fail "$DOMAIN is invalid. exiting..."
fi
done
echo "$*" | tr " " "\n" > "$GLOBAL_VHOST_PATH"
dokku_log_info1 "Set $*"
}