forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv-change-user-ns
More file actions
executable file
·66 lines (49 loc) · 1.74 KB
/
v-change-user-ns
File metadata and controls
executable file
·66 lines (49 loc) · 1.74 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
#!/bin/bash
# info: change user nameservers
# options: USER NS1 NS2 [NS3] [NS4]
#
# The function for changing default nameservers for speciefic user.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns3=$4
ns4=$5
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]'
# Checking argument format
validate_format 'user' 'ns1' 'ns2'
if [ ! -z "$ns3" ]; then
ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns3'
fi
if [ ! -z "$ns4" ]; then
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns4'
fi
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Merging values
ns="$ns1,$ns2,$ns3,$ns4"
ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//")
# Changing ns values
update_user_value "$user" '$NS' "$ns"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "changed user nameservers to $ns1, $ns2"
log_event "$OK" "$EVENT"
exit