vesta/bin/v_list_dns_domain
2011-06-30 01:00:27 +03:00

66 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# info: listing dns domain
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
format="${3-shell}"
limit="${4-1000}"
offset="${5-1}"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
source $V_FUNC/domain_func.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '2' "$#" 'user domain [format]'
# Checking argument format
format_validation 'user' 'domain' 'limit' 'offset'
# Checking user
is_user_valid
# Checking domain exist
is_dns_domain_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/zones/$domain"
# Defining fileds to select
fields='$ID $RECORD $TYPE $VALUE $SUSPEND $DATE'
# Listing domains
case $format in
json) dns_json_list ;;
shell) fields='$ID $RECORD $TYPE $VALUE';
dns_shell_list | column -t ;;
*) check_args '2' "0" 'user domain [format]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK