forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv_del_sys_user
More file actions
executable file
·137 lines (110 loc) · 3.19 KB
/
Copy pathv_del_sys_user
File metadata and controls
executable file
·137 lines (110 loc) · 3.19 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
# info: deliting system user
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
source $V_FUNC/domain_func.sh
source $V_FUNC/db_func.sh
source $V_FUNC/ip_func.sh
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
# Checking user childs
is_user_parent
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking web system is enabled
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_web_domains $user
$V_BIN/v_del_web_domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
fi
# Checking dns system is enabled
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_dns_domains $user
$V_BIN/v_del_dns_domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
fi
# Checking mail system is enabled
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_mail_domains $user
$V_BIN/v_del_mail_domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
fi
# Checking db system is enabled
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_db_bases $user
$V_BIN/v_del_db_dbases $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
fi
# Checking ip
$V_BIN/v_del_sys_user_ips "$user"
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
# Deleteing user pipes
diskp=$(grep -n " $user$" $V_QUEUE/disk.pipe|cut -d : -f 1|sort -n -r)
trafp=$(grep -n " $user$" $V_QUEUE/traffic.pipe|cut -d : -f 1|sort -n -r)
statp=$(grep -n "/$user/" $V_QUEUE/stats.pipe|cut -d : -f 1|sort -n -r)
if [ ! -z "$diskp" ]; then
for str in $diskp; do
sed -i "$str d" $V_QUEUE/disk.pipe
done
fi
if [ ! -z "$trafp" ]; then
for str in $trafp; do
sed -i "$str d" $V_QUEUE/traffic.pipe
done
fi
if [ ! -z "$statp" ]; then
for str in $statp; do
sed -i "$str d" $V_QUEUE/stats.pipe
done
fi
# Deleteing user from parent
childc=$(grep -n "USER='$user'" $V_USERS/child.conf |cut -d : -f 1|sort -n -r)
if [ ! -z "$childc" ]; then
for str in $childc; do
sed -i "$str d" $V_USERS/child.conf
done
fi
# Removing system user
userdel -f $user
rm -rf $V_HOME/$user
rm -f /var/spool/mail/$user
rm -f /var/spool/cron/$user
rm -rf $V_USERS/$user
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK