Add domains_add_global and domains_remove_global
This commit is contained in:
@@ -9,10 +9,12 @@ case "$1" in
|
||||
cat<<help_content
|
||||
domains [<app>], List domains
|
||||
domains:add <app> DOMAIN, Add a domain to app
|
||||
domains:add-global DOMAIN, Add global domain name
|
||||
domains:clear <app>, Clear all domains for app
|
||||
domains:disable <app>, Disable VHOST support
|
||||
domains:enable <app>, Enable VHOST support
|
||||
domains:remove <app> DOMAIN, Remove a domain from app
|
||||
domains:remove-global DOMAIN, Remove global domain name
|
||||
domains:set-global <domain>, Set global domain name
|
||||
help_content
|
||||
}
|
||||
|
||||
@@ -131,6 +131,36 @@ domains_enable() {
|
||||
fi
|
||||
}
|
||||
|
||||
domains_add_global() {
|
||||
declare desc="add 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
|
||||
|
||||
for DOMAIN in "$@"; do
|
||||
if [[ $(egrep -w "^$DOMAIN$" "$GLOBAL_VHOST_PATH" > /dev/null 2>&1; echo $?) -eq 0 ]]; then
|
||||
dokku_log_info1 "Skipping: $DOMAIN already added"
|
||||
else
|
||||
echo "$DOMAIN" >> "$GLOBAL_VHOST_PATH"
|
||||
dokku_log_info1 "Added $DOMAIN"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
domains_remove_global() {
|
||||
declare desc="remove list of domains"
|
||||
local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||
|
||||
for DOMAIN in "$@"; do
|
||||
sed -i "\|^$DOMAIN\$|d" "$GLOBAL_VHOST_PATH"
|
||||
dokku_log_info1 "Removed $DOMAIN"
|
||||
done
|
||||
}
|
||||
|
||||
domains_set_global() {
|
||||
declare desc="set global domain name"
|
||||
local NEW_GLOBAL_VHOST="$1"; local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||
|
||||
15
plugins/domains/subcommands/add-global
Executable file
15
plugins/domains/subcommands/add-global
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/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_global_cmd() {
|
||||
declare desc="add global domain name via command line"
|
||||
local cmd="domains:add-global"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 DOMAIN [DOMAIN ...]"
|
||||
|
||||
shift 1
|
||||
domains_add_global "$@"
|
||||
}
|
||||
|
||||
domains_add_global_cmd "$@"
|
||||
15
plugins/domains/subcommands/remove-global
Executable file
15
plugins/domains/subcommands/remove-global
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/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_global_cmd() {
|
||||
declare desc="remove global domain name via command line"
|
||||
local cmd="domains:remove-global"
|
||||
[[ -z $2 ]] && dokku_log_fail "Please specify a domain name. Usage: dokku $1 DOMAIN [DOMAIN ...]"
|
||||
|
||||
shift 1
|
||||
domains_remove_global "$@"
|
||||
}
|
||||
|
||||
domains_remove_global_cmd "$@"
|
||||
Reference in New Issue
Block a user