mirror of
https://github.com/myvesta/vesta.git
synced 2024-11-20 20:40:08 -08:00
93 lines
2.4 KiB
Bash
Executable File
93 lines
2.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: unsuspend user
|
|
# options: USER [RESTART]
|
|
#
|
|
# The function unsuspends user and all his objects.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
user=$1
|
|
restart=$2
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
source $VESTA/conf/vesta.conf
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Verifications #
|
|
#----------------------------------------------------------#
|
|
|
|
check_args '1' "$#" 'USER'
|
|
is_format_valid 'user'
|
|
is_object_valid 'user' 'USER' "$user"
|
|
if [ "$user" = 'admin' ]; then
|
|
exit
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Deleting '!' in front of the password
|
|
/usr/sbin/usermod --unlock $user
|
|
|
|
# Unsuspending ftp accounts
|
|
for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do
|
|
/usr/sbin/usermod --unlock $ftp 2>/dev/null
|
|
done
|
|
|
|
# Unsuspending web domains
|
|
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
|
|
$BIN/v-unsuspend-web-domains $user $restart
|
|
fi
|
|
|
|
# Unsuspending dns domains
|
|
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
|
|
$BIN/v-unsuspend-dns-domains $user $restart
|
|
fi
|
|
|
|
# Unsuspending mail domains
|
|
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
|
|
$BIN/v-unsuspend-mail-domains $user
|
|
fi
|
|
|
|
# Unsuspending datbabases
|
|
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
|
$BIN/v-unsuspend-databases $user
|
|
fi
|
|
|
|
# Unsuspending cron jobs
|
|
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
|
|
$BIN/v-unsuspend-cron-jobs $user $restart
|
|
fi
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
# Changing suspend value
|
|
update_user_value "$user" '$SUSPENDED' 'no'
|
|
decrease_user_value 'admin' '$SUSPENDED_USERS'
|
|
|
|
# Restarting system services
|
|
$BIN/v-restart-web $restart
|
|
check_result $? "Web restart failed" >/dev/null
|
|
|
|
$BIN/v-restart-dns $restart
|
|
check_result $? "DNS restart failed" >/dev/null
|
|
|
|
$BIN/v-restart-cron $restart
|
|
check_result $? "Cron restart failed" >/dev/null
|
|
|
|
# Logging
|
|
log_event "$OK" "$ARGUMENTS"
|
|
|
|
exit
|