Merge branch 'master' of github.com:serghey-rodin/vesta

This commit is contained in:
Dima Malishev 2011-08-21 20:26:56 +03:00
commit c80f12eaa4
41 changed files with 603 additions and 107 deletions

View file

@ -60,7 +60,7 @@ case $type in
new_str="$new_str MAX_DB='$max_db' U_SYS_USERS=''";
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";;
pgsql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'";
new_str="$new_str PORT='$port' TPL='$tpl'";
new_str="$new_str PORT='$port' TPL='$template'";
new_str="$new_str MAX_USERS='$max_usr' MAX_DB='$max_db'";
new_str="$new_str U_SYS_USERS=''";
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";;

View file

@ -59,7 +59,7 @@ v_str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month"
v_str="$v_str' WDAY='$wday' CMD='$command' SUSPEND='no' DATE='$V_DATE'"
# Adding to crontab
echo "$v_str">>$V_USERS/$user/crontab.conf
echo "$v_str">>$V_USERS/$user/cron.conf
# Sorting jobs by id
sort_cron_jobs

View file

@ -118,7 +118,7 @@ echo "v_upd_sys_user_disk $user" >> $V_QUEUE/disk.pipe
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
mkdir $V_USERS/$user/cert
touch $V_USERS/$user/web_domains.conf
touch $V_USERS/$user/web.conf
echo "v_upd_web_domains_traff $user" >> $V_QUEUE/traffic.pipe
echo "v_upd_web_domains_disk $user" >> $V_QUEUE/disk.pipe
fi
@ -140,7 +140,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
fi
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
touch $V_USERS/$user/crontab.conf
touch $V_USERS/$user/cron.conf
fi
if [ ! -z "$BACKUP_SYSTEM" ] && [ "$BACKUP_SYSTEM" != 'no' ]; then

View file

@ -183,11 +183,11 @@ v_str="$v_str TPL='$template'"
v_str="$v_str ALIAS='$aliases'"
v_str="$v_str $template_data" # Inserting PHP,CGI and ELOG keys
v_str="$v_str STATS='' STATS_AUTH=''"
v_str="$v_str SSL='no' SSL_HOME='' SSL_CERT=''"
v_str="$v_str SSL_HOME='' SSL_CERT=''"
v_str="$v_str NGINX='' NGINX_EXT='' SUSPEND='no' DATE='$V_DATE'"
# Registering domain
echo "$v_str" >>$V_USERS/$user/web_domains.conf
echo "$v_str" >>$V_USERS/$user/web.conf
# Adding task to the vesta pipe
restart_schedule 'web'

407
bin/v_backup_sys_user Executable file
View file

@ -0,0 +1,407 @@
#!/bin/bash
# info: backup system user with all its objects
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user="$1"
output="$2"
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared_func.sh
source $V_FUNC/domain_func.sh
source $V_FUNC/db_func.sh
source $V_CONF/vesta.conf
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user [output]'
# Checking argument format
format_validation 'user'
# Checking backup system is enabled
is_system_enabled 'backup'
# Checking user
is_user_valid
# Checking user backups
is_backup_enabled
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Creating temporary random directory
tmpdir=$(mktemp -p $V_TMP -d)
# Prinitng status
if [ -z "$output" ]; then
echo "$(date +%m-%d-%y" "%H:%m:%S) System backup for user $user"
echo
echo "VESTA VERSION $VERSION"
echo "BACKUP VERSION 1.0"
echo "TMPDIR is $tmpdir"
echo
fi
# Addding vesta version
echo "1.0" >$tmpdir/backup_version
echo "$VERSION" > $tmpdir/vesta_version
# Checking excludes
OLD_IFS="$IFS"
IFS=$'\n'
if [ -e "$V_USERS/$user/backup.excludes" ]; then
if [ -z "$output" ]; then
echo "-- Excludes --"
fi
for exclude in $(cat $V_USERS/$user/backup.excludes); do
if [ -z "$output" ]; then
echo -e "\t $exclude"
fi
# Indirect variable references (a bit of black magic)
eval ${exclude%%=*}=${exclude#*=}
done
if [ -z "$output" ]; then
echo
fi
fi
IFS="$OLD_IFS"
# WEB domains
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ] && [ "$WEB" != '*' ]
then
if [ -z "$output" ]; then
echo "-- WEB --"
fi
mkdir $tmpdir/web/
# Parsing unsuspeneded domains
conf="$V_USERS/$user/web.conf"
field='$DOMAIN'
search_string='DOMAIN='
domains=$(dom_clear_search)
domain_list=''
# Cleaning excludes
for domain in $domains; do
check_exl=$(echo "$WEB"|grep -w $domain)
if [ -z "$check_exl" ]; then
web_list="$web_list $domain"
fi
done
for domain in $web_list; do
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) $domain"
fi
# Defining domain variables
domain_idn=$(idn -t --quiet -a "$domain")
tpl_name=$(get_web_domain_value '$TPL')
ssl_cert=$(get_web_domain_value '$SSL_CERT')
nginx=$(get_web_domain_value '$NGINX')
# Building directory tree
mkdir -p $tmpdir/web/$domain/conf $tmpdir/web/$domain/cert
# Packing data folders
cd $V_HOME/$user/web/$domain
tar -cf $tmpdir/web/$domain/$domain.tar \
public_html public_shtml private document_errors cgi-bin stats
# Creating web.config
cd $tmpdir/web/$domain/
conf="$V_USERS/$user/web.conf"
grep "DOMAIN='$domain'" $conf > conf/web.conf
# Apache config
if [ "$WEB_SYSTEM" = 'apache' ]; then
# Parsing httpd.conf
tpl_file="$V_WEBTPL/apache_$tpl_name.tpl"
conf="$V_HOME/$user/conf/httpd.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf
# SSL check
if [ ! -z "$ssl_cert" ]; then
tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
conf="$V_HOME/$user/conf/shttpd.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf
fi
fi
# Nginx config
if [ ! -z "$nginx" ] ; then
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
# SSL check
if [ ! -z "$ssl_cert" ] ; then
tpl_file="$V_WEBTPL/ngingx_vhost_$nginx.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf
fi
fi
# Suplemental configs
for sconfig in $(ls $V_HOME/$user/conf/|grep ".$domain.conf"); do
cp $V_HOME/$user/conf/$sconfig conf/
done
# SSL Certificates
if [ ! -z "$ssl_cert" ] ; then
cp $V_HOME/$user/conf/$ssl_cert.* cert/
fi
tar -rf $tmpdir/web/$domain/$domain.tar conf cert
mv $tmpdir/web/$domain/$domain.tar $tmpdir/web/
rm -rf $tmpdir/web/$domain
if [ ! -z "$V_BACKUP_GZIP" ]; then
gzip -$V_BACKUP_GZIP $tmpdir/web/$domain.tar
fi
done
if [ -z "$output" ]; then
echo
fi
fi
# DNS domains
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ] && [ "$DNS" != '*' ]
then
if [ -z "$output" ]; then
echo "-- DNS --"
fi
mkdir $tmpdir/dns/
# Parsing unsuspeneded domains
conf="$V_USERS/$user/dns.conf"
field='$DOMAIN'
search_string='DOMAIN='
domains=$(dom_clear_search)
# Cleaning excludes
for domain in $domains; do
check_exl=$(echo "$DNS"|grep -w $domain)
if [ -z "$check_exl" ]; then
dns_list="$dns_list $domain"
fi
done
for domain in $dns_list; do
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) $domain"
fi
# Building directory tree
mkdir $tmpdir/dns/$domain
# Creating dns_domains config
cd $tmpdir/dns/$domain/
conf="$V_USERS/$user/dns.conf"
grep "DOMAIN='$domain'" $conf > dns.conf
# Backingup dns recods
cp $V_USERS/$user/zones/$domain $domain
cp /etc/namedb/$domain.db $domain.db
done
if [ -z "$output" ]; then
echo
fi
fi
# Mail domains
# TBD
# DatbaBases
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then
if [ -z "$output" ]; then
echo "-- DB --"
fi
mkdir $tmpdir/db/
# Parsing unsuspeneded domains
conf="$V_USERS/$user/db.conf"
field='$DB'
search_string='DB='
dbs=$(dom_clear_search)
# Cleaning excludes
for database in $dbs; do
check_exl=$(echo "$DB"|grep -w $database)
if [ -z "$check_exl" ]; then
db_list="$db_list $database"
fi
done
for database in $db_list; do
type=$(get_db_value '$TYPE')
host=$(get_db_value '$HOST')
db_user=$(get_db_value '$USER')
dump="$tmpdir/db/$database.$type.sql"
grants="$tmpdir/db/$database.$type.$db_user"
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) $database $type"
fi
case $type in
mysql) dump_db_mysql ;;
pgsql) dump_db_pgsql ;;
esac
if [ ! -z "$V_BACKUP_GZIP" ]; then
gzip -$V_BACKUP_GZIP $dump
fi
done
if [ -z "$output" ]; then
echo
fi
fi
# Cron jobs
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ] && [ "$CRON" != '*' ]
then
if [ -z "$output" ]; then
echo "-- CRON --"
fi
mkdir $tmpdir/cron/
# Backingup cron recods
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) cron.conf"
fi
cp $V_USERS/$user/cron.conf $tmpdir/cron/
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) system cron"
fi
cp /var/spool/cron/$user $tmpdir/cron/
if [ -z "$output" ]; then
echo
fi
fi
# SSL CERTIFICATES
if [ ! -z "$WEB_SSL" ] && [ "$WEB_SSL" != 'no' ] && [ "$SSL" != '*' ]; then
if [ -z "$output" ]; then
echo "-- CERTIFICATES --"
fi
mkdir $tmpdir/cert
# Backingup ssl certificates
for cert in $(ls $V_USERS/$user/cert/); do
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) $cert"
fi
cp $V_USERS/$user/cert/$cert $tmpdir/cert/
done
if [ -z "$output" ]; then
echo
fi
fi
# Vesta
if [ -z "$output" ]; then
echo "-- VESTA --"
fi
mkdir $tmpdir/vesta
# Backingup vesta configs
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) user.conf"
fi
cp -r $V_USERS/$user/user.conf $tmpdir/vesta/
if [ -e "$V_USERS/$user/billing.log" ]; then
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) billing.log"
fi
cp -r $V_USERS/$user/billing.log $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/reseller.conf" ]; then
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) reseller.conf"
fi
cp -r $V_USERS/$user/reseller.conf $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/history.log" ]; then
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) history.log"
fi
cp -r $V_USERS/$user/history.log $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/backup.excludes" ]; then
if [ -z "$output" ]; then
echo -e "\t$(date +%H:%m:%S) backup.excludes"
fi
cp -r $V_USERS/$user/backup.excludes $tmpdir/vesta/
fi
if [ -z "$output" ]; then
echo
fi
# Move tmp backup to local storage
if [ "$BACKUP_SYSTEM" = 'local' ]; then
if [ -z "$output" ]; then
echo "ARCHIVE $V_BACKUP/$user.$V_DATE.tar"
fi
# Checking retention
check_ret=$()
cd $tmpdir
tar -cf $V_BACKUP/$user.$V_DATE.tar .
fi
cd /
rm -rf $tmpdir
if [ -z "$output" ]; then
echo
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
exit $OK

