New config path. New permission policy. Improved rebuild scripts.

This commit is contained in:
Serghey Rodin 2012-02-14 18:41:09 +02:00
commit bee8009b4b
21 changed files with 323 additions and 62 deletions

View file

@ -67,6 +67,8 @@ v_str="$v_str' WDAY='$wday' CMD='$command' SUSPEND='no' DATE='$V_DATE'"
# Adding to crontab
echo "$v_str">>$V_USERS/$user/cron.conf
chmod 660 $V_USERS/$user/cron.conf
# Sorting jobs by id
sort_cron_jobs

View file

@ -90,7 +90,8 @@ increase_user_value "$user" '$U_DATABASES'
# Adding db to db conf
v_str="DB='$database' USER='$db_user' HOST='$host' TYPE='$type'"
v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPEND='no' DATE='$V_DATE'"
echo "$v_str">>$V_USERS/$user/db.conf
echo "$v_str" >> $V_USERS/$user/db.conf
chmod 660 $V_USERS/$user/db.conf
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user $database $db_user ***** $type $host"

View file

@ -103,14 +103,20 @@ cat $V_DNSTPL/$template.tpl |\
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
dns_rec="$dns_rec SOA='$soa' SUSPEND='no' DATE='$V_DATE'"
echo "$dns_rec" >> $V_USERS/$user/dns.conf
chmod 660 $V_USERS/$user/dns.conf
# Adding zone in named.conf
named="zone \"$domain_idn\" {type master; file \"/etc/namedb/$domain.db\";};"
named="zone \"$domain_idn\" {type master; file"
named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};"
echo "$named" >> /etc/named.conf
# Updating domain dns zone
conf="$V_HOME/$user/conf/dns/$domain.db"
update_domain_zone
chmod 640 $conf
chown root:named $conf
#----------------------------------------------------------#
# Vesta #

View file

@ -75,26 +75,32 @@ esac
echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1
# Building directory tree
if [ ! -z "$BACKUP_SYSTEM" ] && [ "$BACKUP_SYSTEM" != 'no' ]; then
mkdir $V_HOME/$user/backup
chmod 751 $V_HOME/$user/backup
fi
mkdir $V_HOME/$user/conf
chmod 751 $V_HOME/$user/conf/web
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
mkdir $V_HOME/$user/conf
mkdir $V_HOME/$user/conf/web
mkdir $V_HOME/$user/web
mkdir $V_HOME/$user/tmp
chmod 751 $V_HOME/$user/conf
chmod 751 $V_HOME/$user/conf/web
chmod 751 $V_HOME/$user/web
chmod 777 $V_HOME/$user/tmp
chown $user:$user $V_HOME/$user/web
fi
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
mkdir $V_HOME/$user/conf/mail
mkdir $V_HOME/$user/mail
chmod 751 $V_HOME/$user/mail
chmod 751 $V_HOME/$user/conf/mail
fi
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
mkdir $V_HOME/$user/conf/dns
chmod 751 $V_HOME/$user/conf/dns
fi
# Set permissions
chmod -R a+x $V_HOME/$user
@ -111,36 +117,51 @@ fi
# Adding user dir
mkdir $V_USERS/$user
chmod 770 $V_USERS/$user
# Creating configuration files and pipes
touch $V_USERS/$user/user.conf
touch $V_USERS/$user/backup.conf
chmod 660 $V_USERS/$user/backup.conf
touch $V_USERS/$user/history.log
chmod 660 $V_USERS/$user/history.log
touch $V_USERS/$user/billing.log
chmod 660 $V_USERS/$user/billing.log
echo "v_update_user_disk $user" >> $V_QUEUE/disk.pipe
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
mkdir $V_USERS/$user/ssl
chmod 770 $V_USERS/$user/ssl
touch $V_USERS/$user/web.conf
chmod 660 $V_USERS/$user/web.conf
echo "$V_BIN/v_update_web_domains_traff $user" >> $V_QUEUE/traffic.pipe
echo "v_update_web_domains_disk $user" >> $V_QUEUE/disk.pipe
fi
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
touch $V_USERS/$user/dns.conf
mkdir $V_USERS/$user/dns
chmod 770 $V_USERS/$user/dns
touch $V_USERS/$user/dns.conf
chmod 660 $V_USERS/$user/dns.conf
fi
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
touch $V_USERS/$user/mail_domains.conf
touch $V_USERS/$user/mail_boxes.conf
mkdir $V_USERS/$user/mail
chmod 770 $V_USERS/$user/mail
touch $V_USERS/$user/mail.conf
chmod 660 $V_USERS/$user/mail.conf
echo "v_upd_mail_domains_disk $user" >> $V_QUEUE/disk.pipe
fi
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
touch $V_USERS/$user/db.conf
chmod 660 $V_USERS/$user/db.conf
echo "v_update_db_bases_disk $user" >> $V_QUEUE/disk.pipe
fi
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
touch $V_USERS/$user/cron.conf
chmod 660 $V_USERS/$user/cron.conf
fi
# Filling user config
@ -163,6 +184,7 @@ U_DATABASES='0'
U_MAIL_DOMAINS='0'
U_CRON_JOBS='0'
DATE='$V_DATE'" > $V_USERS/$user/user.conf
chmod 660 $V_USERS/$user/user.conf
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user ***** $email $package $fname $lname"

View file

@ -99,7 +99,7 @@ email="$user@$domain"
docroot="$V_HOME/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
conf="$V_HOME/$user/conf/httpd.conf"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$V_WEBTPL/apache_$template.tpl"
# Parsing template keys
@ -167,8 +167,10 @@ done
# Changing file owner
chown -R $user:$user $V_HOME/$user/web/$domain
chown root:$user /var/log/httpd/domains/$domain.*
chown root:apache $conf
# Changing file permissions
chmod 640 $conf
chmod 551 $V_HOME/$user/web/$domain
chmod 751 $V_HOME/$user/web/$domain/private
chmod 751 $V_HOME/$user/web/$domain/cgi-bin
@ -218,7 +220,8 @@ v_str="$v_str SSL='no' SSL_HOME='single'"
v_str="$v_str NGINX='' NGINX_EXT='' SUSPEND='no' DATE='$V_DATE'"
# Registering domain
echo "$v_str" >>$V_USERS/$user/web.conf
echo "$v_str" >> $V_USERS/$user/web.conf
chmod 660 $V_USERS/$user/web.conf
# Adding task to the vesta pipe
restart_schedule 'web'

View file

@ -67,12 +67,16 @@ get_web_domain_values
NGINX="$template"
NGINX_EXT="$extentions"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
conf="$V_HOME/$user/conf/web/nginx.conf"
# Preparing domain values for the template substitution
upd_web_domain_values
add_web_config
# Set permission and ownership
chown root:nginx $conf
chmod 640 $conf
# Checking main vesta httpd config
main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf )
@ -80,13 +84,16 @@ if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf
fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
proxy_string="proxy_pass https://$ip:$WEB_SSL_PORT;"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
conf="$V_HOME/$user/conf/web/snginx.conf"
add_web_config
chown root:nginx $conf
chmod 640 $conf
main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then
@ -95,6 +102,7 @@ if [ "$SSL" = 'yes' ]; then
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#

View file

@ -76,10 +76,11 @@ if [ -e "$ssl_dir/$domain.ca" ]; then
cp -f $ssl_dir/$domain.ca $V_USERS/$user/ssl/$domain.ca
cat $V_USERS/$user/ssl/$domain.ca >> $V_USERS/$user/ssl/$domain.pem
fi
chmod 660 $V_USERS/$user/ssl/$domain.*
# Parsing domain values
get_web_domain_values
conf="$V_HOME/$user/conf/shttpd.conf"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
SSL_HOME="$ssl_home"
@ -92,12 +93,15 @@ upd_web_domain_values
# Adding domain to the shttpd.conf
add_web_config
chown root:apache $conf
chmod 640 $conf
# Adding certificate to user dir
cp -f $V_USERS/$user/ssl/$domain.crt $V_HOME/$user/conf/ssl.$domain.crt
cp -f $V_USERS/$user/ssl/$domain.key $V_HOME/$user/conf/ssl.$domain.key
cp -f $V_USERS/$user/ssl/$domain.pem $V_HOME/$user/conf/ssl.$domain.pem
cp -f $V_USERS/$user/ssl/$domain.crt $V_HOME/$user/conf/web/ssl.$domain.crt
cp -f $V_USERS/$user/ssl/$domain.key $V_HOME/$user/conf/web/ssl.$domain.key
cp -f $V_USERS/$user/ssl/$domain.pem $V_HOME/$user/conf/web/ssl.$domain.pem
if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then
cp -f $V_USERS/$user/ssl/$domain.ca $V_HOME/$user/conf/ssl.$domain.ca
cp -f $V_USERS/$user/ssl/$domain.ca $V_HOME/$user/conf/web/ssl.$domain.ca
fi
# Running template trigger
@ -115,10 +119,13 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf
conf="$V_HOME/$user/conf/snginx.conf"
conf="$V_HOME/$user/conf/web/snginx.conf"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
add_web_config
chown root:nginx $conf
chmod 640 $conf
# Checking vesta nginx config
main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf )

View file

@ -81,7 +81,7 @@ cat $V_WEBTPL/$type.tpl |\
-e "s/%home%/${V_HOME////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $V_HOME/$user/conf/$type.$domain.conf
> $V_HOME/$user/conf/web/$type.$domain.conf
#----------------------------------------------------------#

View file

@ -503,6 +503,7 @@ backup_str="$backup_str MAIL='${mail_list// /,}'"
backup_str="$backup_str DB='${db_list// /,}'"
backup_str="$backup_str CRON='$cron_list'"
echo "$backup_str" >> $V_USERS/$user/backup.conf
chmod 660 $V_USERS/$user/backup.conf
# Logging
log_event 'system' "$V_EVENT"

View file

@ -54,13 +54,13 @@ tpl_name=$(get_dns_domain_value '$TPL')
old_ip=$(get_dns_domain_value '$IP')
# Deleting domain in named.conf
rm_string=$(grep -n /etc/namedb/$domain.db $named_conf|cut -d : -f 1)
rm_string=$(grep -n /conf/dns/$domain.db $named_conf |cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $named_conf
fi
if [ -e "/etc/namedb/$domain.db" ]; then
rm -f /etc/namedb/$domain.db
if [ -e "$V_HOME/$user/conf/dns/$domain.db" ]; then
rm -f $V_HOME/$user/conf/dns/$domain.db
fi

View file

@ -103,8 +103,12 @@ for domain in $domains; do
sort_dns_records
# Updating zone
conf="$V_HOME/$user/conf/dns/$domain.db"
update_domain_zone
chmod 640 $conf
chown root:named $conf
# Bind config check
nconf='/etc/named.conf'
@ -114,10 +118,9 @@ for domain in $domains; do
sed -i "$rm_string d" $nconf
fi
else
check_string=$(grep /etc/namedb/$domain.db $nconf)
if [ -z "$check_string" ]; then
named="zone \"$domain_idn\""
named="$named {type master; file \"/etc/namedb/$domain.db\";};"
if [ -z "$(grep /$domain.db $nconf)" ]; then
named="zone \"$domain_idn\" {type master; file"
named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};"
echo "$named" >> /etc/named.conf
fi
fi

View file

