Fixes 3
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
# www.domain.tld type will be automatically assigned to the domain unless
|
||||
# "none" is transmited as argument. If ip have associated dns name, this
|
||||
# domain will also get the alias domain-tpl.$ipname. An alias with the ip
|
||||
# name is useful during the site testing while dns isn't moved to server yet.
|
||||
# name is useful during the site testing while dns isn't moved to server yaliet.
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variables & Functions #
|
||||
@@ -255,6 +255,9 @@ check_result $? "Proxy restart failed" > /dev/null
|
||||
module_state=$($BIN/v-ext-modules state bunkerweb_module json | jq -r '.[0].STATE')
|
||||
if [ "$module_state" = "enabled" ]; then
|
||||
$BIN/v-ext-modules-run bunkerweb_module add "$domain"
|
||||
if [ -n "%$ALIAS" ]; then
|
||||
$BIN/v-ext-modules-run bunkerweb_module alias "$domain" "$ALIAS"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Logging
|
||||
|
||||
@@ -108,6 +108,12 @@ check_result $? "Web restart failed" > /dev/null
|
||||
$BIN/v-restart-proxy "$restart"
|
||||
check_result $? "Proxy restart failed" > /dev/null
|
||||
|
||||
# Execute bunkerweb_module if it's enabled
|
||||
module_state=$($BIN/v-ext-modules state bunkerweb_module json | jq -r '.[0].STATE')
|
||||
if [ "$module_state" = "enabled" ]; then
|
||||
$BIN/v-ext-modules-run bunkerweb_module alias "$domain" "$ALIAS"
|
||||
fi
|
||||
|
||||
$BIN/v-log-action "$user" "Info" "Web" "Added new web domain alias (Alias: $aliases, Domain: $domain)."
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
|
||||
@@ -94,6 +94,42 @@ when :add
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
when :alias
|
||||
|
||||
v_domain = ARGV[1].strip
|
||||
v_alias = ARGV[2].strip
|
||||
v_format = ARGV[3] unless ARGV[3].nil?
|
||||
|
||||
if v_domain.nil? || v_domain == ""
|
||||
hestia_print_error_message_to_cli "domain should not be empty"
|
||||
log_event E_ARGS, $ARGUMENTS
|
||||
exit 1
|
||||
else
|
||||
|
||||
begin
|
||||
api = HestiaBunkerWebApi.new("http://127.0.0.1:8888")
|
||||
existing_services = api.list_services()
|
||||
if existing_services.nil?
|
||||
result_arr = []
|
||||
else
|
||||
if existing_services["services"]
|
||||
if existing_services["services"].any? { |s| s["id"] == v_domain }
|
||||
hestia_print_error_message_to_cli "domain already exists"
|
||||
log_event E_EXISTS, $ARGUMENTS
|
||||
exit 1
|
||||
end
|
||||
result_arr = existing_services["services"]
|
||||
else
|
||||
result_arr = []
|
||||
end
|
||||
end
|
||||
api.set_alias(v_domain, v_alias)
|
||||
rescue BunkerWebApiError => e
|
||||
hestia_print_error_message_to_cli "[ERROR] Ошибка API: #{e.message}"
|
||||
log_event E_INVALID, $ARGUMENTS
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
when :delete
|
||||
|
||||
v_domain = ARGV[1].strip
|
||||
|
||||
@@ -92,6 +92,12 @@ check_result $? "Web restart failed" > /dev/null
|
||||
$BIN/v-restart-proxy "$restart"
|
||||
check_result $? "Proxy restart failed" > /dev/null
|
||||
|
||||
# Execute bunkerweb_module if it's enabled
|
||||
module_state=$($BIN/v-ext-modules state bunkerweb_module json | jq -r '.[0].STATE')
|
||||
if [ "$module_state" = "enabled" ]; then
|
||||
$BIN/v-ext-modules-run bunkerweb_module alias "$domain" "$ALIAS"
|
||||
fi
|
||||
|
||||
# Logging
|
||||
$BIN/v-log-action "$user" "Info" "Web" "Deleted web domain alias (Alias: $dom_alias, Domain: $domain)."
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
Reference in New Issue
Block a user