mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 21:34:11 -07:00
delete vesta user
This commit is contained in:
parent
27a59703a0
commit
9e921c48be
8 changed files with 415 additions and 1 deletions
68
bin/v_del_db_dbases
Executable file
68
bin/v_del_db_dbases
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: deleteing all user databases
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user="$1"
|
||||||
|
|
||||||
|
# Importing variables
|
||||||
|
source $VESTA/conf/vars.conf
|
||||||
|
source $V_FUNC/shared_func.sh
|
||||||
|
source $V_FUNC/db_func.sh
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Checking arg number
|
||||||
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
|
# Checking argument format
|
||||||
|
format_validation 'user'
|
||||||
|
|
||||||
|
# Checking web system is enabled
|
||||||
|
is_system_enabled 'db'
|
||||||
|
|
||||||
|
# Checking user
|
||||||
|
is_user_valid
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Defining config
|
||||||
|
conf="$V_USERS/$user/db.conf"
|
||||||
|
|
||||||
|
# Defining fileds to select
|
||||||
|
field='$DB'
|
||||||
|
|
||||||
|
# Defining search string
|
||||||
|
search_string="SUSPEND='no'"
|
||||||
|
|
||||||
|
# Parsing unsuspeneded domains
|
||||||
|
databases=$(db_clear_search)
|
||||||
|
|
||||||
|
# Starting delete loop
|
||||||
|
for database in $databases; do
|
||||||
|
$V_BIN/v_del_db_base "$user" "$database"
|
||||||
|
rv="$?"
|
||||||
|
if [ "$rv" -ne '0' ]; then
|
||||||
|
log_event 'debug' "$rv $V_EVENT"
|
||||||
|
exit $rv
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
|
exit $OK
|
68
bin/v_del_dns_domains
Executable file
68
bin/v_del_dns_domains
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: deleteing all user dns domains
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Checking arg number
|
||||||
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
|
# Checking argument format
|
||||||
|
format_validation 'user'
|
||||||
|
|
||||||
|
# Checking web system is enabled
|
||||||
|
is_system_enabled 'dns'
|
||||||
|
|
||||||
|
# Checking user
|
||||||
|
is_user_valid
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Defining config
|
||||||
|
conf="$V_USERS/$user/dns.conf"
|
||||||
|
|
||||||
|
# Defining fileds to select
|
||||||
|
field='$DOMAIN'
|
||||||
|
|
||||||
|
# Defining search string
|
||||||
|
search_string="SUSPEND='no'"
|
||||||
|
|
||||||
|
# Parsing domain list
|
||||||
|
domains=$(dom_clear_search)
|
||||||
|
|
||||||
|
# Starting delete loop
|
||||||
|
for domain in $domains; do
|
||||||
|
$V_BIN/v_del_dns_domain "$user" "$domain"
|
||||||
|
rv="$?"
|
||||||
|
if [ "$rv" -ne '0' ]; then
|
||||||
|
log_event 'debug' "$rv $V_EVENT"
|
||||||
|
exit $rv
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
|
exit $OK
|
129
bin/v_del_sys_user
Executable file
129
bin/v_del_sys_user
Executable file
|
@ -0,0 +1,129 @@
|
||||||
|
#!/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_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
|
||||||
|
|
||||||
|
# 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
|
|
@ -57,7 +57,7 @@ update_sys_ip_value '$OWNER' ''
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Updating user conf
|
# Updating user conf
|
||||||
decrease_user_value '$IP_OWNED'
|
decrease_user_value $user '$IP_OWNED'
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event 'system' "$V_EVENT"
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
57
bin/v_del_sys_user_ips
Executable file
57
bin/v_del_sys_user_ips
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: deleting user ip
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user="$1"
|
||||||
|
|
||||||
|
# Importing variables
|
||||||
|
source $VESTA/conf/vars.conf
|
||||||
|
source $V_FUNC/shared_func.sh
|
||||||
|
source $V_FUNC/ip_func.sh
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Starting delete loop
|
||||||
|
for ip in $(ip_owner_search); do
|
||||||
|
$V_BIN/v_del_sys_user_ip "$user" "$ip"
|
||||||
|
rv="$?"
|
||||||
|
if [ "$rv" -ne '0' ]; then
|
||||||
|
log_event 'debug' "$rv $V_EVENT"
|
||||||
|
exit $rv
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
|
exit $OK
|
68
bin/v_del_web_domains
Executable file
68
bin/v_del_web_domains
Executable file
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: deleteing all user web domains
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Checking arg number
|
||||||
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
|
# Checking argument format
|
||||||
|
format_validation 'user'
|
||||||
|
|
||||||
|
# Checking web system is enabled
|
||||||
|
is_system_enabled 'web'
|
||||||
|
|
||||||
|
# Checking user
|
||||||
|
is_user_valid
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Defining config
|
||||||
|
conf="$V_USERS/$user/web.conf"
|
||||||
|
|
||||||
|
# Defining fileds to select
|
||||||
|
field='$DOMAIN'
|
||||||
|
|
||||||
|
# Defining search string
|
||||||
|
search_string="SUSPEND='no'"
|
||||||
|
|
||||||
|
# Parsing domain list
|
||||||
|
domains=$(dom_clear_search)
|
||||||
|
|
||||||
|
# Starting delete loop
|
||||||
|
for domain in $domains; do
|
||||||
|
$V_BIN/v_del_web_domain "$user" "$domain"
|
||||||
|
rv="$?"
|
||||||
|
if [ "$rv" -ne '0' ]; then
|
||||||
|
log_event 'debug' "$rv $V_EVENT"
|
||||||
|
exit $rv
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event 'system' "$V_EVENT"
|
||||||
|
|
||||||
|
exit $OK
|
|
@ -591,3 +591,12 @@ ipint_shell_list() {
|
||||||
echo "$interface"
|
echo "$interface"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip_owner_search(){
|
||||||
|
for ip in $(ls $V_IPS/); do
|
||||||
|
check_owner=$(grep "OWNER='$user'" $V_IPS/$ip)
|
||||||
|
if [ ! -z "$check_owner" ]; then
|
||||||
|
echo "$ip"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
|
@ -973,6 +973,21 @@ decrease_user_value() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is_user_parent() {
|
||||||
|
childs="$(grep "U_CHILDS=" $V_USERS/$user/user.conf |cut -f 2 -d \')"
|
||||||
|
if [ -z "$childs" ]; then
|
||||||
|
echo "Error: Parsing error"
|
||||||
|
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
|
||||||
|
exit $E_PARSE_ERROR
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$childs" -gt '0' ]; then
|
||||||
|
echo "Error: user have childs"
|
||||||
|
log_event 'debug' "$E_CHILD_EXIST $V_EVENT"
|
||||||
|
exit $E_CHILD_EXIST
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Json listing function
|
# Json listing function
|
||||||
v_json_list() {
|
v_json_list() {
|
||||||
# Definigng variables
|
# Definigng variables
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue