mirror of
https://github.com/myvesta/vesta.git
synced 2024-12-21 11:31:21 -08:00
100 lines
2.5 KiB
Bash
Executable File
100 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: list dns domain
|
|
# options: USER DOMAIN [FORMAT]
|
|
#
|
|
# The function of obtaining the list of dns domain parameters.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
domain=$2
|
|
format=${3-shell}
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
|
|
# JSON list function
|
|
json_list() {
|
|
echo '{'
|
|
echo ' "'$DOMAIN'": {
|
|
"IP": "'$IP'",
|
|
"TPL": "'$TPL'",
|
|
"TTL": "'$TTL'",
|
|
"EXP": "'$EXP'",
|
|
"SOA": "'$SOA'",
|
|
"SERIAL": "'$SERIAL'",
|
|
"SRC": "'$SRC'",
|
|
"RECORDS": "'$RECORDS'",
|
|
"SUSPENDED": "'$SUSPENDED'",
|
|
"TIME": "'$TIME'",
|
|
"DATE": "'$DATE'"
|
|
}'
|
|
echo '}'
|
|
}
|
|
|
|
# SHELL list function
|
|
shell_list() {
|
|
echo "DOMAIN: $DOMAIN"
|
|
echo "IP: $IP"
|
|
echo "TEMPLATE: $TPL"
|
|
echo "TTL: $TTL"
|
|
echo "EXP: $EXP"
|
|
echo "SOA: $SOA"
|
|
echo "SERIAL: $SERIAL"
|
|
echo "RECORDS: $RECORDS"
|
|
echo "SUSPENDED: $SUSPENDED"
|
|
echo "TIME: $TIME"
|
|
echo "DATE: $DATE"
|
|
}
|
|
|
|
|
|
# PLAIN list function
|
|
plain_list() {
|
|
echo -ne "$DOMAIN\t$IP\t$TPL\t$TTL\t$EXP\t$SOA\t$SERIAL\t$RECORDS\t"
|
|
echo -e "$SUSPENDED\t$TIME\t$DATE"
|
|
}
|
|
|
|
# CSV list function
|
|
csv_list() {
|
|
echo "DOMAIN,IP,TPL,TTL,EXP,SOA,SERIAL,RECORDS,SUSPENDED,TIME,DATE"
|
|
echo -n "$DOMAIN,$IP,$TPL,$TTL,$EXP,$SOA,$SERIAL,$RECORDS,$SUSPENDED,"
|
|
echo "$TIME,$DATE"
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '2' "$#" 'USER DOMAIN [FORMAT]'
|
|
is_format_valid 'user' 'domain'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
is_object_valid 'dns' 'DOMAIN' "$domain"
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Parsing domain
|
|
eval $(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
|
|
|
# Listing data
|
|
case $format in
|
|
json) json_list ;;
|
|
plain) plain_list ;;
|
|
csv) csv_list ;;
|
|
shell) shell_list ;;
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|