@ -65,20 +65,58 @@ for domain in $(shell_list) ; do
# Adding domain to the tmp_httpd.conf
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/tmp_httpd.conf"
conf="$V_HOME/$user/conf/web/tmp_httpd.conf"
add_web_config
chown root:apache $conf
chmod 640 $conf
# Running template trigger
if [ -x $V_WEBTPL/apache_$TPL.sh ]; then
$V_WEBTPL/apache_$TPL.sh $user $domain $ip $V_HOME $docroot
fi
# Checking stats
if [ ! -z "$STATS" ]; then
cat $V_WEBTPL/$STATS.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \
-e "s/%home%/${V_HOME////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $V_HOME/$user/conf/web/$STATS.$domain.conf
stats_string="$V_BIN/v_update_web_domain_stat $user $domain"
check_stats_pipe=$(grep "$stats_string" $V_QUEUE/stats.pipe)
if [ -z "$check_stats_pipe" ]; then
echo "$stats_string" >> $V_QUEUE/stats.pipe
fi
fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
# Adding domain to the shttpd.conf
conf="$V_HOME/$user/conf/tmp_shttpd.conf"
conf="$V_HOME/$user/conf/web/tmp_shttpd.conf"
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
add_web_config
chown root:apache $conf
chmod 640 $conf
cp -f $V_USERS/$user/ssl/$domain.crt \
$V_HOME/$user/conf/web/ssl.$domain.crt
cp -f $V_USERS/$user/ssl/$domain.key \
$V_HOME/$user/conf/web/ssl.$domain.key
cp -f $V_USERS/$user/ssl/$domain.pem \
$V_HOME/$user/conf/web/ssl.$domain.pem
if [ -e "$V_USERS/$user/ssl/$domain.ca" ]; then
cp -f $V_USERS/$user/ssl/$domain.ca \
$V_HOME/$user/conf/web/ssl.$domain.ca
fi
# Running template trigger
if [ -x $V_WEBTPL/apache_$TPL.sh ]; then
@ -91,8 +129,10 @@ for domain in $(shell_list) ; do
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/tmp_nginx.conf"
conf="$V_HOME/$user/conf/web/tmp_nginx.conf"
add_web_config
chown root:nginx $conf
chmod 640 $conf
if [ "$SSL" = 'yes' ]; then
if [ "$SUSPEND" = 'yes' ]; then
@ -102,16 +142,18 @@ for domain in $(shell_list) ; do
fi
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/tmp_snginx.conf"
conf="$V_HOME/$user/conf/web/tmp_snginx.conf"
add_web_config
chown root:nginx $conf
chmod 640 $conf
fi
ngix_change='yes'
fi
done
# Renaming tmp config
tmp_conf="$V_HOME/$user/conf/tmp_httpd.conf"
conf="$V_HOME/$user/conf/httpd.conf"
tmp_conf="$V_HOME/$user/conf/web/tmp_httpd.conf"
conf="$V_HOME/$user/conf/web/httpd.conf"
if [ -e "$tmp_conf" ]; then
mv $tmp_conf $conf
fi
@ -119,14 +161,14 @@ fi
# Checking include in main httpd.conf
main_conf='/etc/httpd/conf.d/vesta.conf'
main_conf_check=$(grep "$conf" $main_conf )
if [ ! -z "$domains" ] && [ -z "$main_conf_check" ]; then
if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf
fi
# Checking ssl
if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$V_HOME/$user/conf/tmp_shttpd.conf"
conf="$V_HOME/$user/conf/shttpd.conf"
tmp_conf="$V_HOME/$user/conf/web/tmp_shttpd.conf"
conf="$V_HOME/$user/conf/web/shttpd.conf"
mv $tmp_conf $conf
# Checking include in main httpd.conf
@ -139,11 +181,10 @@ fi
# Checking nginx
if [ "$ngix_change" = 'yes' ]; then
nginx_conf='/etc/nginx/conf.d/vesta_users.conf'
tmp_conf="$V_HOME/$user/conf/tmp_nginx.conf"
conf="$V_HOME/$user/conf/nginx.conf"
tmp_conf="$V_HOME/$user/conf/web/tmp_nginx.conf"
conf="$V_HOME/$user/conf/web/nginx.conf"
mv $tmp_conf $conf
nginx_conf_check=$(grep "$conf" $nginx_conf )
if [ -z "$nginx_conf_check" ]; then
echo "include $conf;" >>$nginx_conf
@ -151,8 +192,8 @@ if [ "$ngix_change" = 'yes' ]; then
# Checking ssl for nginx
if [ "$ssl_change" = 'yes' ]; then
tmp_conf="$V_HOME/$user/conf/tmp_snginx.conf"
conf="$V_HOME/$user/conf/snginx.conf"
tmp_conf="$V_HOME/$user/conf/web/tmp_snginx.conf"
conf="$V_HOME/$user/conf/web/snginx.conf"
mv $tmp_conf $conf
nginx_conf_check=$(grep "$conf" $nginx_conf )
if [ -z "$nginx_conf_check" ]; then

View file

@ -22,8 +22,8 @@ source $V_CONF/vesta.conf
if [ "$CRON_SYSTEM" = 'crond' ]; then
/etc/init.d/crond 'reload' >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$E_PARSING $V_EVENT"
exit $E_PARSING
echo "$E_RESTART $1"
exit $E_RESTART
fi
fi

View file

@ -11,7 +11,8 @@
# Importing variables
source /etc/profile.d/vesta.sh
source $VESTA/conf/vesta.conf
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
#----------------------------------------------------------#
@ -22,7 +23,8 @@ if [ "$DNS_SYSTEM" = 'bind' ]; then
/etc/init.d/named reload >/dev/null 2>&1
if [ $? -ne 0 ]; then
#$V_FUNC/report_issue 'sys' 'cron'
echo "$E_RESTART_FAILED $V_EVENT"
echo "$E_RESTART $1"
exit $E_RESTART
fi
fi

View file

@ -18,7 +18,8 @@ apache() {
/etc/init.d/httpd 'graceful' >/dev/null 2>&1
if [ $? -ne 0 ]; then
#$V_FUNC/report_issue 'web' 'apache'
echo "$E_RESTART_FAILED $V_EVENT"
echo "$E_RESTART $1"
exit $E_RESTART
fi
}
@ -26,7 +27,8 @@ nginx() {
/etc/init.d/nginx 'reload' >/dev/null 2>&1
if [ $? -ne 0 ]; then
#$V_FUNC/report_issue 'web' 'nginx'
echo "$E_RESTART_FAILED $V_EVENT"
echo "$E_RESTART $1"
exit $E_RESTART
fi
}
@ -37,11 +39,11 @@ nginx() {
# Checking system
if [ "$WEB_SYSTEM" = 'apache' ]; then
apache
apache $1
fi
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
nginx
nginx $1
fi

162
bin/v_restore_user Executable file
View file

@ -0,0 +1,162 @@
#!/bin/bash
# info: restore user
# options: user backup
#
# The function for resotring user from backup.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
backup=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $V_FUNC/db.func
# 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 $V_CONF/ftp.backup.conf
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
[ -z "$BPATH" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSING $V_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 $V_EVENT"
exit $E_FTP
fi
}
#----------------------------------------------------------#
# 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
format_validation 'user' 'backup'
# Checking backup system is enabled
is_system_enabled 'backup'
# Checking load averages
la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.')
i=0
while [ "$la" -ge "$V_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 $V_EVENT"
exit $E_LA
fi
(( ++i))
done
# Checking local backup existance
if [ ! -e "$V_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 $V_BACKUP
echo "$(date "+%F %T") Downloading ftp backup"
ftpc "get $user.$backup.tar" >> /dev/null 2>/dev/null
echo "$(date "+%F %T") Downloaded $user.$backup.tar"
fi
fi
fi
if [ ! -e "$V_BACKUP/$user.$backup.tar" ]; then
echo "Error: $V_BACKUP/$user.$backup.tar backup not found"
log_event 'debug' "$E_NOTEXIST $V_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 #
#----------------------------------------------------------#
# Creating temporary directory
tmpdir=$(mktemp -p $V_BACKUP -d)
echo "TMPDIR is $tmpdir"
cd $tmpdir
echo "$(date "+%F %T") Extracting files from backup"
tar -xf $V_BACKUP/$user.$backup.tar
echo "$(date "+%F %T") Backup has been unpacked"
# Checking Vesta
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit

View file

@ -129,7 +129,8 @@ for user in $user_list; do
check_month=$(grep -n "DATE='$DATE'" $billing|cut -f 1 -d :)
if [ -z "$check_month" ]; then
# Updating as there no dublicates
echo "$v_str" >>$billing
echo "$v_str" >> $billing
chmod 660 $billing
else
# Replacing string with new data
sed -i "$check_month s/.*/$v_str/" $billing
@ -137,6 +138,7 @@ for user in $user_list; do
else
# Creating billing log
echo "$v_str" >$billing
chmod 660 $billing
fi
done

View file

@ -54,7 +54,7 @@ is_web_domain_value_exist '$STATS'
stats=$(get_web_domain_value '$STATS')
# Checking config
config="$V_HOME/$user/conf/$stats.$domain.conf"
config="$V_HOME/$user/conf/web/$stats.$domain.conf"
if [ ! -e "$config" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSING $V_EVENT"

View file

@ -52,3 +52,4 @@ E_SSH=16
E_DB=17
E_RRD=18
E_UPDATE=19
E_RESTART=20

View file

@ -136,7 +136,6 @@ update_domain_zone() {
# Definigng variables
line=$(grep "DOMAIN='$domain'" $V_USERS/$user/dns.conf)
fields='$RECORD\t$TTL\tIN\t$TYPE\t$VALUE'
conf="/etc/namedb/$domain.db"
# Checking serial
if [ -e $conf ]; then
@ -187,7 +186,6 @@ update_domain_zone() {
VALUE=$(idn --quiet -a -t "$VALUE")
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
done < $V_USERS/$user/dns/$domain
}
get_next_dns_record() {
@ -749,10 +747,10 @@ upd_web_domain_values() {
fi
# Defining SSL vars
ssl_crt="$V_HOME/$user/conf/ssl.$domain.crt"
ssl_key="$V_HOME/$user/conf/ssl.$domain.key"
ssl_pem="$V_HOME/$user/conf/ssl.$domain.pem"
ssl_ca="$V_HOME/$user/conf/ssl.$domain.ca"
ssl_crt="$V_HOME/$user/conf/web/ssl.$domain.crt"
ssl_key="$V_HOME/$user/conf/web/ssl.$domain.key"
ssl_pem="$V_HOME/$user/conf/web/ssl.$domain.pem"
ssl_ca="$V_HOME/$user/conf/web/ssl.$domain.ca"
if [ ! -e "$V_USERS/$user/ssl/$domain.ca" ]; then
ssl_ca_str='#'
fi

View file

@ -675,7 +675,7 @@ get_user_value() {
restart_schedule() {
type="$1"
if [ -z "$RESTART_PERIOD" ]; then
$V_BIN/v_restart_"$type"
$V_BIN/v_restart_"$type" "$V_EVENT"
else
echo "$type" >> $V_QUEUE/restart.pipe
fi