forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_list_user_ns
More file actions
executable file
·82 lines (64 loc) · 1.92 KB
/
Copy pathv_list_user_ns
File metadata and controls
executable file
·82 lines (64 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# info: listing user nameservers
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
# Json function
json_list_ns() {
ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
# Print top bracket
echo '['
i=1
nslistc=$(echo -e "${ns//,/\n}"|wc -l)
# Listing servers
for nameserver in ${ns//,/ };do
if [ "$i" -ne "$nslistc" ]; then
echo -e "\t\"$nameserver\","
else
echo -e "\t\"$nameserver\""
fi
(( ++i))
done
echo "]"
}
# Shell function
shell_list_ns() {
ns=$(grep "^NS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
if [ -z "$nohead" ]; then
# Print result
echo "NAMESERVER"
echo "----------"
fi
for nameserver in ${ns//,/ };do
echo "$nameserver"
done
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Listing nameservers
case $format in
json) json_list_ns ;;
plain) nohead=1; shell_list_ns ;;
shell) shell_list_ns ;;
*) check_args '1' '0' 'user [format]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit