mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 05:14:10 -07:00
Refactoring stage V (user)
This commit is contained in:
parent
3ba10cdc6e
commit
fb40168aa3
42 changed files with 225 additions and 551 deletions
|
@ -17,15 +17,12 @@ package=${4-default}
|
||||||
fname=$5
|
fname=$5
|
||||||
lname=$6
|
lname=$6
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
is_user_free() {
|
is_user_free() {
|
||||||
# Parsing domain values
|
|
||||||
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
|
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
|
||||||
|
|
||||||
# Checking result
|
|
||||||
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
|
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
|
||||||
echo "Error: user $user exist"
|
echo "Error: user $user exist"
|
||||||
log_event "$E_EXISTS" "$EVENT"
|
log_event "$E_EXISTS" "$EVENT"
|
||||||
|
@ -38,16 +35,13 @@ is_user_free() {
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user password email [package] [fname] [lname]'
|
check_args '3' "$#" 'user password email [package] [fname] [lname]'
|
||||||
|
validate_format 'user' 'password' 'email' 'package'
|
||||||
|
if [ ! -z "$fname" ]; then
|
||||||
|
validate_format 'fname' 'lname'
|
||||||
|
fi
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'password' 'email' 'package' 'fname' 'lname'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_user_free "$user"
|
is_user_free "$user"
|
||||||
|
|
||||||
# Checking package
|
|
||||||
is_package_valid "$package"
|
is_package_valid "$package"
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +69,6 @@ echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null
|
||||||
|
|
||||||
# Building directory tree
|
# Building directory tree
|
||||||
mkdir $HOMEDIR/$user/conf
|
mkdir $HOMEDIR/$user/conf
|
||||||
chmod 751 $HOMEDIR/$user/conf/web
|
|
||||||
|
|
||||||
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
|
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
|
||||||
mkdir $HOMEDIR/$user/conf/web
|
mkdir $HOMEDIR/$user/conf/web
|
||||||
|
@ -206,6 +199,7 @@ U_MAIL_ACCOUNTS='0'
|
||||||
U_DATABASES='0'
|
U_DATABASES='0'
|
||||||
U_CRON_JOBS='0'
|
U_CRON_JOBS='0'
|
||||||
U_BACKUPS='0'
|
U_BACKUPS='0'
|
||||||
|
TIME='$TIME'
|
||||||
DATE='$DATE'" > $USER_DATA/user.conf
|
DATE='$DATE'" > $USER_DATA/user.conf
|
||||||
chmod 660 $USER_DATA/user.conf
|
chmod 660 $USER_DATA/user.conf
|
||||||
|
|
||||||
|
@ -215,7 +209,8 @@ if [ "$user" != 'admin' ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Hiding password
|
# Hiding password
|
||||||
EVENT="$DATE $SCRIPT $user ***** $email $package $fname $lname"
|
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
|
||||||
|
EVENT="$EVENT ARGUMENTS='$user ***** $email $package $fname $lname'"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -21,19 +21,10 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
is_system_enabled "$BACKUP_SYSTEM"
|
||||||
# Checking backup system is enabled
|
|
||||||
is_system_enabled 'BACKUP_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user backups
|
|
||||||
is_backup_enabled
|
is_backup_enabled
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -70,7 +70,7 @@ fi
|
||||||
# Update config value
|
# Update config value
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes'
|
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web "$EVENT"
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -19,7 +19,7 @@ default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
|
||||||
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
|
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
|
||||||
extentions=${4-$default_extentions}
|
extentions=${4-$default_extentions}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -93,7 +93,7 @@ fi
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
|
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
|
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web "$EVENT"
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -23,36 +23,23 @@ source $VESTA/func/db.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
is_system_enabled "$BACKUP_SYSTEM"
|
||||||
# Checking backup system is enabled
|
|
||||||
is_system_enabled 'BACKUP_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
# Checking user backups
|
|
||||||
is_backup_enabled
|
is_backup_enabled
|
||||||
|
|
||||||
# Checking load averages
|
|
||||||
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
|
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
|
||||||
i=0
|
i=0
|
||||||
while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
|
while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
|
||||||
echo "$(date "+%F %T") Load Average $la"
|
echo "$(date "+%F %T") Load Average $la"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
sleep 60
|
sleep 60
|
||||||
|
|
||||||
if [ "$i" -ge "15" ]; then
|
if [ "$i" -ge "15" ]; then
|
||||||
echo "Error: LA is too high"
|
echo "Error: LA is too high"
|
||||||
log_event 'debug' "$E_LA $EVENT"
|
log_event "$E_LA" "$EVENT"
|
||||||
exit $E_LA
|
exit $E_LA
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(( ++i))
|
(( ++i))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -76,8 +63,6 @@ echo
|
||||||
echo "1.0" > $tmpdir/backup_version
|
echo "1.0" > $tmpdir/backup_version
|
||||||
echo "$VERSION" > $tmpdir/vesta_version
|
echo "$VERSION" > $tmpdir/vesta_version
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Vesta
|
# Vesta
|
||||||
echo "-- VESTA --"
|
echo "-- VESTA --"
|
||||||
vst='yes'
|
vst='yes'
|
||||||
|
@ -103,7 +88,6 @@ if [ -e "$USER_DATA/backup.excludes" ]; then
|
||||||
cp -r $USER_DATA/backup.excludes $tmpdir/vesta/
|
cp -r $USER_DATA/backup.excludes $tmpdir/vesta/
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# PAM
|
# PAM
|
||||||
|
@ -139,13 +123,7 @@ then
|
||||||
|
|
||||||
# Parsing unsuspeneded domains
|
# Parsing unsuspeneded domains
|
||||||
conf="$USER_DATA/web.conf"
|
conf="$USER_DATA/web.conf"
|
||||||
field='$DOMAIN'
|
for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||||
search_string='DOMAIN='
|
|
||||||
domains=$(dom_clear_search)
|
|
||||||
domain_list=''
|
|
||||||
|
|
||||||
# Cleaning excludes
|
|
||||||
for domain in $domains; do
|
|
||||||
check_exl=$(echo "$WEB"|grep -w $domain)
|
check_exl=$(echo "$WEB"|grep -w $domain)
|
||||||
if [ -z "$check_exl" ]; then
|
if [ -z "$check_exl" ]; then
|
||||||
web_list="$web_list $domain"
|
web_list="$web_list $domain"
|
||||||
|
@ -163,8 +141,8 @@ then
|
||||||
|
|
||||||
# Packing data folders
|
# Packing data folders
|
||||||
cd $HOMEDIR/$user/web/$domain
|
cd $HOMEDIR/$user/web/$domain
|
||||||
tar -cf $tmpdir/web/$domain/$domain.tar \
|
domain_direcotries=$(ls |grep -v logs)
|
||||||
public_html public_shtml private document_errors cgi-bin stats
|
tar -cf $tmpdir/web/$domain/$domain.tar $domain_direcotries
|
||||||
|
|
||||||
# Creating web.config
|
# Creating web.config
|
||||||
cd $tmpdir/web/$domain/
|
cd $tmpdir/web/$domain/
|
||||||
|
@ -233,13 +211,7 @@ then
|
||||||
mkdir $tmpdir/dns/
|
mkdir $tmpdir/dns/
|
||||||
|
|
||||||
# Parsing unsuspeneded domains
|
# Parsing unsuspeneded domains
|
||||||
conf="$USER_DATA/dns.conf"
|
for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
|
||||||
field='$DOMAIN'
|
|
||||||
search_string='DOMAIN='
|
|
||||||
domains=$(dom_clear_search)
|
|
||||||
|
|
||||||
# Cleaning excludes
|
|
||||||
for domain in $domains; do
|
|
||||||
check_exl=$(echo "$DNS"|grep -w $domain)
|
check_exl=$(echo "$DNS"|grep -w $domain)
|
||||||
if [ -z "$check_exl" ]; then
|
if [ -z "$check_exl" ]; then
|
||||||
dns_list="$dns_list $domain"
|
dns_list="$dns_list $domain"
|
||||||
|
@ -258,8 +230,8 @@ then
|
||||||
grep "DOMAIN='$domain'" $conf > dns.conf
|
grep "DOMAIN='$domain'" $conf > dns.conf
|
||||||
|
|
||||||
# Backingup dns recods
|
# Backingup dns recods
|
||||||
cp $USER_DATA/dns/$domain $domain
|
cp $USER_DATA/dns/$domain.conf $domain.conf
|
||||||
cp $USER_DATA/conf/dns/$domain.db $domain.db
|
cp $HOMEDIR/$user/conf/dns/$domain.db $domain.db
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
@ -274,13 +246,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then
|
||||||
mkdir $tmpdir/db/
|
mkdir $tmpdir/db/
|
||||||
|
|
||||||
# Parsing unsuspeneded domains
|
# Parsing unsuspeneded domains
|
||||||
conf="$USER_DATA/db.conf"
|
for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do
|
||||||
field='$DB'
|
|
||||||
search_string='DB='
|
|
||||||
dbs=$(dom_clear_search)
|
|
||||||
|
|
||||||
# Cleaning excludes
|
|
||||||
for database in $dbs; do
|
|
||||||
check_exl=$(echo "$DB"|grep -w $database)
|
check_exl=$(echo "$DB"|grep -w $database)
|
||||||
if [ -z "$check_exl" ]; then
|
if [ -z "$check_exl" ]; then
|
||||||
db_list="$db_list $database"
|
db_list="$db_list $database"
|
||||||
|
@ -289,23 +255,17 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then
|
||||||
db_list=$(echo "$db_list" | sed -e "s/ */\ /g" -e "s/^ //")
|
db_list=$(echo "$db_list" | sed -e "s/ */\ /g" -e "s/^ //")
|
||||||
|
|
||||||
for database in $db_list; do
|
for database in $db_list; do
|
||||||
type=$(get_db_value '$TYPE')
|
get_database_values
|
||||||
host=$(get_db_value '$HOST')
|
dump="$tmpdir/db/$database.$TYPE.sql"
|
||||||
db_user=$(get_db_value '$USER')
|
grants="$tmpdir/db/$database.$TYPE.$DBUSER"
|
||||||
dump="$tmpdir/db/$database.$type.sql"
|
echo -e "$(date "+%F %T") $database $TYPE"
|
||||||
grants="$tmpdir/db/$database.$type.$db_user"
|
case $TYPE in
|
||||||
|
mysql) dump_mysql_database ;;
|
||||||
echo -e "$(date "+%F %T") $database $type"
|
pgsql) dump_pgsql_database ;;
|
||||||
|
|
||||||
case $type in
|
|
||||||
mysql) dump_db_mysql ;;
|
|
||||||
pgsql) dump_db_pgsql ;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ ! -z "$BACKUP_GZIP" ]; then
|
if [ ! -z "$BACKUP_GZIP" ]; then
|
||||||
gzip -$BACKUP_GZIP $dump
|
gzip -$BACKUP_GZIP $dump
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
@ -333,6 +293,9 @@ size="$(du -shm $tmpdir | cut -f 1)"
|
||||||
|
|
||||||
# Get current time
|
# Get current time
|
||||||
end_time=$(date '+%s')
|
end_time=$(date '+%s')
|
||||||
|
DATE=$(date +%F)
|
||||||
|
TIME=$(date +%T)
|
||||||
|
|
||||||
|
|
||||||
# Defining local storage function
|
# Defining local storage function
|
||||||
local_backup(){
|
local_backup(){
|
||||||
|
@ -349,7 +312,6 @@ local_backup(){
|
||||||
# Checking retention
|
# Checking retention
|
||||||
backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.")
|
backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.")
|
||||||
backups_count=$(echo "$backup_list" | wc -l)
|
backups_count=$(echo "$backup_list" | wc -l)
|
||||||
|
|
||||||
if [ "$BACKUPS" -le "$backups_count" ]; then
|
if [ "$BACKUPS" -le "$backups_count" ]; then
|
||||||
backups_rm_number=$((backups_count - BACKUPS))
|
backups_rm_number=$((backups_count - BACKUPS))
|
||||||
(( ++backups_rm_number))
|
(( ++backups_rm_number))
|
||||||
|
@ -367,7 +329,7 @@ local_backup(){
|
||||||
disk_usage=$(df $BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%')
|
disk_usage=$(df $BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%')
|
||||||
if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then
|
if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then
|
||||||
echo "Error: Not enough disk space"
|
echo "Error: Not enough disk space"
|
||||||
log_event 'debug' "$E_DISK $EVENT"
|
log_event "$E_DISK" "$EVENT"
|
||||||
exit $E_DISK
|
exit $E_DISK
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -402,7 +364,7 @@ ftp_backup(){
|
||||||
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
|
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
|
||||||
[ -z "$BPATH" ]; then
|
[ -z "$BPATH" ]; then
|
||||||
echo "Error: Parsing error"
|
echo "Error: Parsing error"
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
exit $E_PARSING
|
exit $E_PARSING
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -417,7 +379,7 @@ ftp_backup(){
|
||||||
rm $ftmpdir"
|
rm $ftmpdir"
|
||||||
if [ ! -z "$(ftpc "$command")" ] ; then
|
if [ ! -z "$(ftpc "$command")" ] ; then
|
||||||
echo "Error: FTP error"
|
echo "Error: FTP error"
|
||||||
log_event 'debug' "$E_FTP $EVENT"
|
log_event "$E_FTP" "$EVENT"
|
||||||
exit $E_FTP
|
exit $E_FTP
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -489,7 +451,7 @@ for backup_record in $deprecated; do
|
||||||
done
|
done
|
||||||
|
|
||||||
# Concatenating string
|
# Concatenating string
|
||||||
backup_str="DATE='$DATE' TIME='$current_time' RUNTIME='$run_time'"
|
backup_str="DATE='$DATE' TIME='$TIME' RUNTIME='$run_time'"
|
||||||
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
|
||||||
backup_str="$backup_str VESTA='$vst'"
|
backup_str="$backup_str VESTA='$vst'"
|
||||||
backup_str="$backup_str PAM='$pam'"
|
backup_str="$backup_str PAM='$pam'"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# mostly by cron wich not read it by itself
|
# mostly by cron wich not read it by itself
|
||||||
source /etc/profile.d/vesta.sh
|
source /etc/profile.d/vesta.sh
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -22,11 +22,12 @@ source $VESTA/func/shared.sh
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
user_list=$(ls $V_USERS/)
|
|
||||||
|
|
||||||
# Updating user billing
|
# Updating user billing
|
||||||
for user in $user_list; do
|
for user in $(ls $VESTA/data/users); do
|
||||||
$BIN/v_backup_user $user &>> $VESTA/logs/backup.log
|
check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf)
|
||||||
|
if [ ! -z "$check_suspend" ]; then
|
||||||
|
$BIN/v_backup_user $user >> $VESTA/log/backup.log 2>&1
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
ip=$1
|
ip=$1
|
||||||
user=$2
|
user=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/ip.sh
|
source $VESTA/func/ip.sh
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
email=$2
|
email=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -22,16 +22,9 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user email'
|
check_args '2' "$#" 'user email'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'email'
|
validate_format 'user' 'email'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,13 +32,9 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Get old value
|
|
||||||
old_email=$(get_user_value '$CONTACT')
|
|
||||||
|
|
||||||
# Changing user contact email
|
# Changing user contact email
|
||||||
|
old_email=$get_user_value '$CONTACT')
|
||||||
update_user_value "$user" '$CONTACT' "$email"
|
update_user_value "$user" '$CONTACT' "$email"
|
||||||
|
|
||||||
# Changing passwd file
|
|
||||||
pw_str=$(grep -n "^$user:" /etc/passwd)
|
pw_str=$(grep -n "^$user:" /etc/passwd)
|
||||||
str=$(echo "$pw_str" | cut -f 1 -d :)
|
str=$(echo "$pw_str" | cut -f 1 -d :)
|
||||||
sed -i "$str s/$old_email/$email/g" /etc/passwd
|
sed -i "$str s/$old_email/$email/g" /etc/passwd
|
||||||
|
@ -56,7 +45,7 @@ sed -i "$str s/$old_email/$email/g" /etc/passwd
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "$SCRIPT $user $old_email"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -14,7 +14,7 @@ user=$1
|
||||||
fname=$2
|
fname=$2
|
||||||
lname=$3
|
lname=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -23,16 +23,9 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
|
||||||
check_args '3' "$#" 'user fname lname'
|
check_args '3' "$#" 'user fname lname'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'fname' 'lname'
|
validate_format 'user' 'fname' 'lname'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,7 +47,7 @@ update_user_value "$user" '$LNAME' "$lname"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "$SCRIPT $user $old_fname $old_lname"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -20,7 +20,7 @@ ns6=$7
|
||||||
ns7=$8
|
ns7=$8
|
||||||
ns8=$9
|
ns8=$9
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -37,31 +37,23 @@ validate_format 'user' 'ns1' 'ns2'
|
||||||
if [ ! -z "$ns3" ]; then
|
if [ ! -z "$ns3" ]; then
|
||||||
validate_format 'ns3'
|
validate_format 'ns3'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$ns4" ]; then
|
if [ ! -z "$ns4" ]; then
|
||||||
validate_format 'ns4'
|
validate_format 'ns4'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$ns5" ]; then
|
if [ ! -z "$ns5" ]; then
|
||||||
validate_format 'ns5'
|
validate_format 'ns5'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$ns6" ]; then
|
if [ ! -z "$ns6" ]; then
|
||||||
validate_format 'ns6'
|
validate_format 'ns6'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$ns7" ]; then
|
if [ ! -z "$ns7" ]; then
|
||||||
validate_format 'ns7'
|
validate_format 'ns7'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z "$ns8" ]; then
|
if [ ! -z "$ns8" ]; then
|
||||||
validate_format 'ns8'
|
validate_format 'ns8'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,9 +61,6 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Get old values
|
|
||||||
old_ns=$(get_user_value '$NS')
|
|
||||||
|
|
||||||
# Merging values
|
# Merging values
|
||||||
ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8"
|
ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8"
|
||||||
ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//")
|
ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//")
|
||||||
|
@ -85,7 +74,7 @@ update_user_value "$user" '$NS' "$ns"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "$SCRIPT $user ${old_ns//,/ }"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
package=$2
|
package=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ is_package_avalable() {
|
||||||
eval ${key%%=*}=${key#*=}
|
eval ${key%%=*}=${key#*=}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Clearing vars
|
|
||||||
WEB_DOMAINS='0'
|
WEB_DOMAINS='0'
|
||||||
DATABASES='0'
|
DATABASES='0'
|
||||||
MAIL_DOMAINS='0'
|
MAIL_DOMAINS='0'
|
||||||
|
@ -33,11 +32,8 @@ is_package_avalable() {
|
||||||
DISK_QUOTA='0'
|
DISK_QUOTA='0'
|
||||||
BANDWIDTH='0'
|
BANDWIDTH='0'
|
||||||
|
|
||||||
# Parsing package
|
|
||||||
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
|
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
|
||||||
for key in $pkg_data; do
|
eval $pkg_data
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Comparing user data with package
|
# Comparing user data with package
|
||||||
if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\
|
if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\
|
||||||
|
@ -48,17 +44,15 @@ is_package_avalable() {
|
||||||
[[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\
|
[[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\
|
||||||
[[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then
|
[[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then
|
||||||
echo "Error: Upgrade package"
|
echo "Error: Upgrade package"
|
||||||
log_event 'debug' "$E_LIMIT $v_log"
|
log_event "$E_LIMIT" "$EVENT"
|
||||||
exit $E_LIMIT
|
exit $E_LIMIT
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
change_user_package() {
|
change_user_package() {
|
||||||
# Parsing user data
|
|
||||||
usr_data=$(cat $USER_DATA/user.conf)
|
usr_data=$(cat $USER_DATA/user.conf)
|
||||||
eval $usr_data
|
eval $usr_data
|
||||||
|
|
||||||
# Parsing package
|
|
||||||
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
|
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
|
||||||
eval $pkg_data
|
eval $pkg_data
|
||||||
|
|
||||||
|
@ -116,19 +110,10 @@ DATE='$DATE'" > $USER_DATA/user.conf
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user package'
|
check_args '2' "$#" 'user package'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'package'
|
validate_format 'user' 'package'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking package
|
|
||||||
is_package_valid
|
is_package_valid
|
||||||
|
|
||||||
# Checking current data
|
|
||||||
is_package_avalable
|
is_package_avalable
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
password=$2
|
password=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -22,16 +22,9 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user password'
|
check_args '2' "$#" 'user password'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'password'
|
validate_format 'user' 'password'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +44,7 @@ echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null
|
||||||
update_user_value "$user" '$RKEY' "$(gen_password)"
|
update_user_value "$user" '$RKEY' "$(gen_password)"
|
||||||
|
|
||||||
# Hiding password
|
# Hiding password
|
||||||
EVENT="$DATE $SCRIPT $user *****"
|
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT' ARGUMENTS='$user *****'"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
shell=$2
|
shell=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -22,16 +22,9 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user shell'
|
check_args '2' "$#" 'user shell'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'shell'
|
validate_format 'user' 'shell'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,11 +33,11 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Get shell full path
|
# Get shell full path
|
||||||
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
|
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1)
|
||||||
|
|
||||||
# Changing passwd file
|
# Changing passwd file
|
||||||
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
|
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
|
||||||
|
shell=$(basename $shell_path)
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
type=$1
|
type=$1
|
||||||
host=$2
|
host=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
ip=$1
|
ip=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/ip.sh
|
source $VESTA/func/ip.sh
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -25,19 +25,10 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user admin
|
|
||||||
if [ "$user" = 'admin' ]; then
|
if [ "$user" = 'admin' ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -69,7 +60,7 @@ fi
|
||||||
# Checking mail system is enabled
|
# Checking mail system is enabled
|
||||||
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
|
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
|
||||||
$BIN/v_unsuspend_mail_domains $user
|
$BIN/v_unsuspend_mail_domains $user
|
||||||
$BIN/v_del_mail_domains $user
|
#$BIN/v_delete_mail_domains $user
|
||||||
rv="$?"
|
rv="$?"
|
||||||
if [ "$rv" -ne '0' ]; then
|
if [ "$rv" -ne '0' ]; then
|
||||||
exit $rv
|
exit $rv
|
||||||
|
@ -78,8 +69,8 @@ fi
|
||||||
|
|
||||||
# Checking db system is enabled
|
# Checking db system is enabled
|
||||||
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
||||||
$BIN/v_unsuspend_db_bases $user
|
$BIN/v_unsuspend_databases $user
|
||||||
$BIN/v_delete_db_dbases $user
|
$BIN/v_delete_databases $user
|
||||||
rv="$?"
|
rv="$?"
|
||||||
if [ "$rv" -ne '0' ]; then
|
if [ "$rv" -ne '0' ]; then
|
||||||
exit $rv
|
exit $rv
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/ip.sh
|
source $VESTA/func/ip.sh
|
||||||
|
@ -22,23 +22,15 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user vesta
|
|
||||||
if [ "$user" = 'admin' ]; then
|
if [ "$user" = 'admin' ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -54,8 +46,8 @@ for ip in $ip_list; do
|
||||||
is_ip_key_empty '$U_SYS_USERS'
|
is_ip_key_empty '$U_SYS_USERS'
|
||||||
|
|
||||||
# Assig ip to main account
|
# Assig ip to main account
|
||||||
update_sys_ip_value '$OWNER' 'admin'
|
update_ip_value '$OWNER' 'admin'
|
||||||
update_sys_ip_value '$STATUS' 'dedicated'
|
update_ip_value '$STATUS' 'dedicated'
|
||||||
increase_user_value 'admin' '$IP_OWNED'
|
increase_user_value 'admin' '$IP_OWNED'
|
||||||
increase_user_value 'admin' '$IP_AVAIL'
|
increase_user_value 'admin' '$IP_AVAIL'
|
||||||
done
|
done
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
|
key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -22,18 +22,10 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
|
||||||
check_args '2' "$#" 'user key'
|
check_args '2' "$#" 'user key'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
|
|
67
bin/v_list_sys_shells
Executable file
67
bin/v_list_sys_shells
Executable file
|
@ -0,0 +1,67 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: list system shells
|
||||||
|
# options: [format]
|
||||||
|
#
|
||||||
|
# The function for obtaining the list of system shells.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
format=${1-shell}
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
# Json function
|
||||||
|
json_list_sh() {
|
||||||
|
shells=$(cat /etc/shells)
|
||||||
|
sh_counter=$(echo "$shells" | wc -l)
|
||||||
|
i=1
|
||||||
|
echo '['
|
||||||
|
for shell in $shells; do
|
||||||
|
shell=$(basename $shell)
|
||||||
|
if [ "$i" -lt "$sh_counter" ]; then
|
||||||
|
echo -e "\t\"$shell\","
|
||||||
|
else
|
||||||
|
echo -e "\t\"$shell\""
|
||||||
|
fi
|
||||||
|
(( ++i))
|
||||||
|
done
|
||||||
|
echo "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Shell function
|
||||||
|
shell_list_sh() {
|
||||||
|
shells=$(cat /etc/shells)
|
||||||
|
if [ -z "$nohead" ]; then
|
||||||
|
echo "SHELLS"
|
||||||
|
echo "----------"
|
||||||
|
fi
|
||||||
|
for shell in $shells; do
|
||||||
|
shell=$(basename $shell)
|
||||||
|
echo "$shell"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Listing domains
|
||||||
|
case $format in
|
||||||
|
json) json_list_sh ;;
|
||||||
|
plain) nohead=1; shell_list_sh ;;
|
||||||
|
shell) shell_list_sh ;;
|
||||||
|
*) check_args '1' '0' '[format]' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit
|
|
@ -47,6 +47,9 @@ shell_list_user() {
|
||||||
source $VESTA/data/users/$user/user.conf
|
source $VESTA/data/users/$user/user.conf
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval key="$field"
|
eval key="$field"
|
||||||
|
if [ -z "$key" ]; then
|
||||||
|
key='NULL'
|
||||||
|
fi
|
||||||
echo "${field//$/}: $key "
|
echo "${field//$/}: $key "
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,20 +13,15 @@
|
||||||
user=$1
|
user=$1
|
||||||
format=${2-shell}
|
format=${2-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
|
||||||
check_args '1' "$#" 'user [format]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,18 +13,16 @@
|
||||||
user=$1
|
user=$1
|
||||||
format=${2-shell}
|
format=${2-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
# Json function
|
# Json function
|
||||||
json_list_user_ips() {
|
json_list_user_ips() {
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
echo '{'
|
||||||
fileds_count=$(echo "$fields" | wc -w)
|
fileds_count=$(echo "$fields" | wc -w)
|
||||||
for IP in $(ls $VESTA/data/ips/); do
|
for IP in $(ls $VESTA/data/ips/); do
|
||||||
source $VESTA/data/ips/$IP
|
source $VESTA/data/ips/$IP
|
||||||
if [ "$OWNER" = "$user" ]; then
|
if [ "$OWNER" = "$user" ]; then
|
||||||
# Closing bracket if there already was output
|
|
||||||
if [ -n "$data" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e ' },'
|
echo -e ' },'
|
||||||
fi
|
fi
|
||||||
|
@ -32,11 +30,9 @@ json_list_user_ips() {
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval value=$field
|
eval value=$field
|
||||||
if [ $i -eq 1 ]; then
|
if [ $i -eq 1 ]; then
|
||||||
# Printing parrent
|
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\"$value\": {"
|
echo -e "\t\"$value\": {"
|
||||||
else
|
else
|
||||||
# Printing child
|
|
||||||
if [ $i -lt $fileds_count ]; then
|
if [ $i -lt $fileds_count ]; then
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||||
|
@ -52,11 +48,9 @@ json_list_user_ips() {
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval value=$field
|
eval value=$field
|
||||||
if [ $i -eq 1 ]; then
|
if [ $i -eq 1 ]; then
|
||||||
# Printing parrent
|
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\"$value\": {"
|
echo -e "\t\"$value\": {"
|
||||||
else
|
else
|
||||||
# Printing child
|
|
||||||
if [ $i -lt $fileds_count ]; then
|
if [ $i -lt $fileds_count ]; then
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||||
|
@ -69,13 +63,9 @@ json_list_user_ips() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Closing bracket if there was output
|
|
||||||
if [ -n "$data" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e ' }'
|
echo -e ' }'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Printing bottom bracket
|
|
||||||
echo -e '}'
|
echo -e '}'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,13 +89,8 @@ shell_list_user_ips() {
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user [format]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,17 +13,15 @@
|
||||||
user=$1
|
user=$1
|
||||||
format=${2-shell}
|
format=${2-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
# Json function
|
# Json function
|
||||||
json_list_ns() {
|
json_list_ns() {
|
||||||
ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \')
|
ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \')
|
||||||
# Print top bracket
|
|
||||||
echo '['
|
echo '['
|
||||||
i=1
|
i=1
|
||||||
nslistc=$(echo -e "${ns//,/\n}"|wc -l)
|
nslistc=$(echo -e "${ns//,/\n}"|wc -l)
|
||||||
# Listing servers
|
|
||||||
for nameserver in ${ns//,/ };do
|
for nameserver in ${ns//,/ };do
|
||||||
if [ "$i" -ne "$nslistc" ]; then
|
if [ "$i" -ne "$nslistc" ]; then
|
||||||
echo -e "\t\"$nameserver\","
|
echo -e "\t\"$nameserver\","
|
||||||
|
@ -32,7 +30,6 @@ json_list_ns() {
|
||||||
fi
|
fi
|
||||||
(( ++i))
|
(( ++i))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "]"
|
echo "]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +37,9 @@ json_list_ns() {
|
||||||
shell_list_ns() {
|
shell_list_ns() {
|
||||||
ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \')
|
ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \')
|
||||||
if [ -z "$nohead" ]; then
|
if [ -z "$nohead" ]; then
|
||||||
# Print result
|
|
||||||
echo "NAMESERVER"
|
echo "NAMESERVER"
|
||||||
echo "----------"
|
echo "----------"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for nameserver in ${ns//,/ };do
|
for nameserver in ${ns//,/ };do
|
||||||
echo "$nameserver"
|
echo "$nameserver"
|
||||||
done
|
done
|
||||||
|
@ -55,13 +50,8 @@ shell_list_ns() {
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
|
||||||
check_args '1' "$#" 'user [format]'
|
check_args '1' "$#" 'user [format]'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,37 +12,27 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format=${1-shell}
|
format=${1-shell}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
# Json function
|
# Json function
|
||||||
json_list_pkgs() {
|
json_list_pkgs() {
|
||||||
# Print top bracket
|
|
||||||
echo '{'
|
echo '{'
|
||||||
|
|
||||||
fileds_count=$(echo "$fields" | wc -w)
|
fileds_count=$(echo "$fields" | wc -w)
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for package in $(ls $VESTA/data/packages); do
|
for package in $(ls $VESTA/data/packages); do
|
||||||
PACKAGE=${package/.pkg/}
|
PACKAGE=${package/.pkg/}
|
||||||
# Assing key=value
|
|
||||||
pkg_data=$(cat $VESTA/data/packages/$package)
|
pkg_data=$(cat $VESTA/data/packages/$package)
|
||||||
eval $pkg_data
|
eval $pkg_data
|
||||||
|
|
||||||
# Closing bracket if there already was output
|
|
||||||
if [ -n "$data" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e ' },'
|
echo -e ' },'
|
||||||
fi
|
fi
|
||||||
i=1
|
i=1
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval value=$field
|
eval value=$field
|
||||||
|
|
||||||
if [ $i -eq 1 ]; then
|
if [ $i -eq 1 ]; then
|
||||||
# Printing parrent
|
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\"$value\": {"
|
echo -e "\t\"$value\": {"
|
||||||
else
|
else
|
||||||
# Printing child
|
|
||||||
if [ $i -lt $fileds_count ]; then
|
if [ $i -lt $fileds_count ]; then
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||||
|
@ -53,40 +43,29 @@ json_list_pkgs() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
# Closing bracket if there was output
|
|
||||||
if [ -n "$data" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e ' }'
|
echo -e ' }'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Printing bottom bracket
|
|
||||||
echo -e '}'
|
echo -e '}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shell fnction
|
# Shell fnction
|
||||||
shell_list_pkgs() {
|
shell_list_pkgs() {
|
||||||
# Listing pkg files
|
|
||||||
for package in $(ls $VESTA/data/packages); do
|
for package in $(ls $VESTA/data/packages); do
|
||||||
PACKAGE=${package/.pkg/}
|
PACKAGE=${package/.pkg/}
|
||||||
# Assign key=value
|
|
||||||
pkg_descr=$(cat $VESTA/data/packages/$package)
|
pkg_descr=$(cat $VESTA/data/packages/$package)
|
||||||
eval $pkg_descr
|
eval $pkg_descr
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$nohead" ]; then
|
if [ -z "$nohead" ]; then
|
||||||
echo '----------'
|
echo '----------'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval value=$field
|
eval value=$field
|
||||||
echo -e "${field//$/}: $value"
|
echo -e "${field//$/}: $value"
|
||||||
done
|
done
|
||||||
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -12,32 +12,22 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
format=${1-shell}
|
format=${1-shell}
|
||||||
|
|
||||||
# Importing variables
|
|
||||||
|
|
||||||
# Json function
|
# Json function
|
||||||
json_list_users() {
|
json_list_users() {
|
||||||
echo '{'
|
echo '{'
|
||||||
fileds_count=$(echo "$fields" | wc -w)
|
fileds_count=$(echo "$fields" | wc -w)
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for USER in $(ls $VESTA/data/users/); do
|
for USER in $(ls $VESTA/data/users/); do
|
||||||
# Reading user data
|
|
||||||
source $VESTA/data/users/$USER/user.conf
|
source $VESTA/data/users/$USER/user.conf
|
||||||
|
|
||||||
# Closing bracket if there already was output
|
|
||||||
if [ -n "$data" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e ' },'
|
echo -e ' },'
|
||||||
fi
|
fi
|
||||||
i=1
|
i=1
|
||||||
for field in $fields; do
|
for field in $fields; do
|
||||||
eval value=$field
|
eval value=$field
|
||||||
|
|
||||||
if [ $i -eq 1 ]; then
|
if [ $i -eq 1 ]; then
|
||||||
# Printing parrent
|
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\"$value\": {"
|
echo -e "\t\"$value\": {"
|
||||||
else
|
else
|
||||||
# Printing child
|
|
||||||
if [ $i -lt $fileds_count ]; then
|
if [ $i -lt $fileds_count ]; then
|
||||||
(( ++i))
|
(( ++i))
|
||||||
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
|
||||||
|
@ -48,27 +38,22 @@ json_list_users() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
# Closing bracket if there was output
|
|
||||||
if [ -n "$data" ]; then
|
if [ -n "$data" ]; then
|
||||||
echo -e ' }'
|
echo -e ' }'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Printing bottom bracket
|
|
||||||
echo -e '}'
|
echo -e '}'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Shell function
|
# Shell function
|
||||||
shell_list_users() {
|
shell_list_users() {
|
||||||
if [ -z "$nohead" ]; then
|
if [ -z "$nohead" ]; then
|
||||||
# Print brief info
|
|
||||||
echo "${fields//$/}"
|
echo "${fields//$/}"
|
||||||
for a in $fields; do
|
for a in $fields; do
|
||||||
echo -e "--------- \c"
|
echo -e "--------- \c"
|
||||||
done
|
done
|
||||||
echo # new line
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Starting main loop
|
|
||||||
for USER in $(ls $VESTA/data/users/); do
|
for USER in $(ls $VESTA/data/users/); do
|
||||||
source $VESTA/data/users/$USER/user.conf
|
source $VESTA/data/users/$USER/user.conf
|
||||||
eval echo "$fields"
|
eval echo "$fields"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
|
|
@ -13,143 +13,22 @@
|
||||||
user=$1
|
user=$1
|
||||||
backup=$2
|
backup=$2
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
|
|
||||||
# Defining ftp command function
|
|
||||||
ftpc() {
|
|
||||||
ftp -n $HOST $PORT <<EOF
|
|
||||||
quote USER $USERNAME
|
|
||||||
quote PASS $PASSWORD
|
|
||||||
binary
|
|
||||||
cd $BPATH
|
|
||||||
$1
|
|
||||||
quit
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
init_ftp_variables() {
|
|
||||||
# Checking config
|
|
||||||
source $VESTA/conf/ftp.backup.conf
|
|
||||||
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
|
|
||||||
[ -z "$BPATH" ]; then
|
|
||||||
echo "Error: Parsing error"
|
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
|
||||||
exit $E_PARSING
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_ftp_connection(){
|
|
||||||
# Checking ftp permission
|
|
||||||
ftmpdir=$(mktemp -u -p $BPATH)
|
|
||||||
command="mkdir $ftmpdir
|
|
||||||
ls $ftmpdir
|
|
||||||
rm $ftmpdir"
|
|
||||||
if [ ! -z "$(ftpc "$command")" ] ; then
|
|
||||||
echo "Error: FTP error"
|
|
||||||
log_event 'debug' "$E_FTP $EVENT"
|
|
||||||
exit $E_FTP
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Get current time
|
|
||||||
start_time=$(date '+%s')
|
|
||||||
echo "$(date "+%F %T") System restore for user $user"
|
|
||||||
echo
|
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user backup'
|
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'backup'
|
|
||||||
|
|
||||||
# Checking backup system is enabled
|
|
||||||
is_system_enabled 'BACKUP_SYSTEM'
|
|
||||||
|
|
||||||
# Checking load averages
|
|
||||||
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
|
|
||||||
i=0
|
|
||||||
while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
|
|
||||||
echo "$(date "+%F %T") Load Average $la"
|
|
||||||
echo
|
|
||||||
sleep 60
|
|
||||||
if [ "$i" -ge "15" ]; then
|
|
||||||
echo "Error: LA is too high"
|
|
||||||
log_event 'debug' "$E_LA $EVENT"
|
|
||||||
exit $E_LA
|
|
||||||
fi
|
|
||||||
(( ++i))
|
|
||||||
done
|
|
||||||
|
|
||||||
# Checking local backup existance
|
|
||||||
if [ ! -e "$BACKUP/$user.$backup.tar" ]; then
|
|
||||||
if [ ! -z "$(echo $BACKUP_SYSTEM | grep -w ftp)" ]; then
|
|
||||||
init_ftp_variables
|
|
||||||
check_ftp_connection
|
|
||||||
if [ ! -z "$(ftpc ls |awk '{print $9}' |grep $user.$backup.)" ]; then
|
|
||||||
cd $BACKUP
|
|
||||||
echo "$(date "+%F %T") Downloading ftp backup"
|
|
||||||
ftpc "get $user.$backup.tar" &>/dev/null
|
|
||||||
echo "$(date "+%F %T") Downloaded $user.$backup.tar"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -e "$BACKUP/$user.$backup.tar" ]; then
|
|
||||||
echo "Error: $BACKUP/$user.$backup.tar backup not found"
|
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking arguments
|
|
||||||
if [ -z "$3" ]; then
|
|
||||||
# Define full backup variables
|
|
||||||
VESTA='yes'
|
|
||||||
PAM='yes'
|
|
||||||
WEB='yes'
|
|
||||||
DNS='yes'
|
|
||||||
DB='yes'
|
|
||||||
MAIL='yes'
|
|
||||||
SSL='yes'
|
|
||||||
CRON='yes'
|
|
||||||
else
|
|
||||||
args=("$@")
|
|
||||||
for (( i=2; i<${#@}; i++)); do
|
|
||||||
key=$(echo ${args[$i]} | cut -f 1 -d :| tr '[:lower:]' '[:upper:]')
|
|
||||||
opt=$(echo ${args[$i]} | cut -f 2 -d :)
|
|
||||||
if [ -z "$(echo ${args[$i]} |grep :)" ]; then
|
|
||||||
eval $key='yes'
|
|
||||||
else
|
|
||||||
eval $key='opt'
|
|
||||||
eval ${key}_OPT=$opt
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Creating temporary directory
|
|
||||||
tmpdir=$(mktemp -p $BACKUP -d)
|
|
||||||
echo "TMPDIR is $tmpdir"
|
|
||||||
cd $tmpdir
|
|
||||||
echo "$(date "+%F %T") Extracting files from backup"
|
|
||||||
tar -xf $BACKUP/$user.$backup.tar
|
|
||||||
echo "$(date "+%F %T") Backup has been unpacked"
|
|
||||||
|
|
||||||
# Checking Vesta
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -15,7 +15,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
restart="$3"
|
restart="$3"
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -21,19 +21,10 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user status
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user admin
|
|
||||||
if [ "$user" = 'admin' ]; then
|
if [ "$user" = 'admin' ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -61,7 +52,7 @@ fi
|
||||||
|
|
||||||
# Suspending datbabases
|
# Suspending datbabases
|
||||||
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
||||||
$BIN/v_suspend_db_bases $user
|
$BIN/v_suspend_databases $user
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Suspending cron jobs
|
# Suspending cron jobs
|
||||||
|
@ -74,11 +65,6 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
|
||||||
$BIN/v_restart_cron "$EVENT"
|
|
||||||
$BIN/v_restart_web "$EVENT"
|
|
||||||
$BIN/v_restart_dns "$EVENT"
|
|
||||||
|
|
||||||
# Changing suspend value
|
# Changing suspend value
|
||||||
update_user_value "$user" '$SUSPENDED' 'yes'
|
update_user_value "$user" '$SUSPENDED' 'yes'
|
||||||
increase_user_value 'admin' '$SUSPENDED_USERS'
|
increase_user_value 'admin' '$SUSPENDED_USERS'
|
||||||
|
|
|
@ -40,7 +40,6 @@ for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
|
||||||
$BIN/v_suspend_web_domain "$user" "$domain" "$url" 'no'
|
$BIN/v_suspend_web_domain "$user" "$domain" "$url" 'no'
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
|
|
|
@ -49,13 +49,13 @@ field='$DOMAIN'
|
||||||
search_string="SUSPENDED='yes'"
|
search_string="SUSPENDED='yes'"
|
||||||
|
|
||||||
# Parsing suspeneded domains
|
# Parsing suspeneded domains
|
||||||
domains=$(dom_clear_search)
|
#domains=$(dom_clear_search)
|
||||||
|
|
||||||
|
|
||||||
# Starting unsuspend loop
|
# Starting unsuspend loop
|
||||||
for domain in $domains; do
|
#for domain in $domains; do
|
||||||
$BIN/v_unsuspend_mail_domain "$user" "$domain"
|
# $BIN/v_unsuspend_mail_domain "$user" "$domain"
|
||||||
done
|
#done
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -21,16 +21,9 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user admin
|
|
||||||
if [ "$user" = 'admin' ]; then
|
if [ "$user" = 'admin' ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
@ -58,7 +51,7 @@ fi
|
||||||
|
|
||||||
# Unsuspending datbabases
|
# Unsuspending datbabases
|
||||||
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
|
||||||
$BIN/v_unsuspend_db_bases $user
|
$BIN/v_unsuspend_databases $user
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unsuspending cron jobs
|
# Unsuspending cron jobs
|
||||||
|
@ -71,11 +64,6 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
|
||||||
$BIN/v_restart_cron "$EVENT"
|
|
||||||
$BIN/v_restart_web "$EVENT"
|
|
||||||
$BIN/v_restart_dns "$EVENT"
|
|
||||||
|
|
||||||
# Changing suspend value
|
# Changing suspend value
|
||||||
update_user_value "$user" '$SUSPENDED' 'no'
|
update_user_value "$user" '$SUSPENDED' 'no'
|
||||||
decrease_user_value 'admin' '$SUSPENDED_USERS'
|
decrease_user_value 'admin' '$SUSPENDED_USERS'
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ if [ "$version" != "$VERSION" ]; then
|
||||||
# Checking download result
|
# Checking download result
|
||||||
if [ "$?" -ne "0" ]; then
|
if [ "$?" -ne "0" ]; then
|
||||||
echo "Error: version tree update failed"
|
echo "Error: version tree update failed"
|
||||||
log_event 'debug' "$E_UPDATE $EVENT"
|
log_event "$E_UPDATE" "$EVENT"
|
||||||
exit $E_UPDATE
|
exit $E_UPDATE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ if [ "$version" != "$VERSION" ]; then
|
||||||
# Checking download result
|
# Checking download result
|
||||||
if [ "$?" -ne "0" ]; then
|
if [ "$?" -ne "0" ]; then
|
||||||
echo "Error: version tree update failed"
|
echo "Error: version tree update failed"
|
||||||
log_event 'debug' "$E_UPDATE $EVENT"
|
log_event "$E_UPDATE" "$EVENT"
|
||||||
exit $E_UPDATE
|
exit $E_UPDATE
|
||||||
fi
|
fi
|
||||||
bash $BIN/updates/$update.sh
|
bash $BIN/updates/$update.sh
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -19,8 +19,8 @@ type="${2-$BACKUP_SYSTEM}"
|
||||||
|
|
||||||
# Defining tar parser function
|
# Defining tar parser function
|
||||||
get_backup_info() {
|
get_backup_info() {
|
||||||
backup=$1 # full path to backup
|
backup=$1
|
||||||
backup_type="$2" # backup type
|
backup_type="$2"
|
||||||
|
|
||||||
backup_name=$(basename $backup )
|
backup_name=$(basename $backup )
|
||||||
backup_date=$(echo $backup_name |cut -f 2 -d '.' )
|
backup_date=$(echo $backup_name |cut -f 2 -d '.' )
|
||||||
|
@ -28,7 +28,6 @@ get_backup_info() {
|
||||||
backup_size=$(du -sm $backup |cut -f 1 )
|
backup_size=$(du -sm $backup |cut -f 1 )
|
||||||
backup_data=$(tar -tf $backup)
|
backup_data=$(tar -tf $backup)
|
||||||
|
|
||||||
# Checking system data
|
|
||||||
vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$")
|
vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$")
|
||||||
if [ -z "$vst_data" ]; then
|
if [ -z "$vst_data" ]; then
|
||||||
vst=''
|
vst=''
|
||||||
|
@ -36,7 +35,6 @@ get_backup_info() {
|
||||||
vst='yes'
|
vst='yes'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking pam
|
|
||||||
pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$")
|
pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$")
|
||||||
if [ -z "$pam_data" ]; then
|
if [ -z "$pam_data" ]; then
|
||||||
pam=''
|
pam=''
|
||||||
|
@ -44,7 +42,6 @@ get_backup_info() {
|
||||||
pam='yes'
|
pam='yes'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking web data
|
|
||||||
web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort)
|
web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort)
|
||||||
if [ -z "$web_data" ]; then
|
if [ -z "$web_data" ]; then
|
||||||
web=''
|
web=''
|
||||||
|
@ -61,7 +58,6 @@ get_backup_info() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking dns data
|
|
||||||
dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort)
|
dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort)
|
||||||
if [ -z "$dns_data" ]; then
|
if [ -z "$dns_data" ]; then
|
||||||
dns=''
|
dns=''
|
||||||
|
@ -78,7 +74,6 @@ get_backup_info() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking mail
|
|
||||||
mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort)
|
mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort)
|
||||||
if [ -z "$mail_data" ]; then
|
if [ -z "$mail_data" ]; then
|
||||||
ml=''
|
ml=''
|
||||||
|
@ -95,7 +90,6 @@ get_backup_info() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking databases
|
|
||||||
db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort)
|
db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort)
|
||||||
if [ -z "$db_data" ]; then
|
if [ -z "$db_data" ]; then
|
||||||
db=''
|
db=''
|
||||||
|
@ -112,7 +106,6 @@ get_backup_info() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking certificates
|
|
||||||
ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort)
|
ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort)
|
||||||
if [ -z "$ssl_data" ]; then
|
if [ -z "$ssl_data" ]; then
|
||||||
ssl=''
|
ssl=''
|
||||||
|
@ -129,8 +122,6 @@ get_backup_info() {
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Checking cron data
|
|
||||||
cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$")
|
cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$")
|
||||||
if [ -z "$cron_data" ]; then
|
if [ -z "$cron_data" ]; then
|
||||||
cron=''
|
cron=''
|
||||||
|
@ -156,25 +147,23 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
init_ftp_variables() {
|
init_ftp_variables() {
|
||||||
# Checking config
|
|
||||||
source $VESTA/conf/ftp.backup.conf
|
source $VESTA/conf/ftp.backup.conf
|
||||||
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
|
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
|
||||||
[ -z "$BPATH" ]; then
|
[ -z "$BPATH" ]; then
|
||||||
echo "Error: Parsing error"
|
echo "Error: Parsing error"
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
exit $E_PARSING
|
exit $E_PARSING
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_ftp_connection(){
|
check_ftp_connection(){
|
||||||
# Checking ftp permission
|
|
||||||
ftmpdir=$(mktemp -u -p $BPATH)
|
ftmpdir=$(mktemp -u -p $BPATH)
|
||||||
command="mkdir $ftmpdir
|
command="mkdir $ftmpdir
|
||||||
ls $ftmpdir
|
ls $ftmpdir
|
||||||
rm $ftmpdir"
|
rm $ftmpdir"
|
||||||
if [ ! -z "$(ftpc "$command")" ] ; then
|
if [ ! -z "$(ftpc "$command")" ] ; then
|
||||||
echo "Error: FTP error"
|
echo "Error: FTP error"
|
||||||
log_event 'debug' "$E_FTP $EVENT"
|
log_event "$E_FTP" "$EVENT"
|
||||||
exit $E_FTP
|
exit $E_FTP
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -185,22 +174,13 @@ check_ftp_connection(){
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
is_system_enabled "$BACKUP_SYSTEM"
|
||||||
# Checking backup system is enabled
|
|
||||||
is_system_enabled 'BACKUP_SYSTEM'
|
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking load averages
|
|
||||||
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
|
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
|
||||||
if [ "$la" -ge "$BACKUP_LA_LIMIT" ]; then
|
if [ "$la" -ge "$BACKUP_LA_LIMIT" ]; then
|
||||||
log_event 'debug' "$E_LA $EVENT"
|
log_event "$E_LA" "$EVENT"
|
||||||
exit $E_LA
|
exit $E_LA
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -235,7 +215,7 @@ if [ "$type" = 'ftp' ]; then
|
||||||
cd $tmpdir
|
cd $tmpdir
|
||||||
if [ ! -z "$(ftpc "get $backup")" ]; then
|
if [ ! -z "$(ftpc "get $backup")" ]; then
|
||||||
echo "Error: FTP transfer error"
|
echo "Error: FTP transfer error"
|
||||||
log_event 'debug' "$E_FTP $EVENT"
|
log_event "$E_FTP" "$EVENT"
|
||||||
exit $E_FTP
|
exit $E_FTP
|
||||||
fi
|
fi
|
||||||
get_backup_info $tmpdir/$backup $type >> $tmp_file
|
get_backup_info $tmpdir/$backup $type >> $tmp_file
|
||||||
|
@ -262,7 +242,7 @@ if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then
|
||||||
cd $tmpdir
|
cd $tmpdir
|
||||||
if [ ! -z "$(ftpc "get $backup")" ]; then
|
if [ ! -z "$(ftpc "get $backup")" ]; then
|
||||||
echo "Error: FTP transfer error"
|
echo "Error: FTP transfer error"
|
||||||
log_event 'debug' "$E_FTP $EVENT"
|
log_event "$E_FTP" "$EVENT"
|
||||||
exit $E_FTP
|
exit $E_FTP
|
||||||
fi
|
fi
|
||||||
get_backup_info $tmpdir/$backup ftp >> $tmp_file
|
get_backup_info $tmpdir/$backup ftp >> $tmp_file
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -21,15 +21,9 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '0' "$#" 'user'
|
check_args '0' "$#" 'user'
|
||||||
|
|
||||||
# If user specified
|
|
||||||
if [ ! -z "$user" ]; then
|
if [ ! -z "$user" ]; then
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -40,13 +34,14 @@ fi
|
||||||
|
|
||||||
# Creating user_list
|
# Creating user_list
|
||||||
if [ -z "$user" ]; then
|
if [ -z "$user" ]; then
|
||||||
user_list=$(ls $V_USERS/)
|
user_list=$(ls $VESTA/data/users)
|
||||||
else
|
else
|
||||||
user_list="$user"
|
user_list="$user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Updating user stats
|
# Updating user stats
|
||||||
for user in $user_list; do
|
for user in $user_list; do
|
||||||
|
USER_DATA=$VESTA/data/users/$user
|
||||||
# Cleaning counters
|
# Cleaning counters
|
||||||
SUSPENDED_USERS=0
|
SUSPENDED_USERS=0
|
||||||
SUSPENDED_WEB=0
|
SUSPENDED_WEB=0
|
||||||
|
@ -84,8 +79,9 @@ for user in $user_list; do
|
||||||
|
|
||||||
# Checking users
|
# Checking users
|
||||||
if [ "$user" = 'admin' ]; then
|
if [ "$user" = 'admin' ]; then
|
||||||
SUSPENDED_USERS=$(grep "SUSPENDED='yes'" $V_USERS/*/user.conf|wc -l)
|
SUSPENDED_USERS=$(grep "SUSPENDED='yes'" $VESTA/data/users/*/user.conf)
|
||||||
U_USERS=$(ls $V_USERS/|wc -l)
|
SUSPENDED_USERS=$(echo "$SUSPENDED_USERS" |wc -l)
|
||||||
|
U_USERS=$(ls $VESTA/data/users/|wc -l)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ip
|
# Checking ip
|
||||||
|
@ -128,7 +124,7 @@ for user in $user_list; do
|
||||||
for domain_str in $(cat $USER_DATA/dns.conf); do
|
for domain_str in $(cat $USER_DATA/dns.conf); do
|
||||||
eval $domain_str
|
eval $domain_str
|
||||||
U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1))
|
U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1))
|
||||||
records=$(wc -l $USER_DATA/dns/$DOMAIN| cut -f 1 -d ' ')
|
records=$(wc -l $USER_DATA/dns/$DOMAIN.conf| cut -f 1 -d ' ')
|
||||||
U_DNS_RECORDS=$((U_DNS_RECORDS + records))
|
U_DNS_RECORDS=$((U_DNS_RECORDS + records))
|
||||||
if [ "$SUSPENDED" = 'yes' ]; then
|
if [ "$SUSPENDED" = 'yes' ]; then
|
||||||
SUSPENDED_DNS=$((SUSPENDED_DNS + 1))
|
SUSPENDED_DNS=$((SUSPENDED_DNS + 1))
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
|
|
||||||
|
@ -21,13 +21,8 @@ source $VESTA/func/shared.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ user=$1
|
||||||
# mostly by cron wich not read it by itself
|
# mostly by cron wich not read it by itself
|
||||||
source /etc/profile.d/vesta.sh
|
source /etc/profile.d/vesta.sh
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -26,15 +26,9 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '0' "$#" 'user'
|
check_args '0' "$#" 'user'
|
||||||
|
|
||||||
# If user specified
|
|
||||||
if [ ! -z "$user" ]; then
|
if [ ! -z "$user" ]; then
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -45,20 +39,19 @@ fi
|
||||||
|
|
||||||
# Creating user_list
|
# Creating user_list
|
||||||
if [ -z "$user" ]; then
|
if [ -z "$user" ]; then
|
||||||
user_list=$(ls $V_USERS/)
|
user_list=$(ls $VESTA/data/users)
|
||||||
else
|
else
|
||||||
user_list="$user"
|
user_list="$user"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Updating user stats
|
# Updating user stats
|
||||||
for user in $user_list; do
|
for user in $user_list; do
|
||||||
|
USER_DATA=$VESTA/data/users/$user
|
||||||
# Importing user values
|
|
||||||
source $USER_DATA/user.conf
|
source $USER_DATA/user.conf
|
||||||
DATE=$(date -d "$(date +'%m/01') -1day" +%F)
|
DATE=$(date -d "$(date +'%m/01') -1day" +%F)
|
||||||
|
|
||||||
# Compiling report string
|
# Compiling report string
|
||||||
s="DATE='$DATE' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'"
|
s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'"
|
||||||
s="$s U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS' U_DISK_WEB='$U_DISK_WEB'"
|
s="$s U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS' U_DISK_WEB='$U_DISK_WEB'"
|
||||||
s="$s U_DISK_MAIL='$U_DISK_MAIL' U_DISK_DB='$U_DISK_DB'"
|
s="$s U_DISK_MAIL='$U_DISK_MAIL' U_DISK_DB='$U_DISK_DB'"
|
||||||
s="$s U_DISK_DATABASES='$U_DISK_DATABASES'"
|
s="$s U_DISK_DATABASES='$U_DISK_DATABASES'"
|
||||||
|
|
86
func/db.sh
86
func/db.sh
|
@ -218,7 +218,7 @@ change_mysql_password() {
|
||||||
|
|
||||||
# Change PostgreSQL database password
|
# Change PostgreSQL database password
|
||||||
change_pgsql_password() {
|
change_pgsql_password() {
|
||||||
host_str=$(grep "HOST='$host'" $VESTA/conf/pgsql.conf)
|
host_str=$(grep "HOST='$HOST'" $VESTA/conf/pgsql.conf)
|
||||||
eval $host_str
|
eval $host_str
|
||||||
export PGPASSWORD="$PASSWORD"
|
export PGPASSWORD="$PASSWORD"
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
||||||
|
@ -308,74 +308,62 @@ delete_pgsql_database() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Dump MySQL database
|
||||||
dump_db_mysql() {
|
dump_mysql_database() {
|
||||||
# Defining vars
|
host_str=$(grep "HOST='$HOST'" $VESTA/conf/mysql.conf)
|
||||||
host_str=$(grep "HOST='$host'" $VESTA/conf/mysql.conf)
|
eval $host_str
|
||||||
for key in $host_str; do
|
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e"
|
|
||||||
dumper="mysqldump -h $HOST -u $USER -p$PASSWORD -P$PORT -r"
|
|
||||||
|
|
||||||
# Checking empty vars
|
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ]; then
|
||||||
echo "Error: config is broken"
|
echo "Error: mysql config parsing failed"
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
exit $E_PARSING
|
exit $E_PARSING
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking connection
|
query='SELECT VERSION()'
|
||||||
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
|
mysql -h $HOST -u $USER -p$PASSWORD -P $PORT -e "$query" &> /dev/null
|
||||||
if [ '0' -ne "$code" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
echo "Error: Connect failed"
|
echo "Error: Connection failed"
|
||||||
log_event 'debug' "$E_DB $EVENT"
|
log_event "$E_DB $EVENT"
|
||||||
exit $E_DB
|
exit $E_DB
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dumping database
|
mysqldump -h $HOST -u $USER -p$PASSWORD -P$PORT -r $dump $database
|
||||||
$dumper $dump $database
|
|
||||||
|
|
||||||
# Dumping user grants
|
query="SHOW GRANTS FOR '$DBUSER'@'localhost'"
|
||||||
$sql "SHOW GRANTS FOR $db_user@localhost" | grep -v "Grants for" > $grants
|
mysql -h $HOST -u $USER -p$PASSWORD -P $PORT -e "$query" |\
|
||||||
$sql "SHOW GRANTS FOR $db_user@'%'" | grep -v "Grants for" >> $grants
|
grep -v "Grants for" > $grants
|
||||||
|
|
||||||
|
query="SHOW GRANTS FOR '$DBUSER'@'%'"
|
||||||
|
mysql -h $HOST -u $USER -p$PASSWORD -P $PORT -e "$query" |\
|
||||||
|
grep -v "Grants for" > $grants
|
||||||
}
|
}
|
||||||
|
|
||||||
dump_db_pgsql() {
|
# Dump PostgreSQL database
|
||||||
# Defining vars
|
dump_pgsql_database() {
|
||||||
host_str=$(grep "HOST='$host'" $VESTA/conf/pgsql.conf)
|
host_str=$(grep "HOST='$HOST'" $VESTA/conf/pgsql.conf)
|
||||||
for key in $host_str; do
|
eval $host_str
|
||||||
eval ${key%%=*}=${key#*=}
|
|
||||||
done
|
|
||||||
|
|
||||||
export PGPASSWORD="$PASSWORD"
|
export PGPASSWORD="$PASSWORD"
|
||||||
sql="psql -h $HOST -U $USER -p $PORT -c"
|
|
||||||
dumper="pg_dump -h $HOST -U $USER -p $PORT -c -d -O -x -i -f"
|
|
||||||
# Checking empty vars
|
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
||||||
echo "Error: config is broken"
|
echo "Error: postgresql config parsing failed"
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
exit $E_PARSING
|
exit $E_PARSING
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking connection
|
query='SELECT VERSION()'
|
||||||
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
|
psql -h $HOST -U $USER -p $PORT -c "$query" &> /dev/null
|
||||||
if [ '0' -ne "$code" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
echo "Error: Connect failed"
|
echo "Error: Connection failed"
|
||||||
log_event 'debug' "$E_DB $EVENT"
|
log_event "$E_DB" "$EVENT"
|
||||||
exit $E_DB
|
exit $E_DB
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dumping database
|
pg_dump -h $HOST -U $USER -p $PORT -c -d -O -x -i -f $dump $database \
|
||||||
$dumper $dump $database
|
2> /dev/null
|
||||||
|
|
||||||
# Dumping user grants
|
query="SELECT rolpassword FROM pg_authid WHERE rolname='$DBUSER';"
|
||||||
md5=$($sql "SELECT rolpassword FROM pg_authid WHERE rolname='$db_user';")
|
md5=$(psql -h $HOST -U $USER -p $PORT -c "$query"|head -n1|cut -f 2 -d \ )
|
||||||
md5=$(echo "$md5" | head -n 1 | cut -f 2 -d ' ')
|
pw_str="UPDATE pg_authid SET rolpassword='$md5' WHERE rolname='$DBUSER';"
|
||||||
pw_str="UPDATE pg_authid SET rolpassword='$md5' WHERE rolname='$db_user';"
|
gr_str="GRANT ALL PRIVILEGES ON DATABASE $database to '$DBUSER'"
|
||||||
gr_str="GRANT ALL PRIVILEGES ON DATABASE $database to '$db_user'"
|
|
||||||
echo -e "$pw_str\n$gr_str" >> $grants
|
echo -e "$pw_str\n$gr_str" >> $grants
|
||||||
export PGPASSWORD='pgsql'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if database server is in use
|
# Check if database server is in use
|
||||||
|
|
|
@ -119,9 +119,9 @@ is_type_valid() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Checkk user backup settings
|
# Check user backup settings
|
||||||
is_backup_enabled() {
|
is_backup_enabled() {
|
||||||
BACKUPS=$(grep "BACKUPS='" $USER_DATA/user.conf | cut -f 2 -d \')
|
BACKUPS=$(grep "^BACKUPS=" $USER_DATA/user.conf | cut -f2 -d \')
|
||||||
if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then
|
if [ -z "$BACKUPS" ] || [[ "$BACKUPS" -le '0' ]]; then
|
||||||
echo "Error: user backup disabled"
|
echo "Error: user backup disabled"
|
||||||
log_event "$E_DISABLED" "$EVENT"
|
log_event "$E_DISABLED" "$EVENT"
|
||||||
|
@ -422,7 +422,7 @@ validate_format_url() {
|
||||||
|
|
||||||
# Shell
|
# Shell
|
||||||
validate_format_shell() {
|
validate_format_shell() {
|
||||||
if [ -z "$(grep -x $1 /etc/shells)" ]; then
|
if [ -z "$(grep -w $1 /etc/shells)" ]; then
|
||||||
echo "Error: shell $1 is not valid"
|
echo "Error: shell $1 is not valid"
|
||||||
log_event "$E_INVALID" "$EVENT"
|
log_event "$E_INVALID" "$EVENT"
|
||||||
exit $E_INVALID
|
exit $E_INVALID
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue