Add domains_add_global and domains_remove_global
This commit is contained in:
1 parent
6286962c5c
commit
164f48913f
4 files changed
+62
No files matched your search
@@ -9,10 +9,12 @@ case "$1" in
|
|||||||
cat<<help_content
|
cat<<help_content
|
||||||
domains [<app>], List domains
|
domains [<app>], List domains
|
||||||
domains:add <app> DOMAIN, Add a domain to app
|
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:clear <app>, Clear all domains for app
|
||||||
domains:disable <app>, Disable VHOST support
|
domains:disable <app>, Disable VHOST support
|
||||||
domains:enable <app>, Enable VHOST support
|
domains:enable <app>, Enable VHOST support
|
||||||
domains:remove <app> DOMAIN, Remove a domain from app
|
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
|
domains:set-global <domain>, Set global domain name
|
||||||
help_content
|
help_content
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -131,6 +131,36 @@ domains_enable() {
|
|||||||
fi
|
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() {
|
domains_set_global() {
|
||||||
declare desc="set global domain name"
|
declare desc="set global domain name"
|
||||||
local NEW_GLOBAL_VHOST="$1"; local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
local NEW_GLOBAL_VHOST="$1"; local GLOBAL_VHOST_PATH="$DOKKU_ROOT/VHOST"
|
||||||
|
|||||||
Executable
+15
@@ -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 "$@"
|
||||||
Executable
+15
@@ -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