Fixes 3
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user