refactoring: log_event(), is_format_valid()

This commit is contained in:
Serghey Rodin 2016-06-24 16:31:43 +03:00
parent 325ca65f32
commit a61a6e979e
52 changed files with 582 additions and 1170 deletions

View file

@ -17,7 +17,7 @@ hour=$3
day=$4
month=$5
wday=$6
command=$(echo $7 | sed "s/'/%quote%/g")
command=$(echo $7 |sed "s/'/%quote%/g")
job=$8
restart=$9
@ -25,8 +25,7 @@ restart=$9
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
# Assigning new value
A7="$command"
HIDE=7
#----------------------------------------------------------#

View file

@ -40,8 +40,8 @@ time=$(echo "$time_n_date" |cut -f 1 -d \ )
date=$(echo "$time_n_date" |cut -f 2 -d \ )
# Define time somewhere at night
min=$(gen_password '012345' '2')
hour=$(gen_password '1234567' '1')
min=$(generate_password '012345' '2')
hour=$(generate_password '1234567' '1')
day='*'
month='*'
wday='*'

View file

@ -17,8 +17,13 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
if [[ "$domain" =~ [[:upper:]] ]]; then
domain=$(echo "$domain" |tr '[:upper:]' '[:lower:]')
fi
domain_idn="$domain"
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $domain)
fi
ip=$3
ns1=$4
ns2=$5
@ -48,7 +53,7 @@ is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'dns'
is_package_full 'DNS_DOMAINS'
template=$(get_user_value '$DNS_TEMPLATE')
is_dns_template_valid
is_dns_template_valid $template
if [ ! -z "$ns1" ]; then
ns1=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')

View file

@ -14,9 +14,7 @@
# Argument definition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
domain=$2
record=$(idn -t --quiet -u "$3" )
record=$(echo "$record" | tr '[:upper:]' '[:lower:]')
rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')

View file

@ -39,11 +39,9 @@ is_object_unsuspended 'user' 'USER' "$user"
# Get ip if it wasn't defined
if [ -z "$ip" ]; then
ip=$(get_user_ip $user)
get_user_ip $user
if [ -z "$ip" ]; then
echo "Error: no avaiable IP address"
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
check_result $E_NOTEXIST "no avaiable IP address"
fi
fi

View file

@ -38,7 +38,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_package_full 'MAIL_USER'
is_package_full 'MAIL_ACCOUNTS'
is_mail_new "$account"
is_password_valid
@ -48,7 +48,7 @@ is_password_valid
#----------------------------------------------------------#
# Generating hashed password
salt=$(gen_password "$PW_MATRIX" "8")
salt=$(generate_password "$PW_MATRIX" "8")
md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"
# Adding account info into password file

View file

@ -13,8 +13,13 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
if [[ "$domain" =~ [[:upper:]] ]]; then
domain=$(echo "$domain" |tr '[:upper:]' '[:lower:]')
fi
domain_idn="$domain"
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $domain)
fi
antispam=${3-yes}
antivirus=${4-yes}
dkim=${5-yes}

View file

@ -58,12 +58,11 @@ fi
if [ "$restart" = 'yes' ]; then
subj="OpenSSH restart failed"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
send_mail="$VESTA/web/inc/mail-wrapper.php"
/usr/sbin/sshd -t >/dev/null 2>&1
if [ "$?" -ne 0 ]; then
mail_text="OpenSSH can not be restarted. Please check config:
\n\n$(/usr/sbin/sshd -t)"
echo -e "$mail_text" | $send_mail -s "$subj" $email
echo -e "$mail_text" |$SENDMAIL -s "$subj" $email
else
service ssh restart >/dev/null 2>&1
service sshd restart >/dev/null 2>&1

View file

@ -24,9 +24,7 @@ source $VESTA/conf/vesta.conf
is_user_free() {
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
echo "Error: user $user exists"
log_event "$E_EXISTS" "$ARGUMENTS"
exit $E_EXISTS
check_result $E_EXISTS "user $user exists"
fi
}
@ -155,7 +153,7 @@ $pkg_data
CONTACT='$email'
CRON_REPORTS='yes'
MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)'
RKEY='$(gen_password)'
RKEY='$(generate_password)'
SUSPENDED='no'
SUSPENDED_USERS='0'
SUSPENDED_WEB='0'

View file

@ -61,7 +61,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_package_full 'WEB_DOMAINS' 'WEB_ALIASES'
is_domain_new 'web' "$domain,$aliases"
is_ip_valid "$ip"
is_ip_valid "$ip" "$user"
#----------------------------------------------------------#
@ -133,8 +133,8 @@ fi
# Increasing counters
increase_ip_value "$local_ip"
increase_user_value "$user" '$U_WEB_DOMAINS' "$alias_number"
increase_user_value "$user" '$U_WEB_ALIASES'
increase_user_value "$user" '$U_WEB_DOMAINS'
increase_user_value "$user" '$U_WEB_ALIASES' "$alias_number"
# Generating timestamp
time_n_date=$(date +'%T %F')

View file

@ -55,11 +55,11 @@ local_ip=$(get_real_ip $IP)
# Preparing domain values for the template substitution
PROXY_EXT="$extentions"
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
add_web_config "$PROXY_SYSTEM" "$template.tpl"
# Adding proxy for ssl
if [ "$SSL" = 'yes' ]; then
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
add_web_config "$PROXY_SYSTEM" "$template.stpl"
fi
@ -68,7 +68,7 @@ fi
#----------------------------------------------------------#
# Update config
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$template"
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
# Restarting web server

View file

@ -41,7 +41,7 @@ is_backup_enabled
# Set backup directory if undefined
if [ -z "$BACKUP" ]; then
BACKUP=/home/backup
BACKUP=/backup
fi
mkdir -p $BACKUP
@ -49,28 +49,20 @@ mkdir -p $BACKUP
start_time=$(date '+%s')
# Set notification email and subject
if [ "$notify" != 'no' ]; then
subj="$user → backup failed"
email=$(get_user_value '$CONTACT')
else
subj="$user → backup failed"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
fi
subj="$user → backup failed"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
# Check load average
# Checking load average
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") LoadAverage $la is above threshold. Sleeping..."
sleep 120
if [ "$i" -ge "5" ]; then
mail_top=$(top -b| head -n 30)
mail_text="LoadAverage $i is above threshold\n\n$mail_top\n"
echo -e "$mail_text" |$send_mail -s "$subj" $email
echo "Error: LA is too high"
echo -e "$(date "+%F %T") Load Average $la"
sleep 60
if [ "$i" -ge "15" ]; then
la_error="LoadAverage $la is above threshold"
echo "$la_error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_LA" "$ARGUMENTS"
exit $E_LA
check_result $E_LA "$la_error"
fi
la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
(( ++i))
@ -79,48 +71,40 @@ done
# Creating temporary directory
tmpdir=$(mktemp -p $BACKUP -d)
if [ "$?" -ne 0 ]; then
echo "Can't create tmp dir $tmpdir" |$send_mail -s "$subj" $email
echo "Error: can't create tmp dir"
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
echo "Can't create tmp dir $tmpdir" |$SENDMAIL -s "$subj" $email $notify
check_result $E_NOTEXIST "can't create tmp dir"
fi
# Backup sys configs
echo -e "-- SYSTEM --"
msg="-- SYSTEM --"
echo "-- SYSTEM --" |tee $BACKUP/$user.log
mkdir $tmpdir/vesta
echo -e "$(date "+%F %T") $user.conf"
msg="$msg\n$(date "+%F %T") $user.conf"
echo -e "$(date "+%F %T") $user.conf" |tee -a $BACKUP/$user.log
cp -r $USER_DATA/user.conf $tmpdir/vesta/
cp -r $USER_DATA/ssl $tmpdir/vesta/
if [ -e "$USER_DATA/stats.log" ]; then
echo -e "$(date "+%F %T") stats.log"
msg="$msg\n$(date "+%F %T") stats.log"
echo -e "$(date "+%F %T") stats.log" |tee -a $BACKUP/$user.log
cp -r $USER_DATA/stats.log $tmpdir/vesta/
fi
if [ -e "$USER_DATA/history.log" ]; then
echo -e "$(date "+%F %T") history.log"
msg="$msg\n$(date "+%F %T") history.log"
echo -e "$(date "+%F %T") history.log" |tee -a $BACKUP/$user.log
cp -r $USER_DATA/history.log $tmpdir/vesta/
fi
if [ -e "$USER_DATA/backup-excludes.conf" ]; then
echo -e "$(date "+%F %T") backup-excludes.conf"
msg="$msg\n$(date "+%F %T") backup-excludes.conf"
echo -e "$(date "+%F %T") backup-excludes.conf" |tee -a $BACKUP/$user.log
cp -r $USER_DATA/backup-excludes.conf $tmpdir/vesta/
fi
# Backup PAM
mkdir $tmpdir/pam
echo -e "$(date "+%F %T") pam"
msg="$msg\n$(date "+%F %T") pam"
echo -e "$(date "+%F %T") pam" |tee -a $BACKUP/$user.log
grep "^$user:" /etc/passwd > $tmpdir/pam/passwd
grep "^$user:" /etc/shadow > $tmpdir/pam/shadow
grep "^$user:" /etc/group > $tmpdir/pam/group
echo
msg="$msg\n"
# Parsing excludes
if [ -e "$USER_DATA/backup-excludes.conf" ]; then
@ -129,8 +113,7 @@ fi
# WEB domains
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
echo "-- WEB --"
msg="$msg\n-- WEB --"
echo -e "\n-- WEB --" |tee -a $BACKUP/$user.log
mkdir $tmpdir/web/
# Parsing domain exclusions
@ -140,8 +123,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
if [ -z "$exclusion" ]; then
web_list="$web_list $domain"
else
echo "$(date "+%F %T") excluding $domain"
msg="$msg\n$(date "+%F %T") excluding $domain"
echo "$(date "+%F %T") excluding $domain"|tee -a $BACKUP/$user.log
fi
done
web_list=$(echo "$web_list" |sed -e "s/ */\ /g" -e "s/^ //")
@ -150,8 +132,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
for domain in $web_list; do
((i ++))
echo -e "$(date "+%F %T") $domain"
msg="$msg\n$(date "+%F %T") $domain"
echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
mkdir -p $tmpdir/web/$domain/conf
mkdir -p $tmpdir/web/$domain/vesta
@ -230,20 +211,15 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
# Print total
if [ "$i" -eq 1 ]; then
echo -e "$(date "+%F %T") *** $i domain ***"
msg="$msg\n$(date "+%F %T") *** $i domain ***"
echo -e "$(date "+%F %T") *** $i domain ***" |tee -a $BACKUP/$user.log
else
echo -e "$(date "+%F %T") *** $i domains ***"
msg="$msg\n$(date "+%F %T") *** $i domains ***"
echo -e "$(date "+%F %T") *** $i domains ***"|tee -a $BACKUP/$user.log
fi
echo
msg="$msg\n"
fi
# DNS domains
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then
echo "-- DNS --"
msg="$msg\n-- DNS --"
echo -e "\n-- DNS --" |tee -a $BACKUP/$user.log
mkdir $tmpdir/dns/
# Parsing domain exclusions
@ -261,8 +237,7 @@ if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then
i=0
for domain in $dns_list; do
((i ++))
echo -e "$(date "+%F %T") $domain"
msg="$msg\n$(date "+%F %T") $domain"
echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
# Building directory tree
mkdir -p $tmpdir/dns/$domain/conf
@ -282,20 +257,15 @@ if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then
# Print total
if [ "$i" -eq 1 ]; then
echo -e "$(date "+%F %T") *** $i domain ***"
msg="$msg\n$(date "+%F %T") *** $i domain ***"
echo -e "$(date "+%F %T") *** $i domain ***" |tee -a $BACKUP/$user.log
else
echo -e "$(date "+%F %T") *** $i domains ***"
msg="$msg\n$(date "+%F %T") *** $i domains ***"
echo -e "$(date "+%F %T") *** $i domains ***"|tee -a $BACKUP/$user.log
fi
echo
msg="$msg\n"
fi
# Mail domains
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
echo "-- MAIL --"
msg="$msg\n-- MAIL --"
echo -e "\n-- MAIL --" |tee -a $BACKUP/$user.log
mkdir $tmpdir/mail/
# Parsing domain exclusions
@ -305,8 +275,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
if [ -z "$check_exl" ]; then
mail_list="$mail_list $domain"
else
echo "$(date "+%F %T") excluding $domain"
msg="$msg\n$(date "+%F %T") excluding $domain"
echo "$(date "+%F %T") excluding $domain"|tee -a $BACKUP/$user.log
fi
done
mail_list=$(echo "$mail_list" |sed -e "s/ */\ /g" -e "s/^ //")
@ -314,8 +283,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
i=0
for domain in $mail_list; do
((i ++))
echo -e "$(date "+%F %T") $domain"
msg="$msg\n$(date "+%F %T") $domain"
echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
mkdir -p $tmpdir/mail/$domain/conf
mkdir -p $tmpdir/mail/$domain/vesta
domain_idn=$(idn -t --quiet -a "$domain")
@ -342,13 +310,13 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
# Checking exlusions
if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
echo "$(date "+%F %T") + $account@$domain"
msg="$msg\n$(date "+%F %T") + $account@$domain"
echo "$(date "+%F %T") + $account@$domain" |\
tee -a $BACKUP/$user.log
touch $tmpdir/mail/$domain/accounts.tar
tar -rpf $tmpdir/mail/$domain/accounts.tar $account
else
echo "$(date "+%F %T") excluding account $account"
msg="$msg\n$(date "+%F %T") excluding account $account"
echo "$(date "+%F %T") excluding mail account $account" |\
tee -a $BACKUP/$user.log
fi
done
@ -360,21 +328,16 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
# Print total
if [ "$i" -eq 1 ]; then
echo -e "$(date "+%F %T") *** $i domain ***"
msg="$msg\n$(date "+%F %T") *** $i domain ***"
echo -e "$(date "+%F %T") *** $i domain ***" |tee -a $BACKUP/$user.log
else
echo -e "$(date "+%F %T") *** $i domains ***"
msg="$msg\n$(date "+%F %T") *** $i domains ***"
echo -e "$(date "+%F %T") *** $i domains ***"|tee -a $BACKUP/$user.log
fi
echo
msg="$msg\n"
fi
# Databases
if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
echo "-- DB --"
msg="$msg\n-- DB --"
echo -e "\n-- DB --" |tee -a $BACKUP/$user.log
mkdir $tmpdir/db/
# Parsing database exclusions
@ -383,8 +346,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
if [ -z "$exclusion" ]; then
db_list="$db_list $database"
else
echo "$(date "+%F %T") excluding $database"
msg="$msg\n$(date "+%F %T") excluding $database"
echo "$(date "+%F %T") excluding $database" |\
tee -a $BACKUP/$user.log
fi
done
@ -395,9 +358,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
((i ++))
get_database_values
echo -e "$(date "+%F %T") $database ($TYPE)"
msg="$msg\n$(date "+%F %T") $database ($TYPE)"
echo -e "$(date "+%F %T") $database ($TYPE)" |tee -a $BACKUP/$user.log
mkdir -p $tmpdir/db/$database/conf
mkdir -p $tmpdir/db/$database/vesta
@ -417,20 +378,17 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
# Print total
if [ "$i" -eq 1 ]; then
echo -e "$(date "+%F %T") *** $i database ***"
msg="$msg\n$(date "+%F %T") *** $i database ***"
echo -e "$(date "+%F %T") *** $i database ***" |\
tee -a $BACKUP/$user.log
else
echo -e "$(date "+%F %T") *** $i databases ***"
msg="$msg\n$(date "+%F %T") *** $i databases ***"
echo -e "$(date "+%F %T") *** $i databases ***"|\
tee -a $BACKUP/$user.log
fi
echo
msg="$msg\n"
fi
# Cron jobs
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON" != '*' ]; then
echo "-- CRON --"
msg="$msg\n-- CRON --"
echo -e "\n-- CRON --" |tee -a $BACKUP/$user.log
mkdir $tmpdir/cron/
# Backup cron.conf
@ -444,20 +402,17 @@ if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON" != '*' ]; then
# Print total
if [ "$cron_record" -eq 1 ]; then
echo -e "$(date "+%F %T") *** $cron_record job ***"
msg="$msg\n$(date "+%F %T") *** $cron_record job ***"
echo -e "$(date "+%F %T") *** $cron_record job ***" |\
tee -a $BACKUP/$user.log
else
echo -e "$(date "+%F %T") *** $cron_record jobs ***"
msg="$msg\n$(date "+%F %T") *** $cron_record jobs ***"
echo -e "$(date "+%F %T") *** $cron_record jobs ***" |\
tee -a $BACKUP/$user.log
fi
echo
msg="$msg\n"
fi
# User Directories
if [ "$USER" != '*' ]; then
echo "-- User Dir --"
msg="$msg\n-- User Dir --"
echo -e "\n-- User Dir --" |tee -a $BACKUP/$user.log
mkdir $tmpdir/user_dir
cd $HOMEDIR/$user
@ -471,8 +426,8 @@ if [ "$USER" != '*' ]; then
fargs+=(-not)
fargs+=(-path)
fargs+=("./$xpath*")
echo "$(date "+%F %T") excluding directory $xpath"
msg="$msg\n$(date "+%F %T") excluding directory $xpath"
echo "$(date "+%F %T") excluding directory $xpath" |\
tee -a $BACKUP/$user.log
done
IFS=$'\n'
@ -484,8 +439,7 @@ if [ "$USER" != '*' ]; then
if [ -z "$exclusion" ]; then
((i ++))
udir_list="$udir_list $udir"
echo -e "$(date "+%F %T") adding $udir"
msg="$msg\n$(date "+%F %T") adding $udir"
echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
# Backup files and dirs
tar -cpf $tmpdir/user_dir/$udir.tar $udir
@ -499,14 +453,12 @@ if [ "$USER" != '*' ]; then
# Print total
if [ "$i" -eq 1 ]; then
echo -e "$(date "+%F %T") *** $i user directory ***"
msg="$msg\n$(date "+%F %T") *** $i directory ***"
echo -e "$(date "+%F %T") *** $i user directory ***" |\
tee -a $BACKUP/$user.log
else
echo -e "$(date "+%F %T") *** $i directories ***"
msg="$msg\n$(date "+%F %T") *** $i directories ***"
echo -e "$(date "+%F %T") *** $i directories ***" |\
tee -a $BACKUP/$user.log
fi
echo
msg="$msg\n"
fi
# Get backup size
@ -533,23 +485,20 @@ local_backup(){
# Removing old backup
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
echo -e "$(date "+%F %T") Roated: $backup_date"
msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
echo -e "$(date "+%F %T") Roated: $backup_date" |\
tee -a $BACKUP/$user.log
rm -f $BACKUP/$backup
done
fi
# Checking disk space
disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %)
if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then
rm -rf $tmpdir
echo "Not enough disk space to run backup" |\
$send_mail -s "$subj" $email
echo "Error: Not enough disk space"
rm -f $BACKUP/$user.log
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_DISK" "$ARGUMENTS"
exit $E_DISK
echo "Not enough disk space" |$SENDMAIL -s "$subj" $email $notify
check_result "$E_DISK" "Not enough dsk space"
fi
# Creating final tarball
@ -558,8 +507,8 @@ local_backup(){
chmod 640 $BACKUP/$user.$date.tar
chown admin:$user $BACKUP/$user.$date.tar
localbackup='yes'
echo -e "$(date "+%F %T") Local: $BACKUP/$user.$date.tar"
msg="$msg\n$(date "+%F %T") Local: $BACKUP/$user.$date.tar"
echo -e "$(date "+%F %T") Local: $BACKUP/$user.$date.tar" |\
tee -a $BACKUP/$user.log
U_BACKUPS=$(ls $BACKUP/ |grep "^$user." |wc -l)
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
}
@ -582,12 +531,12 @@ EOF
ftp_backup() {
# Checking config
if [ ! -e "$VESTA/conf/ftp.backup.conf" ]; then
ftp_conf_error="Can't open $VESTA/conf/ftp.backup.conf"
echo "$ftp_conf_error" |$send_mail -s "$subj" $email
echo "Error: $VESTA/conf/ftp.backup.conf doesn't exist"
error="ftp.backup.conf doesn't exist"
rm -rf $tmpdir
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
check_result "$E_NOTEXIST" "$error"
fi
# Parse config
@ -600,13 +549,12 @@ ftp_backup() {
# Checking variables
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
error="Can't parse ftp backup configuration"
rm -rf $tmpdir
echo "Can't parse ftp backup configuration" |\
$send_mail -s "$subj" $email
echo "Error: Parsing error"
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_PARSING" "$ARGUMENTS"
exit $E_PARSING
check_result "$E_PARSING" "$error"
fi
@ -617,13 +565,12 @@ ftp_backup() {
fconn=$(ftpc)
ferror=$(echo $fconn |grep -i -e failed -e error -e "Can't" -e "not conn")
if [ ! -z "$ferror" ]; then
error="Error: can't login to ftp ftp://$USERNAME@$HOST"
rm -rf $tmpdir
echo "Can't login to ftp://$USERNAME@$HOST" |\
$send_mail -s "$subj" $email
echo "Error: can't login to ftp ftp://$USERNAME@$HOST"
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_CONNECT" "$ARGUMENTS"
exit $E_CONNECT
check_result "$E_CONNECT" "$error"
fi
# Check ftp permissions
@ -632,13 +579,12 @@ ftp_backup() {
ftpc "mkdir $ftmpdir" "rm $ftmpdir"
ftp_result=$(ftpc "mkdir $ftmpdir" "rm $ftmpdir" |grep -v Trying)
if [ ! -z "$ftp_result" ] ; then
error="Can't create ftp backup folder ftp://$HOST$BPATH"
rm -rf $tmpdir
echo "Can't create ftp backup folder ftp://$HOST$BPATH" |\
$send_mail -s "$subj" $email
echo "Error: cant's create ftp folder ftp://$HOST$BPATH"
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_FTP" "$ARGUMENTS"
exit $E_FTP
check_result "$E_FTP" "$error"
fi
# Checking retention
@ -648,8 +594,8 @@ ftp_backup() {
backups_rm_number=$((backups_count - BACKUPS + 1))
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
echo -e "$(date "+%F %T") Roated ftp backup: $backup_date"
msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
echo -e "$(date "+%F %T") Roated ftp backup: $backup_date" |\
tee -a $BACKUP/$user.log
ftpc "cd $BPATH" "delete $backup"
done
fi
@ -729,12 +675,12 @@ sftp_backup() {
# Checking config
if [ ! -e "$VESTA/conf/sftp.backup.conf" ]; then
sftp_conf_error="Can't open $VESTA/conf/sftp.backup.conf"
echo "$sftp_conf_error" |$send_mail -s "$subj" $email
echo "Error: $VESTA/conf/sftp.backup.conf doesn't exist"
error="Can't open sftp.backup.conf"
rm -rf $tmpdir
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
check_result "$E_NOTEXIST" "$error"
fi
# Parse config
@ -747,17 +693,17 @@ sftp_backup() {
# Checking variables
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ]; then
error="Can't parse sftp backup configuration"
rm -rf $tmpdir
echo "Can't parse sftp backup configuration" |\
$send_mail -s "$subj" $email
echo "Error: Parsing error"
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$E_PARSING" "$ARGUMENTS"
exit $E_PARSING
check_result "$E_PARSING" "$error"
fi
# Debug info
echo -e "$(date "+%F %T") Remote: sftp://$HOST/$BPATH/$user.$date.tar"
echo -e "$(date "+%F %T") Remote: sftp://$HOST/$BPATH/$user.$date.tar" |\
tee -a $BACKUP/$user.log
# Checking network connection and write permissions
sftmpdir="$BPATH/vst.bK76A9SUkt"
@ -765,33 +711,32 @@ sftp_backup() {
sftpc "mkdir $sftmpdir" "rmdir $sftmpdir" > /dev/null 2>&1
rc=$?
if [[ "$rc" != 0 ]]; then
rm -rf $tmpdir
case $rc in
$E_CONNECT) echo "Error: can't login to sftp host $HOST" |\
$send_mail -s "$subj" $email;;
$E_FTP) echo "Error: can't create temp folder on sftp $HOST" |\
$send_mail -s "$subj" $email;;
$E_CONNECT) error="Can't login to sftp host $HOST" ;;
$E_FTP) error="Can't create temp folder on sftp $HOST" ;;
esac
rm -rf $tmpdir
rm -f $BACKUP/$user.log
echo "$error" |$SENDMAIL -s "$subj" $email $notify
sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
log_event "$rc" "$ARGUMENTS"
exit "$rc"
check_result "$rc" "$error"
fi
# Checking retention
backup_list=$(sftpc "cd $BPATH" "ls -l" |awk '{print $9}' |grep "^$user\.")
backup_list=$(sftpc "cd $BPATH" "ls -l" |awk '{print $9}'|grep "^$user\.")
backups_count=$(echo "$backup_list" |wc -l)
if [ "$backups_count" -ge "$BACKUPS" ]; then
backups_rm_number=$((backups_count - BACKUPS + 1))
for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar.*$//")
echo -e "$(date "+%F %T") Roated sftp backup: $backup_date"
msg="$msg\n$(date "+%F %T") Roated sftp backup: $backup_date"
echo -e "$(date "+%F %T") Roated sftp backup: $backup_date" |\
tee -a $BACKUP/$user.log
sftpc "cd $BPATH" "rm $backup" > /dev/null 2>&1
done
fi
# Uploading backup archive
echo -e "$(date "+%F %T") Uploading $user.$date.tar ..."
echo "$(date "+%F %T") Uploading $user.$date.tar"|tee -a $BACKUP/$user.log
if [ "$localbackup" = 'yes' ]; then
cd $BACKUP
sftpc "cd $BPATH" "put $user.$date.tar" > /dev/null 2>&1
@ -804,8 +749,7 @@ sftp_backup() {
fi
}
echo "-- SUMMARY --"
msg="$msg\n-- SUMMARY --"
echo -e "\n-- SUMMARY --" |tee -a $BACKUP/$user.log
# Switching on backup system types
for backup_type in $(echo -e "${BACKUP_SYSTEM//,/\\n}"); do
@ -831,10 +775,8 @@ if [ "$run_time" -eq 1 ]; then
min=minute
fi
echo "$(date "+%F %T") Size: $size Mb"
msg="$msg\n$(date "+%F %T") Size: $size Mb"
echo "$(date "+%F %T") Runtime: $run_time $min"
msg="$msg\n$(date "+%F %T") Runtime: $run_time $min"
echo "$(date "+%F %T") Size: $size Mb" |tee -a $BACKUP/$user.log
echo "$(date "+%F %T") Runtime: $run_time $min" |tee -a $BACKUP/$user.log
#----------------------------------------------------------#
@ -866,10 +808,11 @@ chmod 660 $USER_DATA/backup.conf
sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
# Send notification
if [ "$notify" != 'no' ]; then
if [ -e "$BACKUP/$user.log" ]; then
subj="$user → backup has been completed"
email=$(get_user_value '$CONTACT')
echo -e "$msg" |$send_mail -s "$subj" $email
cat $BACKUP/$user.log #|$SENDMAIL -s "$subj" $email $notify
rm $BACKUP/$user.log
fi
# Logging

View file

@ -80,7 +80,6 @@ $BIN/v-suspend-database $owner $database > /dev/null 2>&1
eval $db_data
dump="$tmpdir/$database.$TYPE.sql"
grants="$tmpdir/$database.$TYPE.$DBUSER"
send_mail='/bin/true'
case $TYPE in
mysql) dump_mysql_database ;;
pgsql) dump_pgsql_database ;;

View file

@ -35,7 +35,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_dns_template_valid
is_dns_template_valid "$template"
#----------------------------------------------------------#
@ -52,8 +52,31 @@ for nameserver in ${ns//,/ };do
(( ++i))
done
# Reading template
template_data=$(cat $DNSTPL/$template.tpl)
# Deleting unused nameservers
if [ -z "$ns3" ]; then
template_data=$(echo "$template_data" |grep -v %ns3%)
fi
if [ -z "$ns4" ]; then
template_data=$(echo "$template_data" |grep -v %ns4%)
fi
if [ -z "$ns5" ]; then
template_data=$(echo "$template_data" |grep -v %ns5%)
fi
if [ -z "$ns6" ]; then
template_data=$(echo "$template_data" |grep -v %ns6%)
fi
if [ -z "$ns7" ]; then
template_data=$(echo "$template_data" |grep -v %ns7%)
fi
if [ -z "$ns8" ]; then
template_data=$(echo "$template_data" |grep -v %ns8%)
fi
# Changing tpl
cat $DNSTPL/$template.tpl |\
echo "$template_data" |\
sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: change ip owner
# options: DOMAIN USER [IP]
# info: change domain owner
# options: DOMAIN USER
#
# The function of changing domain ownership.
@ -12,7 +12,6 @@
# Argument definition
domain=$1
user=$2
ip=$3
# Includes
source $VESTA/func/ip.sh
@ -24,20 +23,13 @@ source $VESTA/conf/vesta.conf
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'DOMAIN USER [IP]'
check_args '2' "$#" 'DOMAIN USER'
is_format_valid 'domain' 'user'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
if [ ! -z "$ip" ]; then
is_ip_valid
is_ip_avalable
fi
owner=$(v-search-domain-owner $domain)
if [ -z "$owner" ]; then
echo "Error: domain $domain doesn't exist"
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
check_result $E_NOTEXIST "domain $domain doesn't exist"
fi
if [ "$owner" = "$user" ]; then
exit

View file

@ -28,7 +28,7 @@ if [ -z $homedir ]; then
fi
# Checking source file
if [ ! -f "$src_file" ]; then
if [ ! -fe "$src_file" ]; then
echo "Error: source file doesn't exist $src_file"
exit 3
fi
@ -41,7 +41,7 @@ if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
fi
# Changing file permissions
sudo -u $user chmod $permissions "$src_file" >/dev/null 2>&1
sudo -u $user chmod -R $permissions "$src_file" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Error: access permission on $src_file was not changed"
exit 3

View file

@ -44,7 +44,7 @@ is_password_valid
#----------------------------------------------------------#
# Generating hashed password
salt=$(gen_password "$PW_MATRIX" "8")
salt=$(generate_password "$PW_MATRIX" "8")
md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"
if [[ "$MAIL_SYSTEM" =~ exim ]]; then

View file

@ -25,10 +25,8 @@ source $VESTA/conf/vesta.conf
check_args '2' "$#" 'IP IP_NAME'
is_format_valid 'ip'
if [ ! -z "$ip_name" ]; then
is_format_valid 'ip_name'
fi
is_ip_valid
is_format_valid 'ip_name'
is_ip_valid "$ip"
#----------------------------------------------------------#

View file

@ -26,10 +26,8 @@ source $VESTA/conf/vesta.conf
check_args '2' "$#" 'IP NAT_IP [RESTART]'
is_format_valid 'ip'
if [ ! -z "$nat_ip" ]; then
is_format_valid 'nat_ip'
fi
is_ip_valid
is_format_valid 'nat_ip'
is_ip_valid "$ip"
#----------------------------------------------------------#

View file

@ -27,11 +27,10 @@ check_args '2' "$#" 'IP USER'
is_format_valid 'ip' 'user'
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_ip_valid
is_ip_valid "$ip"
is_ip_key_empty '$U_WEB_DOMAINS'
is_ip_key_empty '$U_SYS_USERS'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#

View file

@ -25,7 +25,7 @@ source $VESTA/conf/vesta.conf
check_args '2' "$#" 'IP IP_STATUS'
is_format_valid 'ip' 'ip_status'
is_ip_valid
is_ip_valid "$ip"
if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then
echo "Error: status $ip_status is already set"
log_event "$E_EXISTS" "$ARGUMENTS"

View file

@ -40,51 +40,37 @@ is_package_avalable() {
# Checking usage agains package limits
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
if [ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]; then
echo "Error: Package doesn't cover WEB_DOMAIN usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover WEB_DOMAIN usage"
fi
fi
if [ "$DNS_DOMAINS" ! = 'unlimited' ]; then
if [ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]; then
echo "Error: Package doesn't cover DNS_DOMAIN usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover DNS_DOMAIN usage"
fi
fi
if [ "$MAIL_DOMAINS" != 'unlimited' ]; then
if [ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]; then
echo "Error: Package doesn't cover MAIL_DOMAIN usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover MAIL_DOMAIN usage"
fi
fi
if [ "$DATABASES" != 'unlimited' ]; then
if [ "$DATABASES" -lt "$U_DATABASES" ]; then
echo "Error: Package doesn't cover DATABASE usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover DATABASE usage"
fi
fi
if [ "$CRON_JOBS" != 'unlimited' ]; then
if [ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]; then
echo "Error: Package doesn't cover CRON usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover CRON usage"
fi
fi
if [ "$DISK_QUOTA" != 'unlimited' ]; then
if [ "$DISK_QUOTA" -lt "$U_DISK" ]; then
echo "Error: Package doesn't cover DISK usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover DISK usage"
fi
fi
if [ "$BANDWIDTH" != 'unlimited' ]; then
if [ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]; then
echo "Error: Package doesn't cover BANDWIDTH usage"
log_event "$E_LIMIT" "$ARGUMENTS"
exit $E_LIMIT
check_result $E_LIMIT "Package doesn't cover BANDWIDTH usage"
fi
fi
}

View file

@ -43,7 +43,7 @@ md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)
#----------------------------------------------------------#
# Changing RKEY value
update_user_value "$user" '$RKEY' "$(gen_password)"
update_user_value "$user" '$RKEY' "$(generate_password)"
update_user_value "$user" '$MD5' "$md5"
# Logging

View file

@ -35,11 +35,11 @@ is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------#
case $type in
WEB) is_web_template_valid;
WEB) is_web_template_valid $template;
update_user_value "$user" '$WEB_TEMPLATE' "$template";;
PROXY) is_proxy_template_valid $template;
update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
DNS) is_dns_template_valid;
DNS) is_dns_template_valid $template;
update_user_value "$user" '$DNS_TEMPLATE' "$template";;
*) check_args '1' '0' 'USER TYPE TEMPLATE'
esac

View file

@ -35,7 +35,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_web_backend_template_valid $template
is_backend_template_valid $template
#----------------------------------------------------------#

View file

@ -11,9 +11,8 @@
# Argument definition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
new_domain=$(echo $3 |tr '[:upper:]' '[:lower:]')
domain=$2
ip=$3
restart=$4
# Includes
@ -34,8 +33,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_ip_valid
is_ip_avalable
is_ip_valid "$ip" "$user"
#----------------------------------------------------------#
@ -46,6 +44,12 @@ is_ip_avalable
get_domain_values 'web'
old=$(get_real_ip $IP)
new=$ip
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $domain)
else
domain_idn=$domain
fi
# Replacing vhost
replace_web_config "$WEB_SYSTEM" "$TPL.tpl"

View file

@ -48,7 +48,7 @@ is_proxy_template_valid $template
# Parsing domain values
get_domain_values 'web'
ip=$(get_real_ip $IP)
local_ip=$(get_real_ip $IP)
# Delete old vhost
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"

View file

@ -35,7 +35,7 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_web_template_valid
is_web_template_valid "$template"
#----------------------------------------------------------#
@ -44,7 +44,7 @@ is_web_template_valid
# Parsing domain values
get_domain_values 'web'
ip=$(get_real_ip $IP)
local_ip=$(get_real_ip $IP)
# Deleting domain
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
@ -53,7 +53,6 @@ if [ "$SSL" = 'yes' ]; then
fi
# Defining variables for new vhost config
TPL=$template
prepare_web_domain_values
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
if [ "$SSL" = 'yes' ]; then

View file

@ -35,7 +35,7 @@ is_object_unsuspended 'user' 'USER' "$user"
# Working on Web domain
if [ ! -z "$WEB_SYSTEM" ]; then
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf |grep "SUSPENDED='no")
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
if [ ! -z "$str" ]; then
domain_found='yes'
$BIN/v-delete-web-domain $user $domain 'no'
@ -45,7 +45,7 @@ fi
# Working on DNS domain
if [ ! -z "$DNS_SYSTEM" ]; then
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf |grep "SUSPENDED='no")
str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
if [ ! -z "$str" ]; then
domain_found='yes'
$BIN/v-delete-dns-domain $user $domain 'no'
@ -55,7 +55,7 @@ fi
# Working on Mail domain
if [ ! -z "$MAIL_SYSTEM" ]; then
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf |grep "SUSPENDED='no")
str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf)
if [ ! -z "$str" ]; then
domain_found='yes'
$BIN/v-delete-mail-domain $user $domain
@ -65,9 +65,7 @@ fi
# Checking domain search result
if [ -z "$domain_found" ]; then
echo "Error: domain $domain doesn't exist"
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
check_result $E_NOTEXISTS "domain $domain doesn't exist"
fi
# Restarting services

View file

@ -63,12 +63,11 @@ fi
if [ "$restart" = 'yes' ]; then
subj="OpenSSH restart failed"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
send_mail="$VESTA/web/inc/mail-wrapper.php"
/usr/sbin/sshd -t >/dev/null 2>&1
if [ "$?" -ne 0 ]; then
mail_text="OpenSSH can not be restarted. Please check config:
\n\n$(/usr/sbin/sshd -t)"
echo -e "$mail_text" | $send_mail -s "$subj" $email
echo -e "$mail_text" |$SENDMAIL -s "$subj" $email
else
service ssh restart >/dev/null 2>&1
service sshd restart >/dev/null 2>&1

View file

@ -38,52 +38,37 @@ fi
# Action #
#----------------------------------------------------------#
# Checking web system is enabled
# Deleting web domains
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-web-domains $user $restart
$BIN/v-delete-web-domains $user $restart
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
check_result "$?" "web domain deletion failed"
fi
# Checking dns system is enabled
# Deleting dns domains
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-dns-domains $user $restart
$BIN/v-delete-dns-domains $user $restart
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
check_result "$?" "dns domain deletion failed"
fi
# Checking mail system is enabled
# Deleting mail domains
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-mail-domains $user
$BIN/v-delete-mail-domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
check_result "$?" "mail domain deletion failed"
fi
# Checking db system is enabled
# Deleting databases
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-databases $user
$BIN/v-delete-databases $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
check_result "$?" "database deletion failed"
fi
# Checking ip
# Releasing user ips
$BIN/v-delete-user-ips "$user"
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
check_result "$?" "user ip release failed"
# Deleteing user pipes
sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe
@ -96,14 +81,13 @@ fi
# Deleting system user
/usr/sbin/userdel -f $user >> /dev/null 2>&1
if [ "$?" != 0 ]; then
if [ $? -ne 0 ]; then
sed -i "/^$user:/d" /etc/passwd
sed -i "/^$user:/d" /etc/shadow
fi
/usr/sbin/groupdel $user >> /dev/null 2>&1
if [ "$?" != 0 ]; then
if [ $? -ne 0 ]; then
sed -i "/^$user:/d" /etc/group
fi

View file

@ -17,15 +17,6 @@ user=$1
domain=$2
restart=$3
# Additional argument formatting
if [[ "$domain" =~ [[:upper:]] ]]; then
domain=$(echo "$domain" |tr '[:upper:]' '[:lower:]')
fi
domain_idn="$domain"
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $tmp_alias)
fi
# Includes
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
@ -57,6 +48,10 @@ fi
# Parsing domain values
get_domain_values 'web'
domain_idn="$domain"
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $domain)
fi
local_ip=$(get_real_ip $IP)
# Deleting domain from web.conf

View file

@ -35,11 +35,8 @@ is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
get_domain_values 'web'
ip=$(get_real_ip $IP)
if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then
echo "Error: alias $dom_alias doesn't exist"
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
if [ -z "$(echo $ALIAS |tr ',' '\n' |grep ^$dom_alias$)" ]; then
check_result $E_NOTEXIST "alias $dom_alias doesn't exist"
fi
@ -48,6 +45,7 @@ fi
#----------------------------------------------------------#
# Preparing domain values for the template substitution
local_ip=$(get_real_ip $IP)
ALIAS=$(echo "$ALIAS" |\
sed -e "s/,/\n/g"|\
sed -e "s/^$dom_alias$//g"|\

View file

@ -12,7 +12,6 @@
# Argument definition
domain=$1
domain=$(echo $domain |sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain |tr '[:upper:]' '[:lower:]')
domain_alias=$domain
email=$2
country=$3
@ -70,6 +69,15 @@ is_format_valid 'domain_alias' 'format'
# Action #
#----------------------------------------------------------#
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $domain)
else
domain_idn=$domain
fi
if [[ "$email" = *[![:ascii:]]* ]]; then
email=$(idn -t --quiet -a $email)
fi
# Create temporary work directory
workdir=$(mktemp -d)
cd $workdir
@ -79,7 +87,7 @@ openssl genrsa $KEY_SIZE > $domain.key 2>/dev/null
# Generate the CSR
subj="/C=$country/ST=$state/localityName=$city/O=$org"
subj="$subj/organizationalUnitName=$org_unit/commonName=$domain"
subj="$subj/organizationalUnitName=$org_unit/commonName=$domain_idn"
subj="$subj/emailAddress=$email"
if [ -z "$aliases" ]; then
openssl req -sha256\
@ -87,7 +95,7 @@ if [ -z "$aliases" ]; then
-batch \
-subj "$subj" \
-key $domain.key \
-out $domain.csr >/dev/null 2>&1
-out $domain.csr #>/dev/null 2>&1
else
for alias in $(echo $domain,$aliases |tr ',' '\n' |sort -u); do
dns_aliases="${dns_aliases}DNS:$alias,"
@ -118,6 +126,7 @@ openssl x509 -req -sha256 \
-signkey $domain.key \
-out $domain.crt >/dev/null 2>&1
# Listing certificates
if [ -e "$domain.crt" ]; then
crt=$(cat $domain.crt | sed ':a;N;$!ba;s/\n/\\n/g' )

View file

@ -82,7 +82,7 @@ csv_list() {
check_args '1' "$#" 'TEMPLATE [FORMAT]'
is_format_valid 'template'
is_dns_template_valid
is_dns_template_valid "$template"
#----------------------------------------------------------#

View file

@ -18,7 +18,7 @@ source $VESTA/func/main.sh
# JSON list function
json_list() {
objects=$(echo "$users" |wc -l)
objects=$(grep @ /etc/passwd |wc -l)
i=1
echo '['
while read user; do

View file

@ -66,7 +66,7 @@ plain_list() {
# CSV list function
csv_list() {
echo "IP,OWNER,STATUS,NAME,NAT"
for IP in $(ls $VESTA/data/ips/); do
for IP in $ips; do
source $VESTA/data/ips/$IP
echo "$IP,$OWNER,$STATUS,$NAME,$NAT"
done
@ -88,10 +88,10 @@ is_object_valid 'user' 'USER' "$user"
# Defining fileds to select
owner='admin'
owner_ips=$(grep -A 1 "OWNER='$owner'" $VESTA/data/ips/*)
owner_ips=$(grep -A 1 -H "OWNER='$owner'" $VESTA/data/ips/*)
owner_ips=$(echo "$owner_ips" |grep "STATUS='shared'")
owner_ips=$(echo "$owner_ips" |cut -f 7 -d / |cut -f 1 -d -)
user_ips=$(grep "OWNER='$user'" $VESTA/data/ips/*)
user_ips=$(grep -H "OWNER='$user'" $VESTA/data/ips/*)
user_ips=$(echo "$user_ips" |cut -f 7 -d / |cut -f 1 -d :)
ips=$(echo -e "$user_ips\n$owner_ips" |sort -u |sed "/^$/d")
fields='$IP $OWNER $STATUS $NAME $NAT'

View file

@ -14,14 +14,13 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $CRON_SYSTEM restart failed"
service $CRON_SYSTEM configtest >> $tmpfile 2>&1
service $CRON_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -50,7 +49,7 @@ if [ $? -ne 0 ]; then
service $CRON_SYSTEM restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
exit $E_RESTART
check_result $E_RESTART "$CRON_SYSTEM restart failed"
fi
fi

View file

@ -19,15 +19,13 @@ send_email_report() {
else
dns_conf='/etc/bind/named.conf'
fi
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $DNS_SYSTEM restart failed"
/usr/sbin/named-checkconf $dns_conf >> $tmpfile 2>&1
service $DNS_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -56,8 +54,7 @@ if [ $? -ne 0 ]; then
service $DNS_SYSTEM restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $DNS_SYSTEM restart failed"
exit $E_RESTART
check_result $E_RESTART "$DNS_SYSTEM restart failed"
fi
fi

View file

@ -14,14 +14,13 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $FTP_SYSTEM restart failed"
service $FTP_SYSTEM configtest >> $tmpfile 2>&1
service $FTP_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -48,8 +47,7 @@ fi
service $FTP_SYSTEM restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $FTP_SYSTEM restart failed"
exit $E_RESTART
check_result $E_RESTART "$FTP_SYSTEM restart failed"
fi
# Update restart queue

View file

@ -14,14 +14,13 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $MAIL_SYSTEM restart failed"
service $MAIL_SYSTEM configtest >> $tmpfile 2>&1
service $MAIL_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -48,8 +47,7 @@ fi
service $MAIL_SYSTEM restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $MAIL_SYSTEM restart failed"
exit $E_RESTART
check_result $E_RESTART "$MAIL_SYSTEM restart failed"
fi
# Update restart queue

View file

@ -14,14 +14,13 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $PROXY_SYSTEM restart failed"
service $PROXY_SYSTEM configtest >> $tmpfile 2>&1
service $PROXY_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -48,8 +47,7 @@ fi
service $PROXY_SYSTEM restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $PROXY_SYSTEM restart failed"
exit $E_RESTART
check_result $E_RESTART "$PROXY_SYSTEM restart failed"
fi
# Update restart queue

View file

@ -30,13 +30,13 @@ check_args '1' "$#" 'SERVICE'
if [ "$service" != "iptables" ]; then
service $service restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
exit $E_RESTART
check_result $E_RESTART "$service restart failed"
fi
else
$BIN/v-stop-firewall
$BIN/v-update-firewall
if [ $? -ne 0 ]; then
exit $E_RESTART
check_result $E_RESTART "$service restart failed"
fi
fi

View file

@ -14,14 +14,13 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $WEB_SYSTEM restart failed"
service $WEB_SYSTEM configtest >> $tmpfile 2>&1
service $WEB_SYSTEM restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -62,8 +61,7 @@ if [ "$rc" -ne 0 ]; then
service $WEB_SYSTEM restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $WEB_SYSTEM restart failed"
exit $E_RESTART
check_result $E_RESTART "$WEB_SYSTEM restart failed"
fi
fi

View file

@ -14,14 +14,13 @@ source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
send_email_report() {
send_mail="$VESTA/web/inc/mail-wrapper.php"
email=$(grep CONTACT $VESTA/data/users/admin/user.conf)
email=$(echo "$email" | cut -f 2 -d "'")
tmpfile=$(mktemp)
subj="$(hostname): $WEB_BACKEND restart failed"
service $WEB_BACKEND configtest >> $tmpfile 2>&1
service $WEB_BACKEND restart >> $tmpfile 2>&1
cat $tmpfile | $send_mail -s "$subj" $email
cat $tmpfile |$SENDMAIL -s "$subj" $email
rm -f $tmpfile
}
@ -48,8 +47,7 @@ fi
service $WEB_BACKEND restart >/dev/null 2>&1
if [ $? -ne 0 ]; then
send_email_report
echo "Error: $WEB_BACKEND restart failed"
exit $E_RESTART
check_result $E_RESTART "$WEB_BACKEND restart failed"
fi
# Update restart queue

File diff suppressed because it is too large Load diff

View file

@ -43,7 +43,7 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
# Parsing domain values
get_domain_values 'web'
SUSPENDED='yes'
ip=$(get_real_ip $IP)
local_ip=$(get_real_ip $IP)
# Preparing domain values for the template substitution
prepare_web_domain_values

View file

@ -41,7 +41,7 @@ is_object_suspended 'web' 'DOMAIN' "$domain"
# Parsing domain values
get_domain_values 'web'
SUSPENDED='no'
ip=$(get_real_ip $IP)
local_ip=$(get_real_ip $IP)
# Preparing domain values for the template substitution
prepare_web_domain_values

View file

@ -25,7 +25,7 @@ source $VESTA/conf/vesta.conf
tmpdir=$(mktemp -d --dry-run)
mkdir $tmpdir
cd $tmpdir
wget http://c.vestacp.com/$VERSION/rhel/templates.tar.gz -q
wget http://c.vestacp.com/rhel/7/templates.tar.gz -q
if [ "$?" -ne 0 ]; then
echo "Error: can't download template.tar.gz"
log_event "$E_CONNECT" "$ARGUMENTS"

View file

@ -19,9 +19,7 @@ source $VESTA/conf/vesta.conf
is_file_available() {
if [ ! -e "$vfile" ]; then
echo "Error: file $vfile doesn't exist"
log_event "$E_NOTEXIST" "$ARGUMENTS"
exit $E_NOTEXIST
check_result $E_NOTEXIST "file $vfile doesn't exist"
fi
}
@ -29,9 +27,7 @@ is_file_valid() {
exclude="[!$#&;()\]"
vcontent=$(cat $vfile)
if [[ "$vcontent" =~ $exclude ]]; then
echo "Error: invalid characters in the exlusion list"
log_event "$E_INVALID" "$ARGUMENTS"
exit $E_INVALID
check_result $E_INVALID "invalid characters in the exlusion list"
fi
}

View file

@ -1,278 +0,0 @@
#!/bin/bash
# info: update user backups
# options: USER
#
# The function rescan backup directory and updates backup database.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
# Argument definition
user=$1
type="${2-$BACKUP_SYSTEM}"
# Defining tar parser function
get_backup_info() {
backup=$1
backup_type="$2"
backup_name=$(basename $backup )
backup_date=$(echo $backup_name |cut -f 2 -d '.' )
backup_time=$(stat --printf=%y $backup |cut -f 2 -d ' ' |cut -f 1 -d '.')
backup_size=$(du -sm $backup |cut -f 1 )
backup_data=$(tar -tf $backup)
vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$")
if [ -z "$vst_data" ]; then
vst=''
else
vst='yes'
fi
pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$")
if [ -z "$pam_data" ]; then
pam=''
else
pam='yes'
fi
web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort)
if [ -z "$web_data" ]; then
web=''
else
i=1
for domain in $web_data; do
domain="$(basename $domain |sed 's/.tar.gz$//')"
if [ "$i" -eq 1 ]; then
web="$domain"
i=2
else
web="$web,$domain"
fi
done
fi
dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort)
if [ -z "$dns_data" ]; then
dns=''
else
i=1
for domain in $dns_data; do
domain="$(basename $domain |sed 's/.db$//')"
if [ "$i" -eq 1 ]; then
dns="$domain"
i=2
else
dns="$dns,$domain"
fi
done
fi
mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort)
if [ -z "$mail_data" ]; then
ml=''
else
i=1
for domain in $mail_data; do
domain="$(basename $domain |sed 's/.tar.gz$//')"
if [ "$i" -eq 1 ]; then
ml="$domain"
i=2
else
ml="$ml,$domain"
fi
done
fi
db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort)
if [ -z "$db_data" ]; then
db=''
else
i=1
for dbase in $db_data; do
dbase=$(basename $dbase |sed "s/.\(my\|pg\)sql.sql.gz$//")
if [ "$i" -eq 1 ]; then
db="$dbase"
i=2
else
db="$db,$dbase"
fi
done
fi
ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort)
if [ -z "$ssl_data" ]; then
ssl=''
else
i=1
for certificate in $ssl_data; do
certificate=$(basename $certificate |sed "s/.crt$//")
if [ "$i" -eq 1 ]; then
ssl="$certificate"
i=2
else
ssl="$ssl,$certificate"
fi
done
fi
cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$")
if [ -z "$cron_data" ]; then
cron=''
else
cron='yes'
fi
echo -n "DATE='$backup_date' TIME='$backup_time' RUNTIME='0'"
echo -n " SIZE='$backup_size' TYPE='$backup_type' VESTA='$vst' PAM='$pam'"
echo " WEB='$web' DNS='$dns' MAIL='$ml' DB='$db' SSL='$ssl' CRON='$cron'"
}
# 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() {
source $VESTA/conf/ftp.backup.conf
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
[ -z "$BPATH" ]; then
echo "Error: Parsing error"
log_event "$E_PARSING" "$ARGUMENTS"
exit $E_PARSING
fi
}
check_ftp_connection(){
ftmpdir=$(mktemp -u -p $BPATH)
command="mkdir $ftmpdir
ls $ftmpdir
rm $ftmpdir"
if [ ! -z "$(ftpc "$command")" ] ; then
echo "Error: FTP error"
log_event "$E_FTP" "$ARGUMENTS"
exit $E_FTP
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'USER'
is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM'
is_format_valid 'user'
is_object_valid 'user' 'USER' "$user"
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
if [ "$la" -ge "$BACKUP_LA_LIMIT" ]; then
log_event "$E_LA" "$ARGUMENTS"
exit $E_LA
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Checking tmp file
tmp_file="$USER_DATA/backup.conf_tmp"
if [ -e "$tmp_file" ]; then
rm -f $tmp_file
fi
# Checking local
if [ "$type" = 'local' ]; then
backups=$(ls $BACKUP |grep "^$user."|sort)
for backup in $backups; do
get_backup_info $BACKUP/$backup $type >> $tmp_file
done
fi
# Checking ftp
if [ "$type" = 'ftp' ]; then
tmpdir=$(mktemp -p $BACKUP -d)
ftmpdir=$(basename $tmpdir)
init_ftp_variables
check_ftp_connection
backups=$(ftpc ls|awk '{print $9}'|grep "^$user.")
for backup in $backups; do
cd $tmpdir
if [ ! -z "$(ftpc "get $backup")" ]; then
echo "Error: FTP transfer error"
log_event "$E_FTP" "$ARGUMENTS"
exit $E_FTP
fi
get_backup_info $tmpdir/$backup $type >> $tmp_file
rm -f $tmpdir/$backup
done
rm -rf $tmpdir
fi
# Checking both local and ftp
if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then
tmpdir=$(mktemp -p $BACKUP -d)
ftmpdir=$(basename $tmpdir)
init_ftp_variables
check_ftp_connection
ftp_backups=$(ftpc ls|awk '{print $9}'|grep "^$user.")
local_backups=$(ls $BACKUP/ |grep "^$user." |sort)
backups=$(echo -e "$local_backups\n$ftp_backups" |\
sort |uniq -c | awk '{print $1" "$2}')
for backup in $(echo "$backups"|grep "^1 "|cut -f 2 -d ' '); do
check_ftp=$(echo $ftp_backups|grep -w $backup)
if [ ! -z "$check_ftp" ]; then
cd $tmpdir
if [ ! -z "$(ftpc "get $backup")" ]; then
echo "Error: FTP transfer error"
log_event "$E_FTP" "$ARGUMENTS"
exit $E_FTP
fi
get_backup_info $tmpdir/$backup ftp >> $tmp_file
rm -f $tmpdir/$backup
else
get_backup_info $BACKUP/$backup local >> $tmp_file
fi
done
for backup in $(echo "$backups"|grep "^2 "|cut -f 2 -d ' '); do
get_backup_info $BACKUP/$backup $type >> $tmp_file
done
rm -rf $tmpdir
fi
# Checking if there was any output
if [ -e "$tmp_file" ]; then
cat $tmp_file | sort > $USER_DATA/backup.conf
rm $tmp_file
else
rm $USER_DATA/backup.conf
touch $USER_DATA/backup.conf
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit

View file

@ -43,9 +43,7 @@ get_domain_values 'web'
# Checking config
config="$HOMEDIR/$user/conf/web/$STATS.$domain.conf"
if [ ! -e "$config" ]; then
echo "Error: Parsing error"
log_event "$E_PARSING" "$ARGUMENTS"
exit $E_PARSING
check_result $E_NOTEXISTS "$config doesn't exist"
fi
# Checking statistics directory