forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_change_sys_user_ns
More file actions
executable file
·88 lines (65 loc) · 1.83 KB
/
v_change_sys_user_ns
File metadata and controls
executable file
·88 lines (65 loc) · 1.83 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
83
84
85
86
87
88
#!/bin/bash
# info: changing user nameservers
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
ns1=$2
ns2=$3
ns3=$4
ns4=$5
ns5=$6
ns6=$7
ns7=$8
ns8=$9
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '3' "$#" 'user ns1 ns2 [ns3] [ns4] [ns5] [ns6] [ns7] [ns8]'
# Checking argument format
format_validation 'user' 'ns1' 'ns2'
if [ ! -z "$ns3" ]; then
format_validation 'ns3'
fi
if [ ! -z "$ns4" ]; then
format_validation 'ns4'
fi
if [ ! -z "$ns5" ]; then
format_validation 'ns5'
fi
if [ ! -z "$ns6" ]; then
format_validation 'ns6'
fi
if [ ! -z "$ns7" ]; then
format_validation 'ns7'
fi
if [ ! -z "$ns8" ]; then
format_validation 'ns8'
fi
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Get old values
old_ns=$(get_user_value '$NS')
# Merging values
ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8"
ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//")
# Changing ns values
update_user_value "$user" '$NS' "$ns"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user ${old_ns//,/ }"
log_event 'system' "$V_EVENT"
exit