View file

@ -59,7 +59,7 @@ v_str="$v_str MONTH='$month' DAY='$day' CMD='$command' SUSPEND='no'"
del_cron_job
# Adding to crontab
echo "$v_str">>$V_USERS/$user/crontab.conf
echo "$v_str">>$V_USERS/$user/cron.conf
# Sorting jobs by id
sort_cron_jobs

View file

@ -101,13 +101,13 @@ rm -rf /var/log/httpd/domains/$domain.error*
del_web_domain
# Checking last ssl domain
ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web_domains.conf | wc -l)
ssl_dom=$(grep -v "SSL_CERT=''" $V_USERS/$user/web.conf | wc -l)
if [ "$ssl_dom" -eq '0' ]; then
sed -i "s/ Include /#Include /" $V_HOME/$user/conf/httpd.conf
fi
# Checking last domain
domains=$(wc -l $V_USERS/$user/web_domains.conf|cut -f 1 -d ' ')
domains=$(wc -l $V_USERS/$user/web.conf|cut -f 1 -d ' ')
if [ "$domains" -eq '0' ]; then
conf='/etc/httpd/conf.d/vesta.conf'
line=$(grep -n "$V_HOME/$user/conf/httpd.conf" $conf | cut -f 1 -d : )

View file

@ -8,6 +8,7 @@
# Argument defenition
user="$1"
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain" )
dom_alias=$(idn -t --quiet -u "$3" )
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
@ -44,14 +45,13 @@ is_domain_suspended 'web_domains'
# Checking alias is added
cur_alias=$(get_web_domain_value '$ALIAS')
check_alias=$(echo $cur_alias|grep -w "$dom_alias")
check_alias=$(echo ${cur_alias//,/ }|grep -w "$dom_alias")
if [ -z "$check_alias" ]; then
echo "Error: alias not exist"
log_event 'debug' "$E_DOM_NOTEXIST $V_EVENT"
exit $E_DOM_NOTEXIST
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#

View file

@ -77,7 +77,7 @@ update_web_domain_value '$NGINX_EXT' ''
# Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web_domains.conf)
last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
last_snginx=$(echo "$last_nginx" | grep -v "SSL_CERT=''")
if [ -z "$last_snginx" ]; then
sline=$(grep -n "$V_HOME/$user/conf/snginx.conf" $conf | cut -f 1 -d : )

View file

@ -71,7 +71,7 @@ update_web_domain_value '$SSL_HOME' ''
update_web_domain_value '$SSL_CERT' ''
# Checking last ssl domain
ssl_dom=$(grep -v "SSL_CERT=''" $V_USERS/$user/web_domains.conf)
ssl_dom=$(grep -v "SSL_CERT=''" $V_USERS/$user/web.conf)
main_conf='/etc/httpd/conf.d/vesta.conf'
conf="$V_HOME/$user/conf/shttpd.conf"
if [ -z "$ssl_dom" ]; then
@ -83,7 +83,7 @@ fi
decrease_user_value "$user" '$U_WEB_SSL'
# Checking cert parents
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
field='$DOMAIN'
search_string="SSL_CERT='$cert'"
cert_parents=$(dom_clear_search)

View file

@ -36,7 +36,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/crontab.conf"
conf="$V_USERS/$user/cron.conf"
# Defining fileds to select
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPEND $DATE'

View file

@ -36,7 +36,7 @@ is_web_domain_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS

View file

@ -35,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG $STATS

View file

@ -35,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $ALIAS'

View file

@ -35,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $ELOG'

View file

@ -35,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $NGINX'

View file

@ -35,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $SSL $SSL_HOME $SSL_CERT'

View file

@ -35,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
fields='$DOMAIN $STATS $STATS_AUTH'

View file

@ -40,7 +40,7 @@ is_user_suspended
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining search string
search_string="DOMAIN"

View file

@ -33,7 +33,7 @@ is_user_valid
#----------------------------------------------------------#
# Searching jobs
conf="$V_USERS/$user/crontab.conf"
conf="$V_USERS/$user/cron.conf"
field='$JOB'
search_string="SUSPEND='no'"
jobs=$(cron_clear_search)

View file

@ -39,7 +39,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
field='$DOMAIN'

View file

@ -33,7 +33,7 @@ is_user_valid
#----------------------------------------------------------#
# Searching jobs
conf="$V_USERS/$user/crontab.conf"
conf="$V_USERS/$user/cron.conf"
field='$JOB'
search_string="SUSPEND='yes'"
jobs=$(cron_clear_search)

View file

@ -36,7 +36,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
field='$DOMAIN'

View file

@ -58,7 +58,7 @@ for user in $user_list; do
U_DISK_WEB_DOMAINS=''
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
field='$DOMAIN'

View file

@ -36,7 +36,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
field='$DOMAIN'

View file

@ -36,7 +36,7 @@ is_user_valid "$user"
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Defining fileds to select
field='$DOMAIN'

View file

@ -20,11 +20,12 @@ V_IPS="$V_DATA/ips"
V_WEBTPL="$V_DATA/templates"
V_DNSTPL="$V_WEBTPL/dns"
V_LOCK=/var/lock/vesta
V_EXE="$VESTA_BIN/vesta"
V_HOME='/home'
V_TMP='/tmp'
V_BACKUP='/backup'
# Other vars
V_BACKUP_GZIP='5'
V_SUSPEND_URL='vestacp.com/faq/acc_suspended/'
V_SCRIPT=$(basename $0)
V_EVENT="$(date +%m-%d-%y" "%H:%m:%S) $V_SCRIPT $*"

View file

@ -34,7 +34,7 @@
SSLCertificateFile %ssl_cert%
SSLCertificateKeyFile %ssl_key%
Include %home%/%user%/conf/%domain%.shttpd.*
Include %home%/%user%/conf/shttpd.%domain%.conf*
</VirtualHost>

View file

@ -28,7 +28,7 @@
AllowOverride All
</Directory>
php_admin_value open_basedir %home%/%user%/web:%home%/%user%/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp
Include %home%/%user%/conf/%domain%.httpd.*
Include %home%/%user%/conf/httpd.%domain%.conf*
</VirtualHost>

View file

@ -34,7 +34,7 @@
SSLCertificateFile %ssl_cert%
SSLCertificateKeyFile %ssl_key%
Include %home%/%user%/conf/%domain%.shttpd.*
Include %home%/%user%/conf/shttpd.%domain%.conf*
</VirtualHost>

View file

@ -24,7 +24,7 @@
<Directory %home%/%user%/web/%domain%/stats>
AllowOverride All
</Directory>
Include %home%/%user%/conf/%domain%.httpd.*
Include %home%/%user%/conf/httpd.%domain%.conf*
</VirtualHost>

View file

@ -34,7 +34,7 @@
SSLCertificateFile %ssl_cert%
SSLCertificateKeyFile %ssl_key%
Include %home%/%user%/conf/%domain%.shttpd.*
Include %home%/%user%/conf/shttpd.%domain%.conf*
</VirtualHost>

View file

@ -28,7 +28,7 @@
AllowOverride All
</Directory>
php_admin_value open_basedir none
Include %home%/%user%/conf/%domain%.httpd.*
Include %home%/%user%/conf/httpd.%domain%.conf*
</VirtualHost>

View file

@ -30,6 +30,6 @@ server {
location ~ /\.ht {deny all;}
location ~ /.svn/ {deny all;}
include %home%/%user%/conf/%domain%.nginx.*;
include %home%/%user%/conf/snginx.%domain%.conf*;
}

View file

@ -27,6 +27,6 @@ server {
location ~ /\.ht {deny all;}
location ~ /.svn/ {deny all;}
include %home%/%user%/conf/%domain%.nginx.*;
include %home%/%user%/conf/nginx.%domain%.conf*;
}

View file

@ -65,7 +65,7 @@ is_cert_valid() {
is_cert_used() {
# Parsing config
check_cert=$(grep "SSL_CERT='$cert'" $V_USERS/$user/web_domains.conf)
check_cert=$(grep "SSL_CERT='$cert'" $V_USERS/$user/web.conf)
# Checking result
if [ ! -z "$check_cert" ]; then

View file

@ -1,6 +1,6 @@
get_next_cron_string() {
# Parsing config
curr_str=$(grep "JOB=" $V_USERS/$user/crontab.conf|cut -f 2 -d \'|\
curr_str=$(grep "JOB=" $V_USERS/$user/cron.conf|cut -f 2 -d \'|\
sort -n|tail -n1)
# Print result
@ -9,7 +9,7 @@ get_next_cron_string() {
is_cron_job_free() {
# Checking record id
check_job=$(grep "JOB='$job'" $V_USERS/$user/crontab.conf)
check_job=$(grep "JOB='$job'" $V_USERS/$user/cron.conf)
if [ ! -z "$check_job" ]; then
echo "Error: job exist"
@ -20,7 +20,7 @@ is_cron_job_free() {
sort_cron_jobs() {
# Defining conf
conf="$V_USERS/$user/crontab.conf"
conf="$V_USERS/$user/cron.conf"
cat $conf |sort -n -k 2 -t \' >$conf.tmp
mv -f $conf.tmp $conf
}
@ -38,7 +38,7 @@ sync_cron_jobs() {
echo "MAILTO=$email" >$conf
fi
# Reading user crontab.conf
# Reading user cron.conf
while read line ; do
# Defining new delimeter
IFS=$'\n'
@ -53,12 +53,12 @@ sync_cron_jobs() {
echo "$MIN $HOUR $DAY $MONTH $WDAY $CMD" |\
sed -e "s/%quote%/'/g" -e "s/%dots%/:/g" >> $conf
fi
done <$V_USERS/$user/crontab.conf
done <$V_USERS/$user/cron.conf
}
is_job_valid() {
result=$(grep "JOB='$job'" $V_USERS/$user/crontab.conf)
result=$(grep "JOB='$job'" $V_USERS/$user/cron.conf)
if [ -z "$result" ]; then
echo "Error: job not exists"
@ -68,8 +68,8 @@ is_job_valid() {
}
del_cron_job() {
str=$(grep -n "JOB='$job'" $V_USERS/$user/crontab.conf|cut -f 1 -d :)
sed -i "$str d" $V_USERS/$user/crontab.conf
str=$(grep -n "JOB='$job'" $V_USERS/$user/cron.conf|cut -f 1 -d :)
sed -i "$str d" $V_USERS/$user/cron.conf
}
crn_json_list() {
@ -163,7 +163,7 @@ crn_shell_list() {
is_job_suspended() {
# Parsing jobs
str=$(grep "JOB='$job'" $V_USERS/$user/crontab.conf|grep "SUSPEND='yes'" )
str=$(grep "JOB='$job'" $V_USERS/$user/cron.conf|grep "SUSPEND='yes'" )
# Checkng key
if [ ! -z "$str" ]; then
@ -175,7 +175,7 @@ is_job_suspended() {
is_job_unsuspended() {
# Parsing jobs
str=$(grep "JOB='$job'" $V_USERS/$user/crontab.conf|grep "SUSPEND='no'" )
str=$(grep "JOB='$job'" $V_USERS/$user/cron.conf|grep "SUSPEND='no'" )
# Checkng key
if [ ! -z "$str" ]; then
@ -190,7 +190,7 @@ update_cron_job_value() {
value="$2"
# Defining conf
conf="$V_USERS/$user/crontab.conf"
conf="$V_USERS/$user/cron.conf"
# Parsing conf
job_str=$(grep -n "JOB='$job'" $conf)

View file

@ -432,7 +432,7 @@ create_db_pgsql() {
$sql "CREATE ROLE $db_user WITH LOGIN PASSWORD '$db_password'"
$sql "GRANT ALL PRIVILEGES ON DATABASE $database TO $db_user"
export PGPASSWORD='pgsqk'
export PGPASSWORD='pgsql'
}
is_db_host_new() {
@ -563,7 +563,7 @@ change_db_pgsql_password() {
fi
$sql "ALTER ROLE $db_user WITH LOGIN PASSWORD '$db_password'" >/dev/null
export PGPASSWORD='pgsqk'
export PGPASSWORD='pgsql'
}
get_db_value() {
@ -670,7 +670,7 @@ del_db_pgsql() {
else
$sql "REVOKE ALL PRIVILEGES ON $database FROM $db_user">/dev/null
fi
export PGPASSWORD='pgsqk'
export PGPASSWORD='pgsql'
}
@ -687,6 +687,77 @@ del_db_vesta() {
sed -i "$string d" $conf
}
dump_db_mysql() {
# Defining vars
host_str=$(grep "HOST='$host'" $V_DB/mysql.conf)
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
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1; code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
fi
# Dumping database
$dumper $dump $database
# Dumping user grants
$sql "SHOW GRANTS FOR $db_user@localhost" | grep -v "Grants for" > $grants
$sql "SHOW GRANTS FOR $db_user@'%'" | grep -v "Grants for" >> $grants
}
dump_db_pgsql() {
# Defining vars
host_str=$(grep "HOST='$host'" $V_DB/pgsql.conf)
for key in $host_str; do
eval ${key%%=*}=${key#*=}
done
export PGPASSWORD="$PASSWORD"
sql="psql -h $HOST -U $USER -d $TPL -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
echo "Error: config is broken"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# Checking connection
$sql "SELECT VERSION()" >/dev/null 2>&1;code="$?"
if [ '0' -ne "$code" ]; then
echo "Error: Connect failed"
log_event 'debug' "$E_DBHOST_UNAVAILABLE $V_EVENT"
exit $E_DBHOST_UNAVAILABLE
fi
# Dumping database
$dumper $dump $database
# Dumping user grants
md5=$($sql "SELECT rolpassword FROM pg_authid WHERE rolname='$db_user';")
md5=$(echo "$md5" | head -n 1 | cut -f 2 -d ' ')
pw_str="UPDATE pg_authid SET rolpassword='$md5' WHERE rolname='$db_user';"
gr_str="GRANT ALL PRIVILEGES ON DATABASE $database to '$db_user'"
echo -e "$pw_str\n$gr_str" >> $grants
export PGPASSWORD='pgsql'
}
is_db_host_free() {
# Defining vars
host_str=$(grep "HOST='$host'" $V_DB/$type.conf)
@ -801,7 +872,7 @@ suspend_db_pgsql() {
# Suspending user
$sql "REVOKE ALL PRIVILEGES ON $database FROM $db_user">/dev/null
export PGPASSWORD='pgsqk'
export PGPASSWORD='pgsql'
}
unsuspend_db_mysql() {
@ -859,7 +930,7 @@ unsuspend_db_pgsql() {
# Unsuspending user
$sql "GRANT ALL PRIVILEGES ON DATABASE $database TO $db_user" >/dev/null
export PGPASSWORD='pgsqk'
export PGPASSWORD='pgsql'
}
db_clear_search() {
@ -946,9 +1017,10 @@ get_disk_db_pgsql() {
fi
# Raw query
raq_query=$($sql "SELECT pg_database_size('$database');")
raw_size=$(echo raq_query | grep -v "-" | grep -v 'row' | sed -e "/^$/d"|\
awk '{print $1}')
raw_size=$(echo "$raq_query" | grep -v "-" | grep -v 'row' |\
sed -e "/^$/d" |grep -v "pg_database_size" | awk '{print $1}')
# Checking null output (this means error btw)
if [ -z "$raw_size" ]; then
@ -956,7 +1028,7 @@ get_disk_db_pgsql() {
fi
# Converting to MB
size=$(expr $raw_size \ 1048576)
size=$(expr $raw_size / 1048576)
# Rounding zero size
if [ "$size" -eq '0' ]; then

View file

@ -5,11 +5,11 @@ is_domain_new() {
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$search_dom'" $V_USERS/*/*.conf| \
grep -v crontab.conf)
grep -v cron.conf)
# Parsing alias values
check_alias=$(grep -F 'ALIAS=' $V_USERS/*/*.conf | \
grep -v crontab.conf | \
grep -v cron.conf | \
awk -F "ALIAS=" '{print $2}' | \
cut -f 2 -d \' | \
sed -e "s/,/\n/g" | \
@ -63,10 +63,10 @@ is_dns_domain_free() {
is_web_domain_free() {
search_dom=${1-$domain}
# Parsing domain values
check_domain=$(grep -F "IN='$search_dom'" $V_USERS/$user/web_domains.conf)
check_domain=$(grep -F "IN='$search_dom'" $V_USERS/$user/web.conf)
# Parsing alias values
check_alias=$(grep -F 'ALIAS=' $V_USERS/$user/web_domains.conf | \
check_alias=$(grep -F 'ALIAS=' $V_USERS/$user/web.conf | \
awk -F "ALIAS=" '{print $2}' | \
cut -f 2 -d \' | \
sed -e "s/,/\n/g" | \
@ -94,7 +94,7 @@ is_dns_domain_valid() {
is_web_domain_valid() {
# Parsing domain values
check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/web_domains.conf)
check_domain=$(grep -F "DOMAIN='$domain'" $V_USERS/$user/web.conf)
# Checking result
if [ -z "$check_domain" ]; then
@ -243,24 +243,33 @@ add_web_config() {
>> $conf
}
change_web_config() {
get_web_config_brds() {
# Defining template borders
serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
last_line=$(wc -l $tpl_file | cut -f 1 -d ' ')
if [ -z "$serv_line" ]; then
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
return $E_PARSE_ERROR
fi
# Template lines
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
bfr_line=$((serv_line - 1))
aftr_line=$((last_line - serv_line - 1))
# Config lines
str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
top_line=$((str - serv_line + 1))
bottom_line=$((top_line + last_line -1))
}
change_web_config() {
# Get config borders
get_web_config_brds || exit $?
# Parsing config
vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
# Checking parsing result
if [ -z "$str" ] || [ -z "$serv_line" ] || [ -z "$aftr_line" ]; then
echo "Error: config parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# Parsing string position and content
str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=')
str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=')
@ -279,7 +288,7 @@ get_web_domain_value() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web_domains.conf )
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web.conf )
# Parsing key=value
for keys in $string; do
@ -316,7 +325,7 @@ update_web_domain_value() {
value="$2"
# Defining conf
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Parsing conf
domain_str=$(grep -n "DOMAIN='$domain'" $conf)
@ -377,7 +386,7 @@ is_web_domain_key_empty() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web_domains.conf )
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web.conf )
# Parsing key=value
for keys in $string; do
@ -410,7 +419,7 @@ is_web_domain_value_exist() {
key="$1"
# Parsing domains
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web_domains.conf )
string=$( grep "DOMAIN='$domain'" $V_USERS/$user/web.conf )
# Parsing key=value
for keys in $string; do
@ -452,25 +461,10 @@ is_dns_domain_value_exist() {
del_web_config() {
# Get servername line in template
serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
# Get last template line
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
# Parsing config
str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
# Checking result
if [ -z "$str" ] || [ -z "$serv_line" ]; then
echo "Error: httpd parsing error"
log_event 'debug' "$E_PARSE_ERROR $V_EVENT"
exit $E_PARSE_ERROR
fi
# Get config borders
get_web_config_brds || exit $?
# Deleting lines from config
top_line=$((str - serv_line + 1))
bottom_line=$((top_line + last_line -1))
sed -i "$top_line,$bottom_line d" $conf
}
@ -489,7 +483,7 @@ del_dns_domain() {
}
del_web_domain() {
conf="$V_USERS/$user/web_domains.conf"
conf="$V_USERS/$user/web.conf"
# Parsing domains
string=$( grep -n "DOMAIN='$domain'" $conf | cut -f 1 -d : )

View file

@ -188,7 +188,7 @@ decrease_ip_value() {
new_web=$((current_web - 1))
# -1 user
check_ip=$(grep $sip $V_USERS/$user/web_domains.conf |wc -l)
check_ip=$(grep $sip $V_USERS/$user/web.conf |wc -l)
if [ "$check_ip" -lt 2 ]; then
new_usr=$(echo "$current_usr" |\
sed -e "s/,/\n/g"|\

View file

@ -7,7 +7,7 @@ log_event() {
# Checking logging system
log_system=$(grep 'LOG_SYSTEM=' $V_CONF/vesta.conf | cut -f 2 -d \' )
if [ "$log_system" = 'on' ]; then
if [ "$log_system" = 'yes' ]; then
# Checking logging level
log=$(grep 'LOG_LEVEL=' $V_CONF/vesta.conf|\
cut -f 2 -d \'|grep -w "$level" )
@ -342,7 +342,7 @@ is_system_enabled() {
web_system=$(grep "WEB_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$web_system" ] || [ "$web_system" = "off" ]; then
if [ -z "$web_system" ] || [ "$web_system" = "no" ]; then
echo "Error: web hosting support disabled"
log_event 'debug' "$E_WEB_DISABLED $V_EVENT"
exit $E_WEB_DISABLED
@ -366,7 +366,7 @@ is_system_enabled() {
dns_system=$(grep "DNS_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$dns_system" ] || [ "$cron_system" = "off" ]; then
if [ -z "$dns_system" ] || [ "$cron_system" = "no" ]; then
echo "Error: dns support disabled"
log_event 'debug' "$E_DNS_DISABLED $V_EVENT"
exit $E_DNS_DISABLED
@ -378,7 +378,7 @@ is_system_enabled() {
cron_system=$(grep "CRON_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$cron_system" ] || [ "$cron_system" = "off" ]; then
if [ -z "$cron_system" ] || [ "$cron_system" = "no" ]; then
echo "Error: crond support disabled"
log_event 'debug' "$E_CRON_DISABLED $V_EVENT"
exit $E_CRON_DISABLED
@ -390,19 +390,32 @@ is_system_enabled() {
db_system=$(grep "DB_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$db_system" ] || [ "$db_system" = "off" ]; then
if [ -z "$db_system" ] || [ "$db_system" = "no" ]; then
echo "Error: db support disabled"
log_event 'debug' "$E_DB_DISABLED $V_EVENT"
exit $E_DB_DISABLED
fi
}
backup_function() {
# Parsing config
bck_system=$(grep "BACKUP_SYSTEM=" $V_CONF/vesta.conf|cut -f 2 -d \' )
# Checking result
if [ -z "$bck_system" ] || [ "$bck_system" = "no" ]; then
echo "Error: backup support disabled"
log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT"
exit $E_BACKUP_DISABLED
fi
}
case $stype in
web) web_function ;;
proxy) proxy_function ;;
dns) dns_function ;;
cron) cron_function ;;
db) db_function ;;
backup) backup_function ;;
*) check_args '1' '0' 'system'
esac
}
@ -440,7 +453,7 @@ is_package_full() {
web_domain() {
# Checking zero domains
domain_number=$(wc -l $V_USERS/$user/web_domains.conf|cut -f 1 -d ' ')
domain_number=$(wc -l $V_USERS/$user/web.conf|cut -f 1 -d ' ')
# Comparing current val with conf
val=$(grep '^WEB_DOMAINS=' $V_USERS/$user/user.conf|cut -f 2 -d \' )
@ -453,7 +466,7 @@ is_package_full() {
web_alias() {
# Parsing aliases
alias_nmb=$(grep "DOMAIN='$domain'" $V_USERS/$user/web_domains.conf|\
alias_nmb=$(grep "DOMAIN='$domain'" $V_USERS/$user/web.conf|\
awk -F "ALIAS=" '{print $2}' | cut -f 2 -d \' |\
sed -e "s/,/\n/g" | wc -l )
@ -476,7 +489,7 @@ is_package_full() {
fi
# Checking domains
domain_nmb=$(grep "SSL='yes'" $V_USERS/$user/web_domains.conf | wc -l)
domain_nmb=$(grep "SSL='yes'" $V_USERS/$user/web.conf | wc -l)
# Comparing current val with conf
if [ "$domain_nmb" -ge "$val" ]; then
echo "Error: Upgrade package"
@ -1198,9 +1211,9 @@ get_usr_disk() {
size=$((size + dir_usage))
# Checking web
if [ -f "$V_USERS/$user/web_domains.conf" ]; then
if [ -f "$V_USERS/$user/web.conf" ]; then
# Using tricky way to parse configs
disk_usage=$(grep 'U_DISK=' $V_USERS/$user/web_domains.conf |\
disk_usage=$(grep 'U_DISK=' $V_USERS/$user/web.conf |\
awk -F "U_DISK='" '{print $2}'|cut -f 1 -d "'")
for disk in $disk_usage; do
size=$((size + disk))
@ -1232,7 +1245,7 @@ get_usr_disk() {
get_usr_traff() {
size='0'
conf='web_domains.conf'
conf='web.conf'
# Checking web
if [ -f "$V_USERS/$user/$conf" ]; then
@ -1351,3 +1364,12 @@ get_config_value() {
# Print value
echo "$value"
}
is_backup_enabled() {
backups=$(grep "BACKUPS='" $V_USERS/$user/user.conf |cut -f 2 -d \')
if [ -z "$backups" ] || [[ "$backups" -le '0' ]]; then
echo "Error: User backups are disabled"
log_event 'debug' "$E_BACKUP_DISABLED $V_EVENT"
exit $E_BACKUP_DISABLED
fi
}