#!/bin/bash
# info: suspend remote dns server
# options: HOST
#
# example: v-suspend-remote-dns-host hostname.tld
#
# This function for suspending remote dns server.

#----------------------------------------------------------#
#                Variables & Functions                     #
#----------------------------------------------------------#

# Argument definition
host=$1

# Includes
# shellcheck source=/etc/tuliocp/tulio.conf
source /etc/tuliocp/tulio.conf
# shellcheck source=/usr/local/tulio/func/main.sh
source $TULIO/func/main.sh
# load config file
source_conf "$TULIO/conf/tulio.conf"

#----------------------------------------------------------#
#                    Verifications                         #
#----------------------------------------------------------#

check_args '1' "$#" 'HOST'
is_format_valid 'host'
is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
is_object_valid "../../../conf/dns-cluster" 'HOST' "$host"
is_object_unsuspended "../../../conf/dns-cluster" 'HOST' "$host"

# Perform verification if read-only mode is enabled
check_tulio_demo_mode

#----------------------------------------------------------#
#                       Action                             #
#----------------------------------------------------------#

# Unsuspend remote dns server
update_object_value "../../conf/dns-cluster" 'HOST' "$host" '$SUSPENDED' 'yes'

#----------------------------------------------------------#
#                       Tulio                             #
#----------------------------------------------------------#

# Logging
log_event "$OK" "$ARGUMENTS"

exit
