Refactoring stage I

This commit is contained in:
Serghey Rodin 2012-03-06 22:07:06 +02:00
commit 83196f310b
173 changed files with 3132 additions and 3342 deletions

View file

@ -20,42 +20,24 @@ wday=$6
command=$7
job=$8
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/cron.func
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '7' "$#" 'user min hour day month wday command [job]'
# Checking argument format
format_validation 'user' 'min' 'hour' 'day' 'month' 'wday' 'command'
# Checking cron system
is_system_enabled 'CRON_SYSTEM'
# Checking user
is_user_valid
# Checking package
validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_package_full 'CRON_JOBS'
# Get str position
if [ -z "$job" ]; then
job=$(get_next_cron_string)
fi
# Checking id format
format_validation 'job'
# Checking job id
is_cron_job_free
get_next_cronjob
validate_format 'job'
is_object_free 'cron' 'JOB' "$job"
#----------------------------------------------------------#
@ -63,19 +45,20 @@ is_cron_job_free
#----------------------------------------------------------#
# Concatenating cron string
command=$(echo $command|sed -e "s/'/%quote%/g" -e "s/:/%dots%/g")
v_str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month"
v_str="$v_str' WDAY='$wday' CMD='$command' SUSPENDED='no' DATE='$V_DATE'"
command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g")
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month WDAY='$wday'"
str="$v_str' CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
# Adding to crontab
echo "$v_str">>$V_USERS/$user/cron.conf
echo "$str" >> $VESTA/data/users/$user/cron.conf
chmod 660 $V_USERS/$user/cron.conf
# Chaning permissions
chmod 660 $VESTA/data/users/$user/cron.conf
# Sorting jobs by id
# Sort jobs by id number
sort_cron_jobs
# Sync system cron with user
# Sync cronjobs with system crond
sync_cron_jobs
@ -84,13 +67,13 @@ sync_cron_jobs
#----------------------------------------------------------#
# Increasing cron value
increase_user_value "$user" '$U_CRON_JOBS'
increase_user_value $user '$U_CRON_JOBS'
# Adding task to the vesta pipe
restart_schedule 'cron'
# Restart crond
$BIN/v_restart_cron
# Logging
log_history "$V_EVENT" "v_delete_cron_job $user $job"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -1,5 +1,5 @@
#!/bin/bash
# info: add user reports
# info: add cron reports
# opions: user
#
# The script for enabling reports on cron tasks and administrative
@ -13,28 +13,20 @@
# Argument defenition
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/cron.func
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
validate_format 'user'
is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -42,7 +34,7 @@ is_user_suspended
#----------------------------------------------------------#
# Changing user report value
update_user_value "$user" '$REPORTS' 'yes'
update_user_value "$user" '$CRON_REPORTS' 'yes'
# Sync system cron with user
sync_cron_jobs
@ -52,11 +44,11 @@ sync_cron_jobs
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'cron'
# Restart crond
$BIN/v_restart_cron
# Logging
log_history "$V_EVENT" "v_delete_user_reports $user"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -24,45 +24,26 @@ type=$5
host=$6
encoding=${7-UTF8}
encoding=$(echo "$encoding" |tr '[:lower:]' '[:upper:]')
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '5' "$#" 'user db db_user db_password type [host] [encoding]'
# Checking argument format
format_validation 'user' 'database' 'db_user' 'db_password' 'encoding'
# Checking db system is enabled
validate_format 'user' 'database' 'db_user' 'db_password' 'encoding'
is_system_enabled 'DB_SYSTEM'
# Checking db type
is_type_valid 'db' "$type"
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
# Checking db existance
is_db_new
# Checking db host
if [ -z "$host" ]; then
host=$(get_next_db_host)
fi
is_db_host_valid
# Checking package
is_type_valid "$DB_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_free 'db' 'DB' "$database"
get_next_dbhost
is_object_valid "$type" 'DBHOST' "$host"
is_package_full 'DATABASES'
@ -81,24 +62,22 @@ esac
# Vesta #
#----------------------------------------------------------#
# Increasing db value
increase_db_value
# Increasing domain value
# Increasing counters
increase_dbhost_values
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' SUSPENDED='no' DATE='$V_DATE'"
echo "$v_str" >> $V_USERS/$user/db.conf
chmod 660 $V_USERS/$user/db.conf
v_str="$v_str CHARSET='$encoding' U_DISK='0' SUSPENDED='no' DATE='$DATE'"
echo "$v_str" >> $USER_DATA/db.conf
chmod 660 $USER_DATA/db.conf
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user $database $db_user ***** $type $host"
V_EVENT="$V_EVENT $encoding"
EVENT="$DATE $SCRIPT $user $database $db_user ***** $type $host"
EVENT="$EVENT $encoding"
# Logging
log_history "$V_EVENT" "v_delete_db_base $user $database"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_db_base $user $database"
log_event "$OK" "$EVENT"
exit

View file

@ -24,10 +24,9 @@ template=${7-template1}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
@ -39,14 +38,14 @@ args_usage='type host port db_user db_password [max_db] [tpl]'
check_args '5' "$#" "$args_usage"
# Checking argument format
format_validation 'host' 'port' 'db_user' 'db_password' 'max_db'
format_validation 'template'
validate_format 'host' 'port' 'db_user' 'db_password' 'max_db'
validate_format 'template'
# Checking db system is enabled
is_system_enabled 'DB_SYSTEM'
# Checking db type
is_type_valid 'db' "$type"
is_type_valid "$DB_SYSTEM" "$type"
# Checking host existance
is_db_host_new
@ -66,16 +65,16 @@ esac
case $type in
mysql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'";
new_str="$new_str PORT='$port' MAX_DB='$max_db' U_SYS_USERS=''";
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";;
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$DATE'";;
pgsql) new_str="HOST='$host' USER='$db_user' PASSWORD='$db_password'";
new_str="$new_str PORT='$port' TPL='$template'";
new_str="$new_str MAX_DB='$max_db' U_SYS_USERS=''";
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$V_DATE'";;
new_str="$new_str U_DB_BASES='0' ACTIVE='yes' DATE='$DATE'";;
esac
# Adding host to conf
echo "$new_str" >> $V_DB/$type.conf
chmod 660 $V_DB/$type.conf
echo "$new_str" >> $VESTA/conf/$type.conf
chmod 660 $VESTA/conf/$type.conf
#----------------------------------------------------------#
@ -83,9 +82,9 @@ chmod 660 $V_DB/$type.conf
#----------------------------------------------------------#
# Hidding db pass
V_EVENT=$(echo $V_EVENT | sed -e "s/$db_password/xxxxxx/g")
EVENT=$(echo $EVENT | sed -e "s/$db_password/xxxxxx/g")
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -26,10 +26,9 @@ soa=$6
ttl=${7-14400}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -40,16 +39,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain ip [template] [exp] [soa] [ttl]'
# Checking argument format
format_validation 'user' 'domain' 'ip' 'template' 'exp' 'ttl'
validate_format 'user' 'domain' 'ip' 'template' 'exp' 'ttl'
# Checking dns system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_new 'dns'
@ -58,8 +57,7 @@ is_domain_new 'dns'
is_package_full 'DNS_DOMAINS'
# Checking template
is_template_valid 'dns'
is_dns_template_valid
#----------------------------------------------------------#
# Action #
@ -78,7 +76,7 @@ if [ -z "$soa" ]; then
fi
# Adding zone to dns dir
cat $V_DNSTPL/$template.tpl |\
cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \
@ -90,23 +88,23 @@ cat $V_DNSTPL/$template.tpl |\
-e "s/%ns6%/$ns6/g" \
-e "s/%ns7%/$ns7/g" \
-e "s/%ns8%/$ns8/g" \
-e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain
records="$(wc -l $V_USERS/$user/dns/$domain)"
records="$(wc -l $USER_DATA/dns/$domain)"
# Adding dns.conf record
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' DATE='$V_DATE'"
echo "$dns_rec" >> $V_USERS/$user/dns.conf
chmod 660 $V_USERS/$user/dns.conf
dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' DATE='$DATE'"
echo "$dns_rec" >> $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf
# Adding zone in named.conf
named="zone \"$domain_idn\" {type master; file"
named="$named \"$V_HOME/$user/conf/dns/$domain.db\";};"
named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};"
echo "$named" >> /etc/named.conf
# Updating domain dns zone
conf="$V_HOME/$user/conf/dns/$domain.db"
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
chmod 640 $conf
@ -122,10 +120,10 @@ increase_user_value "$user" '$U_DNS_DOMAINS'
increase_user_value "$user" '$U_DNS_RECORDS' "$records"
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "v_delete_dns_domain $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_dns_domain $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -25,10 +25,9 @@ dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]')
id=$6
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -39,16 +38,16 @@ source $V_FUNC/domain.func
check_args '5' "$#" 'user domain record type value [id]'
# Checking argument format
format_validation 'user' 'domain' 'record' 'rtype' 'dvalue'
validate_format 'user' 'domain' 'record' 'rtype' 'dvalue'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -65,7 +64,7 @@ if [ -z "$id"] ; then
fi
# Checking id format
format_validation 'id'
validate_format 'id'
# Checking id
is_dns_record_free
@ -76,18 +75,18 @@ is_dns_record_free
#----------------------------------------------------------#
# Defining zone path
zone="$V_USERS/$user/dns/$domain"
zone="$USER_DATA/dns/$domain"
# Adding record
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$dvalue'"
dns_rec="$dns_rec SUSPENDED='no' DATE='$V_DATE'"
dns_rec="$dns_rec SUSPENDED='no' DATE='$DATE'"
echo "$dns_rec" >> $zone
# Sorting records
sort_dns_records
# Updating zone
conf="$V_HOME/$user/conf/dns/$domain.db"
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
@ -96,17 +95,17 @@ update_domain_zone
#----------------------------------------------------------#
# Updating dns domain values
records="$(wc -l $V_USERS/$user/dns/$domain)"
records="$(wc -l $USER_DATA/dns/$domain)"
update_domain_value 'dns' '$RECORDS' "$records"
# Updating user counters
increase_user_value "$user" '$U_DNS_RECORDS'
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "v_delete_dns_domain_record $user $domain $id"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_dns_domain_record $user $domain $id"
log_event "$OK" "$EVENT"
exit

85
bin/v_add_mail_account Executable file
View file

@ -0,0 +1,85 @@
#!/bin/bash
# info: add mail domain account
# options: user domain account password [quota]
#
# The function add new email account.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
account=$3
password=$4
quota=${5-0}
# Importing variables
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '4' "$#" 'user domain account password quota'
# Checking argument format
validate_format 'user' 'domain' 'account' 'password' 'quota'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
# Checking domain is not suspened
is_domain_suspended 'mail'
# Checking package
is_package_full 'MAIL_ACCOUNTS'
# Checking account
is_mail_account_free
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
password=$(/usr/sbin/dovecotpw -s md5 -p "$password")
str="$account:$password:$user:mail::$HOMEDIR/$user:$quota"
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
str="$str U_DISK='0' SUSPENDED='no' DATE='$DATE'"
echo "$str" >> $USER_DATA/mail/$domain.conf
# Increase mail accounts counter
accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ')
increase_user_value "$user" '$U_MAIL_ACCOUNTS'
update_domain_value 'mail' '$ACCOUNTS' "$accounts"
# Logging
EVENT="$DATE $SCRIPT $user $domain ***** $quota"
log_history "$EVENT" "v_delete_mail_account $user $domain $account"
log_event "$OK" "$EVENT"
exit

85
bin/v_add_mail_account_alias Executable file
View file

@ -0,0 +1,85 @@
#!/bin/bash
# info: add mail account alias aka nickname
# options: user domain account alias
#
# The function add new email account.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
account=$3
malias=$4
# Importing variables
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '4' "$#" 'user domain account alias'
# Checking argument format
validate_format 'user' 'domain' 'account' 'malias'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
# Checking domain is not suspened
is_domain_suspended 'mail'
# Checking account
is_mail_account_valid
# Checking account
is_mail_account_free "$malias"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Adding exim alias
str="$mailas@$domain:$account@$domain"
echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding vesta alias
aliases=$(get_domain_value "mail/$domain" '$ALIAS' "ACCOUNT='$account'")
if [ -z "$aliases" ]; then
aliases="$malias"
else
aliases="$aliases,$malias"
fi
update_domain_value "mail/$domain" '$ALIAS' "$aliases" "ACCOUNT='$account'"
# Logging
cmd='v_delete_mail_account_alias'
log_history "$EVENT" "$cmd $user $domain $account $malias"
log_event "$OK" "$EVENT"
exit

View file

@ -0,0 +1,68 @@
#!/bin/bash
# info: add mail account alias aka nickname
# options: user domain account alias
#
# The function add new email account.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
account=$3
malias=$4
# Importing variables
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '4' "$#" 'user domain account alias'
validate_format 'user' 'domain' 'account' 'malias'
is_system_enabled 'MAIL_SYSTEM'
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_suspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_suspended "mail/$domain" 'ACCOUNT' "$account"
is_key_empty "mail/$domain" '' '$AUTOREPLY'
exit
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
exit
# Adding exim alias
str="$mailas@$domain:$account@$domain"
echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Adding vesta alias
aliases=$(get_domain_value "mail/$domain" '$ALIAS' "ACCOUNT='$account'")
if [ -z "$aliases" ]; then
aliases="$malias"
else
aliases="$aliases,$malias"
fi
update_domain_value "mail/$domain" '$ALIAS' "$aliases" "ACCOUNT='$account'"
# Logging
cmd='v_delete_mail_account_alias'
log_history "$EVENT" "$cmd $user $domain $account $malias"
log_event "$OK" "$EVENT"
exit

View file

@ -20,10 +20,9 @@ dkim=${5-yes}
dkim_size=${6-512}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -34,16 +33,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain [antispam] [antivirus] [dkim] [dkim_size]'
# Checking argument format
format_validation 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size'
validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_new 'mail'
@ -57,62 +56,62 @@ is_package_full 'MAIL_DOMAINS'
#----------------------------------------------------------#
# Adding domain directory
mkdir $V_HOME/$user/conf/mail/$domain
touch $V_HOME/$user/conf/mail/$domain/aliases
touch $V_HOME/$user/conf/mail/$domain/protection
touch $V_HOME/$user/conf/mail/$domain/passwd
chown -R root:mail $V_HOME/$user/conf/mail/$domain
chmod 770 $V_HOME/$user/conf/mail/$domain
chmod 660 $V_HOME/$user/conf/mail/$domain*
mkdir $V_HOME/$user/mail/$domain
chown $user:mail $V_HOME/$user/mail/$domain
chmod 770 $V_HOME/$user/mail/$domain
mkdir $HOMEDIR/$user/conf/mail/$domain
touch $HOMEDIR/$user/conf/mail/$domain/aliases
touch $HOMEDIR/$user/conf/mail/$domain/protection
touch $HOMEDIR/$user/conf/mail/$domain/passwd
chown -R root:mail $HOMEDIR/$user/conf/mail/$domain
chmod 770 $HOMEDIR/$user/conf/mail/$domain
chmod 660 $HOMEDIR/$user/conf/mail/$domain/*
mkdir $HOMEDIR/$user/mail/$domain
chown $user:mail $HOMEDIR/$user/mail/$domain
chmod 770 $HOMEDIR/$user/mail/$domain
# Adding symlink
ln -s $V_HOME/$user/conf/mail/$domain /etc/exim/domains/
ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/
# Adding antispam protection
if [ "$antispam" = 'yes' ]; then
echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection
echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi
# Adding antivirus protection
if [ "$antivirus" = 'yes' ]; then
echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi
# Adding dkim
if [ "$dkim" = 'yes' ]; then
openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null
openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \
-out $V_USERS/$user/mail/$domain.pub 2>/dev/null
chmod 660 $V_USERS/$user/mail/$domain.*
openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null
openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \
-out $USER_DATA/mail/$domain.pub &>/dev/null
chmod 660 $USER_DATA/mail/$domain.*
cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem
chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem
chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem
cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem
chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem
chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem
# Adding dkim dns records
check_dns_domain=$(is_domain_valid 'dns')
if [ "$?" -eq 0 ]; then
p=$(cat $V_USERS/$user/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
record='_domainkey'
policy="\"t=y; o=~;\""
$V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy"
$BIN/v_add_dns_domain_record $user $domain $record TXT "$policy"
record='mail._domainkey'
selector="\"k=rsa\; p=$p\""
$V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
$BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
fi
fi
# Adding domain to vesta db
s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'"
s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' DATE='$V_DATE'"
echo $s >> $V_USERS/$user/mail.conf
touch $V_USERS/$user/mail/$domain
chmod 660 $V_USERS/$user/mail.conf
chmod 660 $V_USERS/$user/mail/$domain
s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' DATE='$DATE'"
echo $s >> $USER_DATA/mail.conf
touch $USER_DATA/mail/$domain.conf
chmod 660 $USER_DATA/mail.conf
chmod 660 $USER_DATA/mail/$domain.conf
#----------------------------------------------------------#
@ -123,7 +122,7 @@ chmod 660 $V_USERS/$user/mail/$domain
increase_user_value "$user" '$U_MAIL_DOMAINS'
# Logging
log_history "$V_EVENT" "v_delete_mail_domain $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_mail_domain $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -56,8 +55,8 @@ is_domain_key_empty 'mail' '$ANTISPAM'
#----------------------------------------------------------#
# Adding antispam key to config
if [ -z "$(grep 'antispam' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
echo 'antispam' >> $V_HOME/$user/conf/mail/$domain/protection
if [ -z "$(grep 'antispam' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then
echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi
#----------------------------------------------------------#
@ -68,7 +67,7 @@ fi
update_domain_value 'mail' '$ANTISPAM' 'yes'
# Logging
log_history "$V_EVENT" "v_delete_mail_domain_antispam $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_mail_domain_antispam $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -56,8 +55,8 @@ is_domain_key_empty 'mail' '$ANTIVIRUS'
#----------------------------------------------------------#
# Adding antivirus key to config
if [ -z "$(grep 'virus' $V_HOME/$user/conf/mail/$domain/protection)" ]; then
echo 'antivirus' >> $V_HOME/$user/conf/mail/$domain/protection
if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then
echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi
#----------------------------------------------------------#
@ -68,7 +67,7 @@ fi
update_domain_value 'mail' '$ANTIVIRUS' 'yes'
# Logging
log_history "$V_EVENT" "v_delete_mail_domain_antivirus $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_mail_domain_antivirus $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
email="$3"
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain email'
# Checking argument format
format_validation 'user' 'domain' 'email'
validate_format 'user' 'domain' 'email'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -57,8 +56,8 @@ is_domain_key_empty 'mail' '$CATCHALL'
#----------------------------------------------------------#
# Adding catchall alias
sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases
echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases
sed -i "/*@demo.vestacp.com:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
echo "*@demo.vestacp.com:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------#
@ -69,7 +68,7 @@ echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases
update_domain_value 'mail' '$CATCHALL' "$email"
# Logging
log_history "$V_EVENT" "v_delete_mail_domain_catchall $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_mail_domain_catchall $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
dkim_size=${3-512}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain [dkim_size]'
# Checking argument format
format_validation 'user' 'domain' 'dkim_size'
validate_format 'user' 'domain' 'dkim_size'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -57,28 +56,28 @@ is_domain_key_empty 'mail' '$DKIM'
#----------------------------------------------------------#
# Generating dkim
openssl genrsa -out $V_USERS/$user/mail/$domain.pem $dkim_size 2>/dev/null
openssl rsa -pubout -in $V_USERS/$user/mail/$domain.pem \
-out $V_USERS/$user/mail/$domain.pub 2>/dev/null
chmod 660 $V_USERS/$user/mail/$domain.*
openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null
openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \
-out $USER_DATA/mail/$domain.pub &>/dev/null
chmod 660 $USER_DATA/mail/$domain.*
# Adding dkim to config
cp $V_USERS/$user/mail/$domain.pem $V_HOME/$user/conf/mail/$domain/dkim.pem
chown root:mail $V_HOME/$user/conf/mail/$domain/dkim.pem
chmod 660 $V_HOME/$user/conf/mail/$domain/dkim.pem
cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem
chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem
chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem
# Checking dns domain
check_dns_domain=$(is_domain_valid 'dns')
if [ "$?" -eq 0 ]; then
# Adding dkim dns records
p=$(cat $V_USERS/$user/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
record='_domainkey'
policy="\"t=y; o=~;\""
$V_BIN/v_add_dns_domain_record $user $domain $record TXT "$policy"
$BIN/v_add_dns_domain_record $user $domain $record TXT "$policy"
record='mail._domainkey'
selector="\"k=rsa\; p=$p\""
$V_BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
$BIN/v_add_dns_domain_record $user $domain $record TXT "$selector"
fi
@ -90,7 +89,7 @@ fi
update_domain_value 'mail' '$DKIM' 'yes'
# Logging
log_history "$V_EVENT" "v_delete_mail_domain_dkim $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_mail_domain_dkim $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -23,11 +23,10 @@ ip_status="${5-shared}"
ip_name=$6
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $V_FUNC/domain.func # for namehosting
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
source $VESTA/func/domain.sh # for namehosting
#----------------------------------------------------------#
# Verifications #
@ -37,22 +36,22 @@ source $V_FUNC/domain.func # for namehosting
check_args '2' "$#" 'ip mask [interface] [user] [ip_status] [ip_name]'
# Checking argument format
format_validation 'ip' 'mask' 'interface' 'user'
validate_format 'ip' 'mask' 'interface' 'user'
# Checking system ip
is_sys_ip_free
# Checking user
is_user_valid "$user"
is_object_valid 'user' 'USER' "$user" "$user"
# Checking ip_status
if [ ! -z "$ip_status" ]; then
format_validation 'ip_status'
validate_format 'ip_status'
fi
# Checking ip_name
if [ ! -z "$ip_name" ] ; then
format_validation 'ip_name'
validate_format 'ip_name'
fi
@ -80,7 +79,7 @@ ip_add_startup
ip_add_vesta
# Importing main config
source $V_CONF/vesta.conf
source $VESTA/conf/vesta.conf
# Adding namehosting support
namehost_ip_support
@ -107,10 +106,10 @@ fi
# Adding task to the vesta pipe
if [ "$web_restart" = 'yes' ]; then
restart_schedule 'web'
$BIN/v_restart_web
fi
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -18,18 +18,17 @@ fname=$5
lname=$6
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
is_user_free() {
# Parsing domain values
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
# Checking result
if [ ! -z "$check_sysuser" ] || [ -e "$V_USERS/$user" ]; then
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
echo "Error: user $user exist"
log_event 'debug' "$E_EXISTS $V_EVENT"
log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS
fi
}
@ -43,7 +42,7 @@ is_user_free() {
check_args '3' "$#" 'user password email [package] [fname] [lname]'
# Checking argument format
format_validation 'user' 'password' 'email' 'package' 'fname' 'lname'
validate_format 'user' 'password' 'email' 'package' 'fname' 'lname'
# Checking user
is_user_free "$user"
@ -57,7 +56,7 @@ is_package_valid "$package"
#----------------------------------------------------------#
# Parsing package data
package_data=$(cat $V_PKG/$package.pkg)
package_data=$(cat $VESTA/data/packages/$package.pkg)
# Checking shell
shell_conf=$(echo "$package_data" | grep 'SHELL' | cut -f 2 -d \')
@ -69,45 +68,45 @@ case $shell_conf in
esac
# Adding user
/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$V_HOME/$user"
/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
# Adding password
echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1
echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null
# Building directory tree
mkdir $V_HOME/$user/conf
chmod 751 $V_HOME/$user/conf/web
mkdir $HOMEDIR/$user/conf
chmod 751 $HOMEDIR/$user/conf/web
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
mkdir $V_HOME/$user/conf/web
mkdir $V_HOME/$user/web
mkdir $V_HOME/$user/tmp
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
mkdir $HOMEDIR/$user/conf/web
mkdir $HOMEDIR/$user/web
mkdir $HOMEDIR/$user/tmp
chmod 751 $HOMEDIR/$user/conf/web
chmod 751 $HOMEDIR/$user/web
chmod 777 $HOMEDIR/$user/tmp
chown $user:$user $HOMEDIR/$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
mkdir $HOMEDIR/$user/conf/mail
mkdir $HOMEDIR/$user/mail
chmod 751 $HOMEDIR/$user/mail
chmod 751 $HOMEDIR/$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
mkdir $HOMEDIR/$user/conf/dns
chmod 751 $HOMEDIR/$user/conf/dns
fi
# Set permissions
chmod -R a+x $V_HOME/$user
chmod -R a+x $HOMEDIR/$user
# Checking quota
if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then
DISK_QUOTA=$(echo "$package_data" | grep 'DISK_QUOTA' | cut -f 2 -d \')
#$V_BIN/v_add_user_quota "$user" "$DISK_QUOTA"
#$BIN/v_add_user_quota "$user" "$DISK_QUOTA"
fi
@ -116,57 +115,58 @@ fi
#----------------------------------------------------------#
# Adding user dir
mkdir $V_USERS/$user
chmod 770 $V_USERS/$user
mkdir $USER_DATA
chmod 770 $USER_DATA
# Creating configuration files and pipes
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/stats.log
chmod 660 $V_USERS/$user/stats.log
touch $USER_DATA/backup.conf
chmod 660 $USER_DATA/backup.conf
touch $USER_DATA/history.log
chmod 660 $USER_DATA/history.log
touch $USER_DATA/stats.log
chmod 660 $USER_DATA/stats.log
echo "v_update_user_disk $user" >> $V_QUEUE/disk.pipe
echo "v_update_user_disk $user" >> $VESTA/data/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
mkdir $USER_DATA/ssl
chmod 770 $USER_DATA/ssl
touch $USER_DATA/web.conf
chmod 660 $USER_DATA/web.conf
echo "$BIN/v_update_web_domains_traff $user" \
>> $VESTA/data/queue/traffic.pipe
echo "v_update_web_domains_disk $user" >> $VESTA/data/queue/disk.pipe
fi
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
mkdir $V_USERS/$user/dns
chmod 770 $V_USERS/$user/dns
touch $V_USERS/$user/dns.conf
chmod 660 $V_USERS/$user/dns.conf
mkdir $USER_DATA/dns
chmod 770 $USER_DATA/dns
touch $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf
fi
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
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
mkdir $USER_DATA/mail
chmod 770 $USER_DATA/mail
touch $USER_DATA/mail.conf
chmod 660 $USER_DATA/mail.conf
echo "v_upd_mail_domains_disk $user" >> $VESTA/data/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
touch $USER_DATA/db.conf
chmod 660 $USER_DATA/db.conf
echo "v_update_db_bases_disk $user" >> $VESTA/data/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
touch $USER_DATA/cron.conf
chmod 660 $USER_DATA/cron.conf
fi
# Filling user config
if [ "$user" != 'admin' ]; then
ip_avail=$($V_BIN/v_list_user_ips admin plain |grep -w shared|wc -l)
ip_avail=$($BIN/v_list_user_ips admin plain |grep -w shared|wc -l)
u_users=0
else
ip_avail=0
@ -178,7 +178,7 @@ LNAME='$lname'
PACKAGE='$package'
$package_data
CONTACT='$email'
REPORTS='yes'
CRON_REPORTS='yes'
RKEY='$(gen_password)'
SUSPENDED='no'
SUSPENDED_USERS='0'
@ -206,8 +206,8 @@ U_MAIL_ACCOUNTS='0'
U_DATABASES='0'
U_CRON_JOBS='0'
U_BACKUPS='0'
DATE='$V_DATE'" > $V_USERS/$user/user.conf
chmod 660 $V_USERS/$user/user.conf
DATE='$DATE'" > $USER_DATA/user.conf
chmod 660 $USER_DATA/user.conf
# Updating admin counter
if [ "$user" != 'admin' ]; then
@ -215,9 +215,9 @@ if [ "$user" != 'admin' ]; then
fi
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user ***** $email $package $fname $lname"
EVENT="$DATE $SCRIPT $user ***** $email $package $fname $lname"
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -13,9 +13,8 @@
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -26,13 +25,13 @@ source $V_FUNC/shared.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking backup system is enabled
is_system_enabled 'BACKUP_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user backups
is_backup_enabled
@ -43,7 +42,7 @@ is_backup_enabled
#----------------------------------------------------------#
# Adding backup to pipe
echo "$user" >> $V_QUEUE/backup.pipe
echo "$user" >> $VESTA/data/queue/backup.pipe
#----------------------------------------------------------#
@ -51,6 +50,6 @@ echo "$user" >> $V_QUEUE/backup.pipe
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -23,11 +23,10 @@ ip=$3
template=${4-default}
# 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/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -38,16 +37,16 @@ source $V_FUNC/ip.func
check_args '3' "$#" 'user domain ip [template]'
# Checking argument format
format_validation 'user' 'domain' 'ip' 'template'
validate_format 'user' 'domain' 'ip' 'template'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_new 'dns'
@ -60,7 +59,7 @@ is_package_full 'WEB_DOMAINS'
# Checking template
templates=$(get_user_value '$WEB_TPL')
is_template_valid "web"
is_apache_template_valid
#----------------------------------------------------------#
@ -88,14 +87,14 @@ fi
# Defining vars for add_config function
group="$user"
email="$user@$domain"
docroot="$V_HOME/$user/web/$domain/public_html"
docroot="$HOMEDIR/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$V_WEBTPL/apache_$template.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$template.tpl"
# Parsing template keys
template_data=$(cat $V_WEBTPL/apache_$template.descr|grep -v '#')
template_data=$(cat $WEBTPL/apache_$template.descr|grep -v '#')
for keys in $template_data; do
eval ${keys%%=*}=${keys#*=}
done
@ -120,14 +119,14 @@ fi
add_web_config
# Building directory tree
mkdir $V_HOME/$user/web/$domain \
$V_HOME/$user/web/$domain/public_html \
$V_HOME/$user/web/$domain/public_shtml \
$V_HOME/$user/web/$domain/document_errors \
$V_HOME/$user/web/$domain/cgi-bin \
$V_HOME/$user/web/$domain/private \
$V_HOME/$user/web/$domain/stats \
$V_HOME/$user/web/$domain/logs
mkdir $HOMEDIR/$user/web/$domain \
$HOMEDIR/$user/web/$domain/public_html \
$HOMEDIR/$user/web/$domain/public_shtml \
$HOMEDIR/$user/web/$domain/document_errors \
$HOMEDIR/$user/web/$domain/cgi-bin \
$HOMEDIR/$user/web/$domain/private \
$HOMEDIR/$user/web/$domain/stats \
$HOMEDIR/$user/web/$domain/logs
# Adding domain logs
touch /var/log/httpd/domains/$domain.bytes \
@ -135,50 +134,50 @@ touch /var/log/httpd/domains/$domain.bytes \
/var/log/httpd/domains/$domain.error.log
# Adding symlink for logs
ln -s /var/log/httpd/domains/$domain.*log $V_HOME/$user/web/$domain/logs/
ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/
# Adding domain skeleton
if [ -e "$V_WEBTPL/skel/public_html/" ]; then
cp -r $V_WEBTPL/skel/public_html/ $V_HOME/$user/web/$domain/
if [ -e "$WEBTPL/skel/public_html/" ]; then
cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/
fi
if [ -e "$V_WEBTPL/skel/public_shtml/" ]; then
cp -r $V_WEBTPL/skel/public_shtml/ $V_HOME/$user/web/$domain/
if [ -e "$WEBTPL/skel/public_shtml/" ]; then
cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/
fi
if [ -e "$V_WEBTPL/skel/document_errors/" ]; then
cp -r $V_WEBTPL/skel/document_errors/ $V_HOME/$user/web/$domain/
if [ -e "$WEBTPL/skel/document_errors/" ]; then
cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/
fi
if [ -e "$V_WEBTPL/skel/cgi-bin/" ]; then
cp -r $V_WEBTPL/skel/cgi-bin/ $V_HOME/$user/web/$domain/
if [ -e "$WEBTPL/skel/cgi-bin/" ]; then
cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/
fi
# Changing tpl values
for file in $(find "$V_HOME/$user/web/$domain/" -type f); do
for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do
sed -i "s/%domain%/$domain/g" $file
done
# Changing file owner
chown -R $user:$user $V_HOME/$user/web/$domain
chown -R $user:$user $HOMEDIR/$user/web/$domain
chown root:$user /var/log/httpd/domains/$domain.*
chown root:apache $conf
# Changing file permissions
chmod 660 $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
chmod 751 $V_HOME/$user/web/$domain/public_html
chmod 751 $V_HOME/$user/web/$domain/public_shtml
chmod 751 $V_HOME/$user/web/$domain/document_errors
chmod -f -R 775 $V_HOME/$user/web/$domain/cgi-bin/*
chmod -f -R 775 $V_HOME/$user/web/$domain/public_html/*
chmod -f -R 775 $V_HOME/$user/web/$domain/document_errors/*
chmod 551 $V_HOME/$user/web/$domain/stats
chmod 551 $V_HOME/$user/web/$domain/logs
chmod 551 $HOMEDIR/$user/web/$domain
chmod 751 $HOMEDIR/$user/web/$domain/private
chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
chmod 751 $HOMEDIR/$user/web/$domain/public_html
chmod 751 $HOMEDIR/$user/web/$domain/public_shtml
chmod 751 $HOMEDIR/$user/web/$domain/document_errors
chmod -f -R 775 $HOMEDIR/$user/web/$domain/cgi-bin/*
chmod -f -R 775 $HOMEDIR/$user/web/$domain/public_html/*
chmod -f -R 775 $HOMEDIR/$user/web/$domain/document_errors/*
chmod 551 $HOMEDIR/$user/web/$domain/stats
chmod 551 $HOMEDIR/$user/web/$domain/logs
chmod 640 /var/log/httpd/domains/$domain.*
# Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then
$V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
fi
# Checking main vesta httpd config
@ -210,17 +209,17 @@ 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='single'"
v_str="$v_str NGINX='' NGINX_EXT='' SUSPENDED='no' DATE='$V_DATE'"
v_str="$v_str NGINX='' NGINX_EXT='' SUSPENDED='no' DATE='$DATE'"
# Registering domain
echo "$v_str" >> $V_USERS/$user/web.conf
chmod 660 $V_USERS/$user/web.conf
echo "$v_str" >> $USER_DATA/web.conf
chmod 660 $USER_DATA/web.conf
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_delete_web_domain $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -20,10 +20,9 @@ dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -34,16 +33,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain dom_alias'
# Checking argument format
format_validation 'user' 'domain' 'dom_alias'
validate_format 'user' 'domain' 'dom_alias'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -64,8 +63,8 @@ is_package_full 'WEB_ALIASES'
# Parsing domain values
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Parsing domain aliases
if [ -z "$ALIAS" ]; then
@ -82,23 +81,23 @@ del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
add_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
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/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
fi
@ -116,9 +115,9 @@ update_domain_value 'web' '$ALIAS' "$ALIAS"
increase_user_value "$user" '$U_WEB_ALIASES'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
log_history "$V_EVENT" "v_delete_web_domain_alias $user $domain $dom_alias"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_alias $user $domain $dom_alias"
log_event "$OK" "$EVENT"
exit

View file

@ -18,10 +18,9 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -32,16 +31,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -59,8 +58,8 @@ is_domain_key_empty 'web' '$CGI'
# Parsing domain values
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
CGI='yes'
# Preparing domain values for the template substitution
@ -72,8 +71,8 @@ add_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
add_web_config
fi
@ -87,10 +86,10 @@ fi
update_domain_value 'web' '$CGI' 'yes'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_delete_web_domain_cgi $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_cgi $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -57,8 +56,8 @@ is_domain_key_empty 'web' '$ELOG'
# Parsing domain values
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
ELOG='yes'
# Preparing domain values for the template substitution
@ -70,23 +69,23 @@ add_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
add_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
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/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
fi
@ -101,10 +100,10 @@ fi
update_domain_value 'web' '$ELOG' 'yes'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_delete_web_domain_elog $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_elog $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -20,10 +20,9 @@ pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
extentions=${4-$default_extentions}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -34,16 +33,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain [template] [extentions]'
# Checking argument format
format_validation 'user' 'domain' 'template' 'extentions'
validate_format 'user' 'domain' 'template' 'extentions'
# Checking proxy system is enabled
is_system_enabled 'proxy'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -55,7 +54,7 @@ is_domain_suspended 'web'
is_domain_key_empty 'web' '$NGINX'
# Checking template
is_template_valid "proxy"
is_nginx_template_valid
#----------------------------------------------------------#
@ -66,8 +65,8 @@ is_template_valid "proxy"
get_domain_values 'web'
NGINX="$template"
NGINX_EXT="$extentions"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Preparing domain values for the template substitution
upd_web_domain_values
@ -87,8 +86,8 @@ 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/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config
chown root:nginx $conf
@ -112,9 +111,9 @@ update_domain_value 'web' '$NGINX' "$NGINX"
update_domain_value 'web' '$NGINX_EXT' "$extentions"
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
log_history "$V_EVENT" "v_delete_web_domain_nginx $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_nginx $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -22,11 +22,10 @@ ssl_dir=$3
ssl_home=${4-single}
# 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/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -37,16 +36,16 @@ source $V_FUNC/ip.func
check_args '3' "$#" 'user domain ssl_dir [ssl_home]'
# Checking argument format
format_validation 'user' 'domain' 'ssl_dir'
validate_format 'user' 'domain' 'ssl_dir'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -66,19 +65,19 @@ is_web_domain_cert_valid
#----------------------------------------------------------#
# Adding certificate to user data directory
cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.crt
cp -f $ssl_dir/$domain.key $V_USERS/$user/ssl/$domain.key
cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.pem
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt
cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem
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
cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca
cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem
fi
chmod 660 $V_USERS/$user/ssl/$domain.*
chmod 660 $USER_DATA/ssl/$domain.*
# Parsing domain values
get_domain_values 'web'
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
SSL_HOME="$ssl_home"
# Checking ip ownership
@ -94,16 +93,16 @@ chown root:apache $conf
chmod 640 $conf
# Adding certificate to user dir
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
cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt
cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key
cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca
fi
# Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then
$V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
fi
# Checking main vesta httpd config
@ -116,8 +115,8 @@ fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf
conf="$V_HOME/$user/conf/web/snginx.conf"
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
add_web_config
chown root:nginx $conf
@ -144,7 +143,7 @@ update_domain_value 'web' '$SSL_HOME' "$SSL_HOME"
update_domain_value 'web' '$SSL' 'yes'
# Logging
log_history "$V_EVENT" "v_delete_web_domain_ssl $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_ssl $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -20,10 +20,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
type=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -34,16 +33,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain type'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid "$user"
is_object_valid 'user' 'USER' "$user" "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -52,7 +51,7 @@ is_domain_valid 'web'
is_domain_suspended 'web'
# Checking statistic type
is_type_valid 'stat' "$type"
is_type_valid "$STATS_SYSTEM" "$type"
# Check statistic is not added
is_domain_key_empty 'web' '$STATS'
@ -69,7 +68,7 @@ get_domain_values 'web'
upd_web_domain_values
# Adding statistic config
cat $V_WEBTPL/$type.tpl |\
cat $WEBTPL/$type.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
@ -78,10 +77,10 @@ cat $V_WEBTPL/$type.tpl |\
-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/%home%/${HOMEDIR////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $V_HOME/$user/conf/web/$type.$domain.conf
> $HOMEDIR/$user/conf/web/$type.$domain.conf
#----------------------------------------------------------#
@ -89,13 +88,13 @@ cat $V_WEBTPL/$type.tpl |\
#----------------------------------------------------------#
# Adding command to pipe
echo "$V_BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
echo "$BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
# Adding stats in config
update_domain_value 'web' '$STATS' "$type"
# Logging
log_history "$V_EVENT" "v_delete_web_domain_stat $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_stat $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ auth_user=$3
auth_pass=$4
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '4' "$#" 'user domain auth_user auth_password'
# Checking argument format
format_validation 'user' 'domain' 'auth_user' 'auth_pass'
validate_format 'user' 'domain' 'auth_user' 'auth_pass'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -53,7 +52,7 @@ is_domain_suspended 'web'
#----------------------------------------------------------#
# Definining statistic dir
stat_dir="$V_HOME/$user/web/$domain/stats"
stat_dir="$HOMEDIR/$user/web/$domain/stats"
# Adding htaccess file
if [ ! -e "$stat_dir/.htaccess" ]; then
@ -66,9 +65,9 @@ fi
# Generating htaccess user and password
if [ ! -e "$stat_dir/.htpasswd" ]; then
htpasswd -bc $stat_dir/.htpasswd "$auth_user" "$auth_pass" >/dev/null 2>&1
htpasswd -bc $stat_dir/.htpasswd "$auth_user" "$auth_pass" &>/dev/null
else
htpasswd -b $stat_dir/.htpasswd "$auth_user" "$auth_pass" >/dev/null 2>&1
htpasswd -b $stat_dir/.htpasswd "$auth_user" "$auth_pass" &>/dev/null
fi
@ -95,10 +94,10 @@ fi
update_domain_value 'web' '$STATS_AUTH' "$a_users"
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user $domain $auth_user *****"
EVENT="$DATE $SCRIPT $user $domain $auth_user *****"
# Logging
log_history "$V_EVENT" "v_delete_web_domain_stat_auth $user $domain $auth_user"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_delete_web_domain_stat_auth $user $domain $auth_user"
log_event "$OK" "$EVENT"
exit

View file

@ -13,11 +13,10 @@
user=$1
# 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
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
@ -28,13 +27,13 @@ source $V_FUNC/db.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking backup system is enabled
is_system_enabled 'BACKUP_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user backups
is_backup_enabled
@ -42,7 +41,7 @@ is_backup_enabled
# 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
while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
echo "$(date "+%F %T") Load Average $la"
echo
@ -50,7 +49,7 @@ while [ "$la" -ge "$V_BACKUP_LA_LIMIT" ]; do
if [ "$i" -ge "15" ]; then
echo "Error: LA is too high"
log_event 'debug' "$E_LA $V_EVENT"
log_event 'debug' "$E_LA $EVENT"
exit $E_LA
fi
@ -66,7 +65,7 @@ done
start_time=$(date '+%s')
# Creating temporary random directory
tmpdir=$(mktemp -p $V_BACKUP -d)
tmpdir=$(mktemp -p $BACKUP -d)
# Prinitng status
echo "$(date "+%F %T") System backup for user $user"
@ -87,21 +86,21 @@ mkdir $tmpdir/vesta
# Backingup vesta configs
echo -e "$(date "+%F %T") user.conf"
cp -r $V_USERS/$user/user.conf $tmpdir/vesta/
cp -r $USER_DATA/user.conf $tmpdir/vesta/
if [ -e "$V_USERS/$user/stats.log" ]; then
if [ -e "$USER_DATA/stats.log" ]; then
echo -e "$(date "+%F %T") stats.log"
cp -r $V_USERS/$user/stats.log $tmpdir/vesta/
cp -r $USER_DATA/stats.log $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/history.log" ]; then
if [ -e "$USER_DATA/history.log" ]; then
echo -e "$(date "+%F %T") history.log"
cp -r $V_USERS/$user/history.log $tmpdir/vesta/
cp -r $USER_DATA/history.log $tmpdir/vesta/
fi
if [ -e "$V_USERS/$user/backup.excludes" ]; then
if [ -e "$USER_DATA/backup.excludes" ]; then
echo -e "$(date "+%F %T") backup.excludes"
cp -r $V_USERS/$user/backup.excludes $tmpdir/vesta/
cp -r $USER_DATA/backup.excludes $tmpdir/vesta/
fi
@ -120,10 +119,10 @@ echo
# Checking excludes
OLD_IFS="$IFS"
IFS=$'\n'
if [ -e "$V_USERS/$user/backup.excludes" ]; then
if [ -e "$USER_DATA/backup.excludes" ]; then
echo "-- Excludes --"
for exclude in $(cat $V_USERS/$user/backup.excludes); do
for exclude in $(cat $USER_DATA/backup.excludes); do
echo -e "$exclude"
# Indirect variable references (a bit of black magic)
eval ${exclude%%=*}=${exclude#*=}
@ -139,7 +138,7 @@ then
mkdir $tmpdir/web/
# Parsing unsuspeneded domains
conf="$V_USERS/$user/web.conf"
conf="$USER_DATA/web.conf"
field='$DOMAIN'
search_string='DOMAIN='
domains=$(dom_clear_search)
@ -163,27 +162,27 @@ then
get_domain_values 'web'
# Packing data folders
cd $V_HOME/$user/web/$domain
cd $HOMEDIR/$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"
conf="$USER_DATA/web.conf"
grep "DOMAIN='$domain'" $conf > conf/vesta.conf
# Apache config
if [ "$WEB_SYSTEM" = 'apache' ]; then
# Parsing httpd.conf
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf
# SSL check
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf
fi
@ -191,36 +190,36 @@ then
# Nginx config
if [ ! -z "$NGINX" ] ; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
# SSL check
if [ "$SSL" = 'yes' ] ; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/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/web/|grep ".$domain.conf"); do
cp $V_HOME/$user/conf/web/$sconfig conf/
for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do
cp $HOMEDIR/$user/conf/web/$sconfig conf/
done
# SSL Certificates
if [ "$SSL" = 'yes' ] ; then
cp $V_HOME/$user/conf/web/ssl.$domain.* conf/
cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/
fi
tar -rf $tmpdir/web/$domain/$domain.tar conf
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
if [ ! -z "$BACKUP_GZIP" ]; then
gzip -$BACKUP_GZIP $tmpdir/web/$domain.tar
fi
done
@ -234,7 +233,7 @@ then
mkdir $tmpdir/dns/
# Parsing unsuspeneded domains
conf="$V_USERS/$user/dns.conf"
conf="$USER_DATA/dns.conf"
field='$DOMAIN'
search_string='DOMAIN='
domains=$(dom_clear_search)
@ -255,12 +254,12 @@ then
# Creating dns_domains config
cd $tmpdir/dns/$domain/
conf="$V_USERS/$user/dns.conf"
conf="$USER_DATA/dns.conf"
grep "DOMAIN='$domain'" $conf > dns.conf
# Backingup dns recods
cp $V_USERS/$user/dns/$domain $domain
cp $V_USERS/$user/conf/dns/$domain.db $domain.db
cp $USER_DATA/dns/$domain $domain
cp $USER_DATA/conf/dns/$domain.db $domain.db
done
echo
fi
@ -275,7 +274,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then
mkdir $tmpdir/db/
# Parsing unsuspeneded domains
conf="$V_USERS/$user/db.conf"
conf="$USER_DATA/db.conf"
field='$DB'
search_string='DB='
dbs=$(dom_clear_search)
@ -303,8 +302,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then
pgsql) dump_db_pgsql ;;
esac
if [ ! -z "$V_BACKUP_GZIP" ]; then
gzip -$V_BACKUP_GZIP $dump
if [ ! -z "$BACKUP_GZIP" ]; then
gzip -$BACKUP_GZIP $dump
fi
done
@ -319,7 +318,7 @@ then
# Backingup cron recods
echo -e "$(date "+%F %T") cron.conf"
cp $V_USERS/$user/cron.conf $tmpdir/cron/
cp $USER_DATA/cron.conf $tmpdir/cron/
echo -e "$(date "+%F %T") system cron"
if [ -e "/var/spool/cron/$user" ]; then
@ -338,17 +337,17 @@ end_time=$(date '+%s')
# Defining local storage function
local_backup(){
echo "-- STORAGE --"
echo -e "$(date "+%F %T") ARCHIVE $V_BACKUP/$user.$V_DATE.tar"
echo -e "$(date "+%F %T") ARCHIVE $BACKUP/$user.$DATE.tar"
# Removing dublicate for this day
if [ -e "$V_BACKUP/$user.$V_DATE.tar" ]; then
deprecated="$V_DATE"
echo -e "Deleting old backup for $V_DATE"
rm -f $V_BACKUP/$user.$V_DATE.tar
if [ -e "$BACKUP/$user.$DATE.tar" ]; then
deprecated="$DATE"
echo -e "Deleting old backup for $DATE"
rm -f $BACKUP/$user.$DATE.tar
fi
# Checking retention
backup_list=$(ls -lrt $V_BACKUP/ | awk '{print $9}' |grep "^$user\.")
backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.")
backups_count=$(echo "$backup_list" | wc -l)
if [ "$BACKUPS" -le "$backups_count" ]; then
@ -360,23 +359,23 @@ local_backup(){
backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//")
deprecated="$deprecated $backup_date"
echo -e "\tDeleteing old backup for $backup_date"
rm -f $V_BACKUP/$backup
rm -f $BACKUP/$backup
done
fi
# Checking disk space
disk_usage=$(df $V_BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%')
if [ "$disk_usage" -ge "$V_BACKUP_DISK_LIMIT" ]; then
disk_usage=$(df $BACKUP | awk '{print $5}'|tail -n1|cut -f 1 -d '%')
if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then
echo "Error: Not enough disk space"
log_event 'debug' "$E_DISK $V_EVENT"
log_event 'debug' "$E_DISK $EVENT"
exit $E_DISK
fi
# Creating final tarball
cd $tmpdir
tar -cf $V_BACKUP/$user.$V_DATE.tar .
chmod 640 $V_BACKUP/$user.$V_DATE.tar
chown nginx:$user $V_BACKUP/$user.$V_DATE.tar
tar -cf $BACKUP/$user.$DATE.tar .
chmod 640 $BACKUP/$user.$DATE.tar
chown nginx:$user $BACKUP/$user.$DATE.tar
localbackup='yes'
echo
}
@ -399,17 +398,17 @@ ftp_backup(){
echo "-- FTP --"
# Checking config
source $V_CONF/ftp.backup.conf
source $VESTA/conf/ftp.backup.conf
if [ -z "$HOST" ] || [ -z "$USERNAME" ] || [ -z "$PASSWORD" ] ||\
[ -z "$BPATH" ]; then
echo "Error: Parsing error"
log_event 'debug' "$E_PARSING $V_EVENT"
log_event 'debug' "$E_PARSING $EVENT"
exit $E_PARSING
fi
# Debug info
echo -ne "$(date "+%F %T") "
echo -e "ftp://$USERNAME@$HOST$BPATH/$user.$V_DATE.tar"
echo -e "ftp://$USERNAME@$HOST$BPATH/$user.$DATE.tar"
# Checking ftp permission
ftmpdir=$(mktemp -u -p $BPATH)
@ -418,7 +417,7 @@ ftp_backup(){
rm $ftmpdir"
if [ ! -z "$(ftpc "$command")" ] ; then
echo "Error: FTP error"
log_event 'debug' "$E_FTP $V_EVENT"
log_event 'debug' "$E_FTP $EVENT"
exit $E_FTP
fi
@ -437,14 +436,14 @@ ftp_backup(){
# Uploading backup archive
if [ "$localbackup" = 'yes' ]; then
cd $V_BACKUP
ftpc "put $user.$V_DATE.tar"
cd $BACKUP
ftpc "put $user.$DATE.tar"
else
cd $tmpdir
tar -cf $V_BACKUP/$user.$V_DATE.tar .
cd $V_BACKUP/
ftpc "put $user.$V_DATE.tar"
rm -f $user.$V_DATE.tar
tar -cf $BACKUP/$user.$DATE.tar .
cd $BACKUP/
ftpc "put $user.$DATE.tar"
rm -f $user.$DATE.tar
fi
echo
}
@ -484,13 +483,13 @@ echo
# Deleting old backup records
for backup_record in $deprecated; do
if [ -e "$V_USERS/$user/backup.conf" ]; then
sed -i "/DATE='$backup_record/d" $V_USERS/$user/backup.conf
if [ -e "$USER_DATA/backup.conf" ]; then
sed -i "/DATE='$backup_record/d" $USER_DATA/backup.conf
fi
done
# Concatenating string
backup_str="DATE='$V_DATE' TIME='$current_time' RUNTIME='$run_time'"
backup_str="DATE='$DATE' TIME='$current_time' RUNTIME='$run_time'"
backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
backup_str="$backup_str VESTA='$vst'"
backup_str="$backup_str PAM='$pam'"
@ -499,10 +498,10 @@ backup_str="$backup_str DNS='${dns_list// /,}'"
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
echo "$backup_str" >> $USER_DATA/backup.conf
chmod 660 $USER_DATA/backup.conf
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,9 +14,8 @@
source /etc/profile.d/vesta.sh
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -27,7 +26,7 @@ user_list=$(ls $V_USERS/)
# Updating user billing
for user in $user_list; do
$V_BIN/v_backup_user $user >> $V_LOG/backup.log 2>> $V_LOG/backup.log
$BIN/v_backup_user $user &>> $VESTA/logs/backup.log
done
#----------------------------------------------------------#
@ -35,6 +34,6 @@ done
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -20,52 +20,37 @@ month=$6
wday=$7
command=$8
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/cron.func
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '7' "$#" 'user job min hour day month wday command'
validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job"
# Checking argument format
format_validation 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
# Checking cron system
is_system_enabled 'CRON_SYSTEM'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
# Checking cron job
is_job_valid
# Checking job is active
# is_job_suspended
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Concatenating cron string
command=$(echo $command|sed -e "s/'/%quote%/g" -e "s/:/%dots%/g")
v_str="JOB='$job' MIN='$min' HOUR='$hour' WDAY='$wday'"
v_str="$v_str MONTH='$month' DAY='$day' CMD='$command' SUSPENDED='no'"
command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g")
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month WDAY='$wday'"
str="$v_str' CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
# Deleting job
del_cron_job
# Deleting old job
sed -i "/JOB='$job' /d" $USER_DATA/cron.conf
# Adding to crontab
echo "$v_str">>$V_USERS/$user/cron.conf
# Adding new
echo "$v_str" >> $USER_DATA/cron.conf
# Sorting jobs by id
sort_cron_jobs
@ -78,11 +63,11 @@ sync_cron_jobs
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'cron'
# Restart crond
$BIN/v_restart_cron
# Logging
log_history "$V_EVENT"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ database=$2
db_password=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/db.func
check_args '3' "$#" 'user db_name db_password'
# Checking argument format
format_validation 'user' 'database' 'db_password'
validate_format 'user' 'database' 'db_password'
# Checking db system is enabled
is_system_enabled 'DB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking db existance
is_db_valid
@ -69,9 +68,9 @@ esac
#----------------------------------------------------------#
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user $database *****"
EVENT="$DATE $SCRIPT $user $database *****"
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
exp=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain exp'
# Checking argument format
format_validation 'user' 'domain' 'exp'
validate_format 'user' 'domain' 'exp'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -65,7 +64,7 @@ update_domain_value 'dns' '$EXP' "$exp"
#----------------------------------------------------------#
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_exp"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_exp"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
@ -29,16 +28,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain ip'
# Checking argument format
format_validation 'user' 'domain' 'ip'
validate_format 'user' 'domain' 'ip'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -58,7 +57,7 @@ old_ip=$(get_domain_value 'dns' '$IP')
update_domain_value 'dns' '$IP' "$ip"
# Changing records
sed -i "s/$old_ip/$ip/g" $V_USERS/$user/dns/$domain
sed -i "s/$old_ip/$ip/g" $USER_DATA/dns/$domain
# Updating zone
update_domain_zone
@ -69,10 +68,10 @@ update_domain_zone
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_ip"
log_event "$OK" "$EVENT"
exit

View file

@ -19,10 +19,9 @@ rtype=$(echo "$5"| tr '[:lower:]' '[:upper:]')
value=$(idn -t --quiet -u "$6" )
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -33,16 +32,16 @@ source $V_FUNC/domain.func
check_args '5' "$#" 'user domain id record type value'
# Checking argument format
format_validation 'user' 'domain' 'id' 'record' 'rtype'
validate_format 'user' 'domain' 'id' 'record' 'rtype'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -58,7 +57,7 @@ is_dns_record_valid
#----------------------------------------------------------#
# Defining zone path
zone="$V_USERS/$user/dns/$domain"
zone="$USER_DATA/dns/$domain"
# Deleting old record
rm_string=$(grep -n "^ID='$id'" $zone|cut -d : -f 1)
@ -68,7 +67,7 @@ fi
# Adding record
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' VALUE='$value'"
dns_rec="$dns_rec SUSPENDED='no' DATE='$V_DATE'"
dns_rec="$dns_rec SUSPENDED='no' DATE='$DATE'"
echo "$dns_rec" >> $zone
# Sorting records
@ -83,10 +82,10 @@ update_domain_zone
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
soa=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain soa'
# Checking argument format
format_validation 'user' 'domain' 'soa'
validate_format 'user' 'domain' 'soa'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -67,10 +66,10 @@ update_domain_zone
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_soa"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_soa"
log_event "$OK" "$EVENT"
exit

View file

@ -18,10 +18,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
template=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -32,16 +31,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain template'
# Checking argument format
format_validation 'user' 'domain' 'template'
validate_format 'user' 'domain' 'template'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -50,7 +49,7 @@ is_domain_valid 'dns'
is_domain_suspended 'dns'
# Checking template
is_template_valid 'dns'
is_dns_template_valid
#----------------------------------------------------------#
@ -65,7 +64,7 @@ ns2=$(get_user_value '$NS2')
# Changing tpl
update_domain_value 'dns' '$TPL' "$template"
cat $V_DNSTPL/$template.tpl |\
cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \
@ -77,10 +76,10 @@ cat $V_DNSTPL/$template.tpl |\
-e "s/%ns6%/$ns6/g" \
-e "s/%ns7%/$ns7/g" \
-e "s/%ns8%/$ns8/g" \
-e "s/%date%/$V_DATE/g" > $V_USERS/$user/dns/$domain
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain
# Updating zone
conf="$V_HOME/$user/conf/dns/$domain.db"
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
@ -89,10 +88,10 @@ update_domain_zone
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_tpl"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_tpl"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
ttl=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain ttl'
# Checking argument format
format_validation 'user' 'domain' 'ttl'
validate_format 'user' 'domain' 'ttl'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -67,10 +66,10 @@ update_domain_zone
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ttl"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_ttl"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
email="$3"
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain email'
# Checking argument format
format_validation 'user' 'domain' 'email'
validate_format 'user' 'domain' 'email'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -57,8 +56,8 @@ is_domain_suspended 'mail'
catchall=$(get_domain_value 'mail' '$CATCHALL')
# Change cathcall alias
sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases
echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases
sed -i "/*@demo.vestacp.com:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
echo "*@demo.vestacp.com:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------#
@ -69,7 +68,7 @@ echo "*@demo.vestacp.com:$email" >> $V_HOME/$user/conf/mail/$domain/aliases
update_domain_value 'mail' '$CATCHALL' "$email"
# Logging
log_history "$V_EVENT" "v_change_mail_domain_catchall $user $domain $catchall"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_change_mail_domain_catchall $user $domain $catchall"
log_event "$OK" "$EVENT"
exit

View file

@ -15,9 +15,8 @@ key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
value=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -28,13 +27,13 @@ source $V_FUNC/shared.func
check_args '2' "$#" 'key value'
# Checking argument format
format_validation 'key'
validate_format 'key'
# Checking key existance
check_ckey=$(grep "^$key='" $V_CONF/vesta.conf)
check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf)
if [ -z "$check_ckey" ]; then
echo "Error: key not found"
log_event 'debug' "$E_INVALID $V_EVENT"
log_event 'debug' "$E_INVALID $EVENT"
exit $E_INVALID
fi
@ -44,7 +43,7 @@ fi
#----------------------------------------------------------#
# Updating conf
sed -i "s/$key=.*/$key='$value'/g" $V_CONF/vesta.conf
sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf
#----------------------------------------------------------#
@ -52,6 +51,6 @@ sed -i "s/$key=.*/$key='$value'/g" $V_CONF/vesta.conf
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,10 +14,9 @@ ip=$1
ip_name=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -28,7 +27,7 @@ source $V_FUNC/ip.func
check_args '2' "$#" 'ip ip_name'
# Checking argument format
format_validation 'ip' 'ip_name'
validate_format 'ip' 'ip_name'
# Checking system ip
is_sys_ip_valid
@ -47,6 +46,6 @@ update_sys_ip_value '$NAME' "$ip_name"
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,10 +14,9 @@ ip=$1
user=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -28,13 +27,13 @@ source $V_FUNC/ip.func
check_args '2' "$#" 'ip user'
# Checking argument format
format_validation 'ip' 'user'
validate_format 'ip' 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking system ip
is_sys_ip_valid
@ -90,6 +89,6 @@ fi
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,10 +14,9 @@ ip=$1
ip_status=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -28,7 +27,7 @@ source $V_FUNC/ip.func
check_args '2' "$#" 'ip ip_status'
# Checking argument format
format_validation 'ip' 'ip_status'
validate_format 'ip' 'ip_status'
# Checking system ip
is_sys_ip_valid
@ -37,7 +36,7 @@ is_sys_ip_valid
current_status=$(get_sys_ip_value '$STATUS')
if [ "$ip_status" = "$current_status" ]; then
echo "Error: status is already set"
log_event 'debug' "$E_EXISTS $V_EVENT"
log_event 'debug' "$E_EXISTS $EVENT"
exit $E_EXISTS
fi
@ -49,7 +48,7 @@ ip_owner=$(get_sys_ip_value '$OWNER')
# Checking condition
if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
echo "Error: ip is used"
log_event 'debug' "$E_INUSE $V_EVENT"
log_event 'debug' "$E_INUSE $EVENT"
exit $E_INUSE
fi
@ -67,6 +66,6 @@ update_sys_ip_value '$STATUS' "$ip_status"
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,9 +14,8 @@ user=$1
email=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/shared.func
check_args '2' "$#" 'user email'
# Checking argument format
format_validation 'user' 'email'
validate_format 'user' 'email'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -57,7 +56,7 @@ sed -i "$str s/$old_email/$email/g" /etc/passwd
#----------------------------------------------------------#
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $old_email"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $old_email"
log_event "$OK" "$EVENT"
exit

View file

@ -15,9 +15,8 @@ fname=$2
lname=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -28,13 +27,13 @@ source $V_FUNC/shared.func
check_args '3' "$#" 'user fname lname'
# Checking argument format
format_validation 'user' 'fname' 'lname'
validate_format 'user' 'fname' 'lname'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -55,7 +54,7 @@ update_user_value "$user" '$LNAME' "$lname"
#----------------------------------------------------------#
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $old_fname $old_lname"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $old_fname $old_lname"
log_event "$OK" "$EVENT"
exit

View file

@ -21,9 +21,8 @@ ns7=$8
ns8=$9
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -34,36 +33,36 @@ source $V_FUNC/shared.func
check_args '3' "$#" 'user ns1 ns2 [ns3] [ns4] [ns5] [ns6] [ns7] [ns8]'
# Checking argument format
format_validation 'user' 'ns1' 'ns2'
validate_format 'user' 'ns1' 'ns2'
if [ ! -z "$ns3" ]; then
format_validation 'ns3'
validate_format 'ns3'
fi
if [ ! -z "$ns4" ]; then
format_validation 'ns4'
validate_format 'ns4'
fi
if [ ! -z "$ns5" ]; then
format_validation 'ns5'
validate_format 'ns5'
fi
if [ ! -z "$ns6" ]; then
format_validation 'ns6'
validate_format 'ns6'
fi
if [ ! -z "$ns7" ]; then
format_validation 'ns7'
validate_format 'ns7'
fi
if [ ! -z "$ns8" ]; then
format_validation 'ns8'
validate_format 'ns8'
fi
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -86,7 +85,7 @@ update_user_value "$user" '$NS' "$ns"
#----------------------------------------------------------#
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user ${old_ns//,/ }"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user ${old_ns//,/ }"
log_event "$OK" "$EVENT"
exit

View file

@ -14,13 +14,12 @@ user=$1
package=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
is_package_avalable() {
# Parsing user data
usr_data=$(cat $V_USERS/$user/user.conf)
usr_data=$(cat $USER_DATA/user.conf)
IFS=$'\n'
for key in $usr_data; do
eval ${key%%=*}=${key#*=}
@ -35,7 +34,7 @@ is_package_avalable() {
BANDWIDTH='0'
# Parsing package
pkg_data=$(cat $V_PKG/$package.pkg)
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
for key in $pkg_data; do
eval ${key%%=*}=${key#*=}
done
@ -56,11 +55,11 @@ is_package_avalable() {
change_user_package() {
# Parsing user data
usr_data=$(cat $V_USERS/$user/user.conf)
usr_data=$(cat $USER_DATA/user.conf)
eval $usr_data
# Parsing package
pkg_data=$(cat $V_PKG/$package.pkg)
pkg_data=$(cat $VESTA/data/packages/$package.pkg)
eval $pkg_data
echo "FNAME='$FNAME'
@ -81,7 +80,7 @@ NS='$NS'
SHELL='$SHELL'
BACKUPS='$BACKUPS'
CONTACT='$CONTACT'
REPORTS='$REPORTS'
CRON_REPORTS='$CRON_REPORTS'
RKEY='$RKEY'
SUSPENDED='$SUSPENDED'
SUSPENDED_USERS='$SUSPENDED_USERS'
@ -109,7 +108,7 @@ U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS'
U_DATABASES='$U_DATABASES'
U_CRON_JOBS='$U_CRON_JOBS'
U_BACKUPS='$U_BACKUPS'
DATE='$DATE'" > $V_USERS/$user/user.conf
DATE='$DATE'" > $USER_DATA/user.conf
}
@ -121,10 +120,10 @@ DATE='$DATE'" > $V_USERS/$user/user.conf
check_args '2' "$#" 'user package'
# Checking argument format
format_validation 'user' 'package'
validate_format 'user' 'package'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking package
is_package_valid
@ -146,6 +145,6 @@ change_user_package
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,9 +14,8 @@ user=$1
password=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/shared.func
check_args '2' "$#" 'user password'
# Checking argument format
format_validation 'user' 'password'
validate_format 'user' 'password'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -41,7 +40,7 @@ is_user_suspended
#----------------------------------------------------------#
# Changing user password
echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1
echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null
#----------------------------------------------------------#
@ -52,9 +51,9 @@ echo "$password" | /usr/bin/passwd "$user" --stdin >/dev/null 2>&1
update_user_value "$user" '$RKEY' "$(gen_password)"
# Hiding password
V_EVENT="$V_DATE $V_SCRIPT $user *****"
EVENT="$DATE $SCRIPT $user *****"
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,9 +14,8 @@ user=$1
shell=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/shared.func
check_args '2' "$#" 'user shell'
# Checking argument format
format_validation 'user' 'shell'
validate_format 'user' 'shell'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -44,7 +43,7 @@ is_user_suspended
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
# Changing passwd file
/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
@ -56,6 +55,6 @@ shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" )
update_user_value "$user" '$SHELL' "$shell"
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -17,11 +17,10 @@ domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
# 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/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -32,16 +31,16 @@ source $V_FUNC/ip.func
check_args '3' "$#" 'user domain ip'
# Checking argument format
format_validation 'user' 'domain' 'ip'
validate_format 'user' 'domain' 'ip'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -59,30 +58,30 @@ is_ip_avalable
# Define variable for replace
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
old=$IP
new=$ip
replace_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
replace_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
replace_web_config
fi
# Checking nginx
if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
replace_web_config
fi
@ -101,10 +100,10 @@ decrease_ip_value "$old"
update_domain_value 'web' '$IP' "$new"
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ip"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_ip"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
ssl_dir=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain ssl_dir'
# Checking argument format
format_validation 'user' 'domain' 'ssl_dir'
validate_format 'user' 'domain' 'ssl_dir'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -60,26 +59,26 @@ is_web_domain_cert_valid
#----------------------------------------------------------#
# Deleting old certificate
tmpdir=$(mktemp -p $V_HOME/$user/web/$domain/private -d)
rm -f $V_HOME/$user/conf/ssl.$domain.*
mv $V_USERS/$user/ssl/$domain.* $tmpdir
tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d)
rm -f $HOMEDIR/$user/conf/ssl.$domain.*
mv $USER_DATA/ssl/$domain.* $tmpdir
chown -R $user:$user $tmpdir
# Adding new certificate to user data directory
cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.crt
cp -f $ssl_dir/$domain.key $V_USERS/$user/ssl/$domain.key
cp -f $ssl_dir/$domain.crt $V_USERS/$user/ssl/$domain.pem
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt
cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem
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
cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca
cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem
fi
# Adding new 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
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 $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt
cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/ssl.$domain.key
cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca
fi
@ -88,10 +87,10 @@ fi
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $tmpdir"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $tmpdir"
log_event "$OK" "$EVENT"
exit

View file

@ -12,10 +12,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
ssl_home=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -26,16 +25,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain ssl_home'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -55,15 +54,15 @@ is_domain_value_exist 'web' '$SSL'
get_domain_values 'web'
old_ssl_home=$SSL_HOME
SSL_HOME=$ssl_home
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/shttpd.conf"
# Parsing tpl_option
case $SSL_HOME in
single) new="$V_HOME/$user/web/$domain/public_shtml" ;
old="$V_HOME/$user/web/$domain/public_html" ;;
same) new="$V_HOME/$user/web/$domain/public_html" ;
old="$V_HOME/$user/web/$domain/public_shtml" ;;
single) new="$HOMEDIR/$user/web/$domain/public_shtml" ;
old="$HOMEDIR/$user/web/$domain/public_html" ;;
same) new="$HOMEDIR/$user/web/$domain/public_html" ;
old="$HOMEDIR/$user/web/$domain/public_shtml" ;;
*) check_args '3' "2" 'user domain sslhome'
esac
@ -72,8 +71,8 @@ replace_web_config
# Checking nginx config
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/snginx.conf"
replace_web_config
fi
@ -86,10 +85,10 @@ fi
update_domain_value 'web' '$SSL_HOME' "$SSL_HOME"
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "$V_SCRIPT $user $domain $old_ssl_home"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$SCRIPT $user $domain $old_ssl_home"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
template=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain template'
# Checking argument format
format_validation 'user' 'domain' 'template'
validate_format 'user' 'domain' 'template'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -50,7 +49,7 @@ is_domain_suspended 'web'
# Checking template
templates=$(get_user_value '$WEB_TPL')
is_template_valid "web"
is_apache_template_valid
#----------------------------------------------------------#
@ -61,15 +60,15 @@ is_template_valid "web"
get_domain_values 'web'
# Deleting domain
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
tpl_file="$WEBTPL/apache_$TPL.tpl"
old_tpl=$TPL
conf="$V_HOME/$user/conf/web/httpd.conf"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
del_web_config
# Deleting ssl vhost
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
fi
@ -77,10 +76,10 @@ fi
ip=$IP
email="$user@$domain"
group="$user"
docroot="$V_HOME/$user/web/$domain/public_html"
docroot="$HOMEDIR/$user/web/$domain/public_html"
docroot_string="DocumentRoot $docroot"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$V_WEBTPL/apache_$template.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$template.tpl"
# Parsing domain aliases
@ -124,7 +123,7 @@ IFS=$OLD_IFS
# Parsing new template
template_data=$(cat $V_WEBTPL/apache_$template.descr | grep -v '#')
template_data=$(cat $WEBTPL/apache_$template.descr | grep -v '#')
for keys in $template_data; do
eval ${keys%%=*}=${keys#*=}
done
@ -140,34 +139,34 @@ fi
add_web_config
# Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then
$V_WEBTPL/apache_$template.sh $user $domain $ip $V_HOME $docroot
if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
# Defining SSL vars
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/web/ssl/$domain.ca" ]; then
ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
if [ ! -e "$USER_DATA/web/ssl/$domain.ca" ]; then
ssl_ca_str='#'
fi
case $SSL_HOME in
single) docroot="$V_HOME/$user/web/$domain/public_shtml" ;;
same) docroot="$V_HOME/$user/web/$domain/public_html" ;;
single) docroot="$HOMEDIR/$user/web/$domain/public_shtml" ;;
same) docroot="$HOMEDIR/$user/web/$domain/public_html" ;;
esac
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$template.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$template.stpl"
# Adding domain to the httpd.conf
add_web_config
# Running template trigger
if [ -x $V_WEBTPL/apache_$template.sh ]; then
$V_WEBTPL/apache_$template.sh \
"$user" "$domain" "$ip" "$V_HOME" "$docroot"
if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh \
"$user" "$domain" "$ip" "$HOMEDIR" "$docroot"
fi
fi
@ -180,17 +179,17 @@ fi
update_domain_value 'web' '$TPL' "$template"
# Updating db keys
for keys in $(cat $V_WEBTPL/apache_$template.descr|grep -v '#'); do
for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
key=$(echo "$keys"| cut -f 1 -d '=' |sed -e "s/^/\$/g")
value=$(echo "$keys" |cut -f 2 -d \')
update_domain_value 'web' "$key" "$value"
done
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_change_web_domain_tpl $user $domain $old_tpl"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_change_web_domain_tpl $user $domain $old_tpl"
log_event "$OK" "$EVENT"
exit

View file

@ -13,31 +13,22 @@
user=$1
job=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/cron.func
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '2' "$#" 'user job'
# Checking argument format
format_validation 'user' 'job'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
# Checking cron job
is_job_valid
validate_format 'user' 'job'
is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job"
is_object_suspended 'cron' 'JOB' "$job"
#----------------------------------------------------------#
@ -45,7 +36,7 @@ is_job_valid
#----------------------------------------------------------#
# Deleting job
del_cron_job
sed -i "/JOB='$job' /d" $USER_DATA/cron.conf
# Sorting jobs by id
sort_cron_jobs
@ -61,10 +52,11 @@ sync_cron_jobs
# Decreasing cron value
decrease_user_value "$user" '$U_CRON_JOBS'
# Adding task to the vesta pipe
restart_schedule 'cron'
# Restart crond
$BIN/v_restart_cron
# Logging
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -1,5 +1,5 @@
#!/bin/bash
# info: delete user reports
# info: delete cron reports
# options: user
#
# The script for disabling reports on cron tasks and administrative
@ -13,28 +13,20 @@
# Argument defenition
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/cron.func
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking arg number
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
# Checking user is active
is_user_suspended
validate_format 'user'
is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -42,7 +34,7 @@ is_user_suspended
#----------------------------------------------------------#
# Changing user report value
update_user_value "$user" '$REPORTS' 'no'
update_user_value "$user" '$CRON_REPORTS' 'no'
# Sync system cron with user
sync_cron_jobs
@ -52,11 +44,11 @@ sync_cron_jobs
# Vesta #
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'cron'
# Restart crond
$BIN/v_restart_cron
# Logging
log_history "$V_EVENT" "v_add_user_reports $user"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ user=$1
database=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
@ -29,16 +28,16 @@ source $V_FUNC/db.func
check_args '2' "$#" 'user db_name'
# Checking argument format
format_validation 'user' 'database'
validate_format 'user' 'database'
# Checking db system is enabled
is_system_enabled 'DB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking db existance
is_db_valid
@ -77,6 +76,6 @@ decrease_user_value "$user" '$U_DATABASES'
del_db_vesta
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -13,10 +13,9 @@
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/db.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking web system is enabled
is_system_enabled 'DB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -41,7 +40,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/db.conf"
conf="$USER_DATA/db.conf"
# Defining fileds to select
field='$DB'
@ -54,10 +53,10 @@ databases=$(db_clear_search)
# Starting delete loop
for database in $databases; do
$V_BIN/v_delete_db_base "$user" "$database"
$BIN/v_delete_db_base "$user" "$database"
rv="$?"
if [ "$rv" -ne '0' ]; then
log_event 'debug' "$rv $V_EVENT"
log_event 'debug' "$rv $EVENT"
exit $rv
fi
done
@ -68,6 +67,6 @@ done
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ type=$1
host=$2
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
#----------------------------------------------------------#
@ -29,13 +28,13 @@ source $V_FUNC/db.func
check_args '2' "$#" 'type host'
# Checking argument format
format_validation 'host'
validate_format 'host'
# Checking db system is enabled
is_system_enabled 'DB_SYSTEM'
# Checking db type
is_type_valid 'db' "$type"
is_type_valid "$DB_SYSTEM" "$type"
# Checking host existance
is_db_host_valid
@ -57,6 +56,6 @@ del_dbhost_vesta
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(idn -t --quiet -u "$2" )
named_conf=/etc/named.conf
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -52,7 +51,7 @@ is_domain_valid 'dns'
# Get domain values
tpl_name=$(get_domain_value 'dns' '$TPL')
old_ip=$(get_domain_value 'dns' '$IP')
records=$(wc -l $V_USERS/$user/dns/$domain|cut -f 1 -d ' ')
records=$(wc -l $USER_DATA/dns/$domain|cut -f 1 -d ' ')
# Deleting domain in named.conf
rm_string=$(grep -n /conf/dns/$domain.db $named_conf |cut -d : -f 1)
@ -60,8 +59,8 @@ if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $named_conf
fi
if [ -e "$V_HOME/$user/conf/dns/$domain.db" ]; then
rm -f $V_HOME/$user/conf/dns/$domain.db
if [ -e "$HOMEDIR/$user/conf/dns/$domain.db" ]; then
rm -f $HOMEDIR/$user/conf/dns/$domain.db
fi
@ -70,18 +69,18 @@ fi
#----------------------------------------------------------#
# Deleting domain
sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/dns.conf
rm -f $V_USERS/$user/dns/$domain
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf
rm -f $USER_DATA/dns/$domain
# Decreasing domain value
decrease_user_value "$user" '$U_DNS_DOMAINS'
decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_history "$V_EVENT" "v_add_dns_domain $user $domain $old_ip $tpl_name"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_dns_domain $user $domain $old_ip $tpl_name"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
id=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,13 +29,13 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain id'
# Checking argument format
format_validation 'user' 'domain' 'id'
validate_format 'user' 'domain' 'id'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -53,7 +52,7 @@ is_dns_record_valid
#----------------------------------------------------------#
# Deleting record
conf="$V_USERS/$user/dns/$domain"
conf="$USER_DATA/dns/$domain"
rm_string=$(grep -n "^ID='$id'" $conf|cut -d : -f 1)
if [ ! -z "$rm_string" ]; then
sed -i "$rm_string d" $conf
@ -63,7 +62,7 @@ fi
sort_dns_records
# Updating zone
conf="$V_HOME/$user/conf/dns/$domain.db"
conf="$HOMEDIR/$user/conf/dns/$domain.db"
update_domain_zone
@ -72,9 +71,9 @@ update_domain_zone
#----------------------------------------------------------#
# Adding task to the vesta pipe
restart_schedule 'dns'
$BIN/v_restart_dns
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -13,10 +13,9 @@
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/domain.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking web system is enabled
is_system_enabled 'DNS_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -41,7 +40,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/dns.conf"
conf="$USER_DATA/dns.conf"
# Defining fileds to select
field='$DOMAIN'
@ -54,10 +53,10 @@ domains=$(dom_clear_search)
# Starting delete loop
for domain in $domains; do
$V_BIN/v_delete_dns_domain "$user" "$domain"
$BIN/v_delete_dns_domain "$user" "$domain"
rv="$?"
if [ "$rv" -ne '0' ]; then
log_event 'debug' "$rv $V_EVENT"
log_event 'debug' "$rv $EVENT"
exit $rv
fi
done
@ -68,6 +67,6 @@ done
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -29,16 +28,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'mail'
@ -50,11 +49,11 @@ is_domain_valid 'mail'
# Get domain values
get_domain_values 'mail'
accounts=$(wc -l $V_USERS/$user/mail/$domain|cut -f 1 -d ' ')
accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ')
rm -f /etc/exim/domains/$domain
rm -rf $V_HOME/$user/conf/$domain
rm -rf $V_HOME/$user/mail/$domain
rm -rf $HOMEDIR/$user/conf/$domain
rm -rf $HOMEDIR/$user/mail/$domain
#----------------------------------------------------------#
@ -62,10 +61,10 @@ rm -rf $V_HOME/$user/mail/$domain
#----------------------------------------------------------#
# Delete domain config
sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/mail.conf
rm -f $V_USERS/$user/mail/$domain
rm -f $V_USERS/$user/mail/$domain.pem
rm -f $V_USERS/$user/mail/$domain.pub
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf
rm -f $USER_DATA/mail/$domain.conf
rm -f $USER_DATA/mail/$domain.pem
rm -f $USER_DATA/mail/$domain.pub
# autoreply
# Decreasing domain value
@ -74,7 +73,7 @@ decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts"
# Logging
cmd='"v_add_mail_domain'
log_history "$V_EVENT" "$cmd $user $domain $ANTISPAM $ANTIVIRUS $DKIM"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "$cmd $user $domain $ANTISPAM $ANTIVIRUS $DKIM"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -56,7 +55,7 @@ is_domain_value_exist 'mail' '$ANTISPAM'
#----------------------------------------------------------#
# Delete antispam key
sed -i "/antispam/d" $V_HOME/$user/conf/mail/$domain/protection
sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection
#----------------------------------------------------------#
@ -67,7 +66,7 @@ sed -i "/antispam/d" $V_HOME/$user/conf/mail/$domain/protection
update_domain_value 'mail' '$ANTISPAM' 'no'
# Logging
log_history "$V_EVENT" "v_add_mail_domain_antispam $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_mail_domain_antispam $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -56,7 +55,7 @@ is_domain_value_exist 'mail' '$ANTIVIRUS'
#----------------------------------------------------------#
# Delete antivirus key
sed -i "/antivirus/d" $V_HOME/$user/conf/mail/$domain/protection
sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection
#----------------------------------------------------------#
@ -67,7 +66,7 @@ sed -i "/antivirus/d" $V_HOME/$user/conf/mail/$domain/protection
update_domain_value 'mail' '$ANTIVIRUS' 'no'
# Logging
log_history "$V_EVENT" "v_add_mail_domain_antivirus $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_mail_domain_antivirus $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,16 +29,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -59,7 +58,7 @@ is_domain_value_exist 'mail' '$CATCHALL'
email=$(get_domain_value 'mail' '$CATCHALL')
# Delete cathcall alias
sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases
sed -i "/*@demo.vestacp.com:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------#
@ -70,7 +69,7 @@ sed -i "/*@demo.vestacp.com:/d" $V_HOME/$user/conf/mail/$domain/aliases
update_domain_value 'mail' '$CATCHALL' ''
# Logging
log_history "$V_EVENT" "v_add_mail_domain_catchall $user $domain $email"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_mail_domain_catchall $user $domain $email"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -29,16 +28,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking dns system is enabled
is_system_enabled 'MAIL_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
@ -55,17 +54,17 @@ is_domain_value_exist 'mail' '$DKIM'
#----------------------------------------------------------#
# Generating dkim
rm -f $V_USERS/$user/mail/$domain.pem
rm -f $V_USERS/$user/mail/$domain.pub
rm -f $V_HOME/$user/conf/mail/$domain/dkim.pem
rm -f $USER_DATA/mail/$domain.pem
rm -f $USER_DATA/mail/$domain.pub
rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem
# Checking dns domain
check_dns_domain=$(is_domain_valid 'dns')
if [ "$?" -eq 0 ]; then
records=$($V_BIN/v_list_dns_domain_records $user $domain plain)
records=$($BIN/v_list_dns_domain_records $user $domain plain)
dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ')
for id in $dkim_records; do
$V_BIN/v_delete_dns_domain_record $user $domain $id
$BIN/v_delete_dns_domain_record $user $domain $id
done
fi
@ -78,7 +77,7 @@ fi
update_domain_value 'mail' '$DKIM' 'no'
# Logging
log_history "$V_EVENT" "v_add_mail_domain_dkim $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_mail_domain_dkim $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -14,11 +14,10 @@
ip=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -29,7 +28,7 @@ source $V_FUNC/domain.func
check_args '1' "$#" 'ip'
# Checking argument format
format_validation 'ip'
validate_format 'ip'
# Checking system ip
is_sys_ip_valid "$ip"
@ -65,10 +64,10 @@ ip_status="$(get_sys_ip_value '$STATUS')"
rm -f $iconf-$interface
# Deleting vesta ip
rm -f $V_IPS/$ip
rm -f $VESTA/data/ips/$ip
# Importing main config
source $V_CONF/vesta.conf
source $VESTA/conf/vesta.conf
# Deleting namehosting support
namehost_ip_disable
@ -99,10 +98,10 @@ fi
# Adding task to the vesta pipe
if [ "$web_restart" = 'yes' ]; then
restart_schedule 'web'
$BIN/v_restart_web
fi
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,12 +14,11 @@
user=$1
# 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
source $V_FUNC/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/db.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -30,13 +29,13 @@ source $V_FUNC/ip.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking user admin
if [ "$user" = 'admin' ]; then
@ -49,8 +48,8 @@ fi
# Checking web system is enabled
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_web_domains $user
$V_BIN/v_delete_web_domains $user
$BIN/v_unsuspend_web_domains $user
$BIN/v_delete_web_domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
@ -59,8 +58,8 @@ fi
# Checking dns system is enabled
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_dns_domains $user
$V_BIN/v_delete_dns_domains $user
$BIN/v_unsuspend_dns_domains $user
$BIN/v_delete_dns_domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
@ -69,8 +68,8 @@ fi
# Checking mail system is enabled
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_mail_domains $user
$V_BIN/v_del_mail_domains $user
$BIN/v_unsuspend_mail_domains $user
$BIN/v_del_mail_domains $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
@ -79,8 +78,8 @@ fi
# Checking db system is enabled
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
$V_BIN/v_unsuspend_db_bases $user
$V_BIN/v_delete_db_dbases $user
$BIN/v_unsuspend_db_bases $user
$BIN/v_delete_db_dbases $user
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
@ -88,41 +87,23 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
fi
# Checking ip
$V_BIN/v_delete_user_ips "$user"
$BIN/v_delete_user_ips "$user"
rv="$?"
if [ "$rv" -ne '0' ]; then
exit $rv
fi
# Deleteing user pipes
diskp=$(grep -n " $user$" $V_QUEUE/disk.pipe|cut -d : -f 1|sort -n -r)
trafp=$(grep -n " $user$" $V_QUEUE/traffic.pipe|cut -d : -f 1|sort -n -r)
statp=$(grep -n "/$user/" $V_QUEUE/stats.pipe|cut -d : -f 1|sort -n -r)
if [ ! -z "$diskp" ]; then
for str in $diskp; do
sed -i "$str d" $V_QUEUE/disk.pipe
done
fi
if [ ! -z "$trafp" ]; then
for str in $trafp; do
sed -i "$str d" $V_QUEUE/traffic.pipe
done
fi
if [ ! -z "$statp" ]; then
for str in $statp; do
sed -i "$str d" $V_QUEUE/stats.pipe
done
fi
sed -i "/v_update_db_bases_disk $user$/d" $VESTA/data/queue/disk.pipe
sed -i "/v_update_web_domains_traff $user$/d" $VESTA/data/queue/traffic.pipe
sed -i "/v_update_web_domain_stat $user /d" $VESTA/data/queue/stats.pipe
# Removing system user
/usr/sbin/userdel -f $user
rm -rf $V_HOME/$user
rm -rf $HOMEDIR/$user
rm -f /var/spool/mail/$user
rm -f /var/spool/cron/$user
rm -rf $V_USERS/$user
rm -rf $USER_DATA
# Updating admin counter
if [ "$user" != 'admin' ]; then
@ -135,6 +116,6 @@ fi
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -13,10 +13,9 @@
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/ip.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking user vesta
if [ "$user" = 'admin' ]; then
@ -45,7 +44,7 @@ fi
#----------------------------------------------------------#
# Parsing user ips
ip_list=$(grep -H "OWNER='$user'" $V_IPS/* | cut -f 1 -d:)
ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:)
for ip in $ip_list; do
ip=$(basename $ip)
@ -56,7 +55,7 @@ for ip in $ip_list; do
# Assig ip to main account
update_sys_ip_value '$OWNER' 'admin'
update_sys_ip_value '$STATUS' 'exclusive'
update_sys_ip_value '$STATUS' 'dedicated'
increase_user_value 'admin' '$IP_OWNED'
increase_user_value 'admin' '$IP_AVAIL'
done
@ -67,6 +66,6 @@ done
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -18,11 +18,10 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# 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/ip.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
source $VESTA/func/ip.sh
#----------------------------------------------------------#
@ -33,16 +32,16 @@ source $V_FUNC/ip.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -57,8 +56,8 @@ is_domain_suspended 'web'
# Get template name
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Deleting domain
del_web_config
@ -72,25 +71,25 @@ fi
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
# Deleting certificates
rm -f $V_HOME/$user/conf/web/ssl.$domain.*
rm -f $V_USERS/$user/ssl/$domain.*
rm -f $HOMEDIR/$user/conf/web/ssl.$domain.*
rm -f $USER_DATA/ssl/$domain.*
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
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/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
fi
@ -98,11 +97,11 @@ fi
# Checking stats
if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then
sed -i "/ $domain$/d" $V_QUEUE/stats.pipe
rm -f $V_HOME/$user/conf/web/$STATS.$domain.conf
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
fi
# Deleting directory
rm -rf $V_HOME/$user/web/$domain
rm -rf $HOMEDIR/$user/web/$domain
# Deleting logs
rm -f /var/log/httpd/domains/$domain.log*
@ -115,19 +114,19 @@ rm -f /var/log/httpd/domains/$domain.error*
#----------------------------------------------------------#
# Deleting domain
sed -i "/DOMAIN='$domain'/ d" $V_USERS/$user/web.conf
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
# Checking last ssl domain
ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web.conf | wc -l)
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l)
if [ "$ssl_dom" -eq '0' ]; then
sed -i "s/ Include /#Include /" $V_HOME/$user/conf/web/httpd.conf
sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf
fi
# Checking last domain
domains=$(wc -l $V_USERS/$user/web.conf|cut -f 1 -d ' ')
domains=$(wc -l $USER_DATA/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/web/httpd.conf" $conf | cut -f 1 -d : )
line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : )
if [ ! -z "$line" ]; then
sed -i "$line d" $conf
fi
@ -135,22 +134,22 @@ fi
# Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then
sline=$(grep -n "$V_HOME/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :)
sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :)
if [ ! -z "$sline" ]; then
sed -i "$sline d" $conf
fi
rm -f $V_HOME/$user/conf/web/snginx.conf
rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi
if [ -z "$last_nginx" ]; then
line=$(grep -n "$V_HOME/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : )
line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : )
if [ ! -z "$line" ]; then
sed -i "$line d" $conf
fi
rm -f $V_HOME/$user/conf/web/nginx.conf
rm -f $HOMEDIR/$user/conf/web/nginx.conf
fi
# Decreasing ip value
@ -168,10 +167,10 @@ if [ "$SSL" = 'yes' ]; then
fi
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: delete web domain alias
# options user domain alias
# options: user domain alias
#
# The function of deleting the alias domain (parked domain). By this call
# default www aliase can be removed as well.
@ -18,10 +18,9 @@ dom_alias=$(idn -t --quiet -u "$3" )
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -32,16 +31,16 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain dom_alias'
# Checking argument format
format_validation 'user' 'domain' 'dom_alias'
validate_format 'user' 'domain' 'dom_alias'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -54,7 +53,7 @@ get_domain_values 'web'
check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias")
if [ -z "$check_alias" ]; then
echo "Error: alias not exist"
log_event 'debug' "$E_NOTEXIST $V_EVENT"
log_event 'debug' "$E_NOTEXIST $EVENT"
exit $E_NOTEXIST
fi
@ -68,8 +67,8 @@ ALIAS=$(echo "$ALIAS" |\
sed -e "s/^$dom_alias$//g"|\
sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g')
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Preparing domain values for the template substitution
upd_web_domain_values
@ -79,23 +78,23 @@ del_web_config
add_web_config
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
add_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
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/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
fi
@ -113,10 +112,10 @@ update_domain_value 'web' '$ALIAS' "$ALIAS"
decrease_user_value "$user" '$U_WEB_ALIASES'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_add_web_domain_alias $user $domain $dom_alias"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_web_domain_alias $user $domain $dom_alias"
log_event "$OK" "$EVENT"
exit

View file

@ -18,10 +18,9 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -32,16 +31,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -58,8 +57,8 @@ is_domain_value_exist 'web' '$CGI'
#----------------------------------------------------------#
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
CGI='no'
# Preparing domain values for the template substitution
@ -71,8 +70,8 @@ add_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
add_web_config
fi
@ -86,10 +85,10 @@ fi
update_domain_value 'web' '$CGI' 'no'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_add_web_domain_cgi $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_web_domain_cgi $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -17,10 +17,9 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -31,16 +30,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid "$user"
is_object_valid 'user' 'USER' "$user" "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -58,8 +57,8 @@ is_domain_value_exist 'web' '$ELOG'
# Parsing domain values
get_domain_values 'web'
tpl_file="$V_WEBTPL/apache_$TPL.tpl"
conf="$V_HOME/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
ELOG='no'
# Preparing domain values for the template substitution
@ -71,23 +70,23 @@ add_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config
add_web_config
fi
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/web/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config
add_web_config
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/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
add_web_config
fi
@ -102,10 +101,10 @@ fi
update_domain_value 'web' '$ELOG' 'no'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_add_web_domain_elog $user $domain"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_web_domain_elog $user $domain"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -29,16 +28,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -56,14 +55,14 @@ is_domain_value_exist 'web' '$NGINX'
# Defining domain parameters
get_domain_values 'web'
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$V_HOME/$user/conf/nginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/nginx.conf"
del_web_config
# Checking ssl
if [ "$SSL" = 'yes' ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/snginx.conf"
del_web_config
fi
@ -78,23 +77,23 @@ update_domain_value 'web' '$NGINX_EXT' ''
# Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then
sed -i "/$user\/conf\/web\/snginx.conf/d" $conf
rm -f $V_HOME/$user/conf/web/snginx.conf
rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi
if [ -z "$last_nginx" ]; then
sed -i "/$user\/conf\/web\/nginx.conf/d" $conf
rm -f $V_HOME/$user/conf/web/nginx.conf
rm -f $HOMEDIR/$user/conf/web/nginx.conf
fi
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -29,16 +28,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -56,23 +55,23 @@ is_domain_value_exist 'web' '$SSL'
# Parsing domain values
get_domain_values 'web'
conf="$V_HOME/$user/conf/web/shttpd.conf"
tpl_file="$V_WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl"
# Deleting domain
del_web_config
# Checking nginx
if [ ! -z "$NGINX" ]; then
tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$V_HOME/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config
fi
# Deleting old certificate
tmpdir=$(mktemp -p $V_HOME/$user/web/$domain/private -d)
rm -f $V_HOME/$user/conf/ssl.$domain.*
mv $V_USERS/$user/ssl/$domain.* $tmpdir
tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d)
rm -f $HOMEDIR/$user/conf/ssl.$domain.*
mv $USER_DATA/ssl/$domain.* $tmpdir
chown -R $user:$user $tmpdir
@ -84,9 +83,9 @@ chown -R $user:$user $tmpdir
update_domain_value 'web' '$SSL' 'no'
# Checking last ssl domain
ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web.conf)
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
main_conf='/etc/httpd/conf.d/vesta.conf'
conf="$V_HOME/$user/conf/shttpd.conf"
conf="$HOMEDIR/$user/conf/shttpd.conf"
if [ -z "$ssl_dom" ]; then
sed -i "/Include ${conf////\/}/d" $main_conf
rm -f $conf
@ -94,22 +93,22 @@ fi
# Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then
if [ -z "$last_nginx" ]; then
sed -i "/$user\/conf\/snginx.conf/d" $conf
rm -f $V_HOME/$user/conf/snginx.conf
rm -f $HOMEDIR/$user/conf/snginx.conf
fi
# Decreasing domain value
decrease_user_value "$user" '$U_WEB_SSL'
# Adding task to the vesta pipe
restart_schedule 'web'
$BIN/v_restart_web
# Logging
log_history "$V_EVENT" "v_add_web_domain_ssl $user $domain $tmpdir $SSL_HOME"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_web_domain_ssl $user $domain $tmpdir $SSL_HOME"
log_event "$OK" "$EVENT"
exit

View file

@ -15,10 +15,9 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -29,16 +28,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -58,13 +57,13 @@ is_domain_value_exist 'web' '$STATS'
type=$(get_domain_value 'web' '$STATS')
# Defining statistic dir
stat_dir="$V_HOME/$user/web/$domain/stats"
stat_dir="$HOMEDIR/$user/web/$domain/stats"
# Deleting dir content
rm -rf $stat_dir/*
# Deleting config
rm -f $V_HOME/$user/conf/$type.$domain.conf
rm -f $HOMEDIR/$user/conf/$type.$domain.conf
#----------------------------------------------------------#
@ -78,7 +77,7 @@ sed -i "/ $domain$/d" $V_QUEUE/stats.pipe
update_domain_value 'web' '$STATS' ''
# Logging
log_history "$V_EVENT" "v_add_web_domain_stat $user $doman $type"
log_event 'system' "$V_EVENT"
log_history "$EVENT" "v_add_web_domain_stat $user $doman $type"
log_event "$OK" "$EVENT"
exit

View file

@ -18,10 +18,9 @@ domain=$(idn -t --quiet -u "$2" )
auth_user=$3
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -32,16 +31,16 @@ source $V_FUNC/domain.func
check_args '2' "$#" 'user domain [auth_user]'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'
@ -58,12 +57,12 @@ is_domain_value_exist 'web' '$STATS_AUTH'
#----------------------------------------------------------#
# Definining statistic dir
stat_dir="$V_HOME/$user/web/$domain/stats"
stat_dir="$HOMEDIR/$user/web/$domain/stats"
# Checking auth_user
if [ ! -z "$auth_user" ]; then
format_validation 'auth_user'
htpasswd -D $stat_dir/.htpasswd "$auth_user" >/dev/null 2>&1
validate_format 'auth_user'
htpasswd -D $stat_dir/.htpasswd "$auth_user" &>/dev/null
fi
# Checking htpasswd current users
@ -104,7 +103,7 @@ fi
update_domain_value 'web' '$STATS_AUTH' "$new_val"
# Logging
log_history "$V_EVENT"
log_event 'system' "$V_EVENT"
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -13,10 +13,9 @@
user=$1
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/domain.func
check_args '1' "$#" 'user'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking web system is enabled
is_system_enabled 'WEB_SYSTEM'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -41,7 +40,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf="$V_USERS/$user/web.conf"
conf="$USER_DATA/web.conf"
# Defining fileds to select
field='$DOMAIN'
@ -54,10 +53,10 @@ domains=$(dom_clear_search)
# Starting delete loop
for domain in $domains; do
$V_BIN/v_delete_web_domain "$user" "$domain"
$BIN/v_delete_web_domain "$user" "$domain"
rv="$?"
if [ "$rv" -ne '0' ]; then
log_event 'debug' "$rv $V_EVENT"
log_event 'debug' "$rv $EVENT"
exit $rv
fi
done
@ -68,6 +67,6 @@ done
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -16,10 +16,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -30,10 +29,10 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain key'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -58,6 +57,6 @@ echo "$value"
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -14,9 +14,8 @@ user=$1
key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -27,13 +26,13 @@ source $V_FUNC/shared.func
check_args '2' "$#" 'user key'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking domain is not suspened
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -52,6 +51,6 @@ echo "$value"
#----------------------------------------------------------#
# Logging
log_event 'system' "$V_EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -18,10 +18,9 @@ domain_idn=$(idn -t --quiet -a "$domain")
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/conf/vesta.conf
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -32,13 +31,13 @@ source $V_FUNC/domain.func
check_args '3' "$#" 'user domain key'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking user is active
is_user_suspended
is_object_suspended 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'web'

View file

@ -13,27 +13,15 @@
user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
# Includes
source $VESTA/func/shared.sh
# Json function
# Json list function
json_list_cron() {
# Print top bracket
echo '{'
# Count fields
fileds_count=$(echo $fields| wc -w )
# Reading file line by line
while read line; do
# New delimeter
IFS=$'\n'
# Assing key=value pair
eval $line
# Closing bracket if there already was output
if [ -n "$data" ]; then
echo -e ' },'
fi
@ -42,13 +30,10 @@ json_list_cron() {
for field in $fields; do
eval value=\"$field\"
value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
if [ $i -eq 1 ]; then
# Printing parrent
(( ++i))
echo -e "\t\"$value\": {"
else
# Printing child
if [ $i -lt $fileds_count ]; then
(( ++i))
echo -e "\t\t\"${field//$/}\": \"${value//,/, }\","
@ -59,34 +44,23 @@ json_list_cron() {
fi
done
done < $conf
# Closing bracket if there was output
if [ -n "$data" ]; then
echo -e ' }'
fi
# Printing bottom bracket
echo -e '}'
}
# Shell function
# Shell list function
shell_list_cron() {
if [ -z "$nohead" ] ; then
# Print brief info
echo "${fields//$/}"
for a in $fields; do
echo -e "------ \c"
done
echo
fi
# Reading file line by line
while read line ; do
# Assing key=value pair
eval $line
# Print result
eval echo "$fields" | sed -e "s/%quote%/'/g"
done < $conf
}
@ -96,14 +70,9 @@ shell_list_cron() {
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
# Checking user
is_user_valid
validate_format 'user'
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -111,19 +80,20 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/cron.conf
conf=$USER_DATA/cron.conf
# Defining fileds to select
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPENDED $DATE'
fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $SUSPENDED $TIME $DATE'
# Listing domains
case $format in
json) json_list_cron ;;
plain) nohead=1;
fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\""
fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\"";
fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" ";
fields="$fields \"\$TIME\" \"\$DATE\""
shell_list_cron ;;
shell) fields='$JOB~$SUSPEND~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD';
shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD';
shell_list_cron |column -t -s '~';;
*) check_args '1' '0' 'user [format]' ;;
esac

View file

@ -15,9 +15,8 @@ database=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
# Json function
json_list_db() {
@ -90,10 +89,10 @@ shell_list_db() {
check_args '2' "$#" 'user db_name [format]'
# Checking argument format
format_validation 'user' 'database'
validate_format 'user' 'database'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking database exist
is_db_valid
@ -104,7 +103,7 @@ is_db_valid
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/db.conf
conf=$USER_DATA/db.conf
# Defining fileds to select
fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $DATE'

View file

@ -14,8 +14,7 @@ user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -26,10 +25,10 @@ source $V_FUNC/shared.func
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -37,7 +36,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/db.conf
conf=$USER_DATA/db.conf
# Defining fileds to select
fields='$DB $USER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $DATE'

View file

@ -15,9 +15,8 @@ host=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/db.func
source $VESTA/func/shared.sh
source $VESTA/func/db.sh
# Json function
json_list_dbhost() {
@ -88,10 +87,10 @@ shell_list_dbhost() {
check_args '2' "$#" 'type host [format]'
# Checking argument format
format_validation 'host'
validate_format 'host'
# Checking db type
is_type_valid 'db' "$type"
is_type_valid "$DB_SYSTEM" "$type"
# Checking db host
is_db_host_valid
@ -102,7 +101,7 @@ is_db_host_valid
#----------------------------------------------------------#
# Defining config type
conf=$V_DB/$type.conf
conf=$VESTA/conf/$type.conf
# Defining fileds to select
fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'

View file

@ -14,8 +14,7 @@ type=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -23,13 +22,10 @@ source $V_FUNC/shared.func
#----------------------------------------------------------#
# Checking args
check_args '1' "$#" 'type [format] [limit] [offset]'
# Checking argument format
format_validation 'limit' 'offset'
check_args '1' "$#" 'type [format]'
# Checking db type
is_type_valid 'db' "$type"
is_type_valid "$DB_SYSTEM" "$type"
#----------------------------------------------------------#
@ -37,7 +33,7 @@ is_type_valid 'db' "$type"
#----------------------------------------------------------#
# Defining config type
conf=$V_DB/$type.conf
conf=$VESTA/conf/$type.conf
# Defining fileds to select
fields='$HOST $PORT $MAX_DB $U_SYS_USERS $U_DB_BASES $ACTIVE $DATE'

View file

@ -16,9 +16,7 @@ domain=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/func/shared.sh
# Json function
json_list_domain() {
@ -82,7 +80,7 @@ shell_list_domain() {
check_args '2' "$#" 'user domain [format]'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -93,7 +91,7 @@ is_domain_valid 'dns'
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/dns.conf
conf=$USER_DATA/dns.conf
# Defining fileds to select
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $DATE'

View file

@ -15,9 +15,7 @@ domain=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/func/shared.sh
# Json func
json_list_dns() {
@ -104,10 +102,10 @@ shell_list_dns() {
check_args '2' "$#" 'user domain [format]'
# Checking argument format
format_validation 'user' 'domain'
validate_format 'user' 'domain'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'dns'
@ -118,7 +116,7 @@ is_domain_valid 'dns'
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/dns/$domain
conf=$USER_DATA/dns/$domain
# Defining fileds to select
fields='$ID $RECORD $TYPE $VALUE $SUSPENDED $DATE'

View file

@ -14,8 +14,7 @@ user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -26,10 +25,10 @@ source $V_FUNC/shared.func
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -37,7 +36,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/dns.conf
conf=$USER_DATA/dns.conf
# Defining fileds to select
fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $DATE'

View file

@ -14,9 +14,8 @@ template=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/func/shared.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
@ -27,10 +26,10 @@ source $V_FUNC/domain.func
check_args '1' "$#" 'template [format]'
# Checking argument format
format_validation 'template'
validate_format 'template'
# Checking template
is_template_valid 'dns'
is_dns_template_valid
# Json func
json_list_dns() {
@ -112,7 +111,7 @@ shell_list_dns() {
#----------------------------------------------------------#
# Defining config
conf=$V_DNSTPL/$template.tpl
conf=$DNSTPL/$template.tpl
# Defining fileds to select
fields='$RECORD $TYPE $VALUE'

View file

@ -13,8 +13,7 @@
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
# Json function
json_list_dnstpl() {
@ -22,13 +21,13 @@ json_list_dnstpl() {
echo '{'
# Count fields
for template in $(ls $V_DNSTPL/| grep '.descr'); do
for template in $(ls $DNSTPL/| grep '.descr'); do
# Closing bracket if there already was output
if [ -n "$data" ]; then
echo -e ' },'
fi
tpl_descr=$(cat $V_DNSTPL/$template |grep '#'|tr -d '\n')
tpl_descr=$(cat $DNSTPL/$template |grep '#'|tr -d '\n')
tpl_name="${template//.descr/}"
echo -e "\t\"$tpl_name\": {"
echo -e "\t\t\"DESCR\": \"${tpl_descr//# /}\""
@ -47,9 +46,9 @@ json_list_dnstpl() {
# Shell function
shell_list_dnstpl() {
for template in $(ls $V_DNSTPL/| grep '.descr'); do
for template in $(ls $DNSTPL/| grep '.descr'); do
tpl_name="${template//.descr/}"
tpl_descr=$(cat $V_DNSTPL/$template |grep '#')
tpl_descr=$(cat $DNSTPL/$template |grep '#')
# Print result
if [ -z "$nohead" ] ; then

62
bin/v_list_mail_accounts Executable file
View file

@ -0,0 +1,62 @@
#!/bin/bash
# info: list mail domain accounts
# options: user domain [format]
#
# The function of obtaining the list of all user domains.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$2
format=${3-shell}
# Importing variables
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
# Checking args
check_args '2' "$#" 'user domain [format]'
# Checking argument format
validate_format 'user' 'domain'
# Checking user
is_object_valid 'user' 'USER' "$user"
# Checking domain
is_domain_valid 'mail'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Defining config
conf=$USER_DATA/mail/$domain.conf
# Defining fileds to select
fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$U_DISK \$SUSPENDED \$DATE"
# Listing domain accounts
case $format in
json) json_list ;;
plain) nohead=1; shell_list ;;
shell) fields='$ACCOUNT $ALIAS $FWD $AUTOREPLY $U_DISK $DATE';
shell_list | column -t ;;
*) check_args '1' '0' 'user [format]'
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit

View file

@ -16,9 +16,7 @@ domain=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/func/shared.sh
# Json function
json_list_domain() {
@ -82,7 +80,7 @@ shell_list_domain() {
check_args '2' "$#" 'user domain [format]'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'mail'
@ -93,7 +91,7 @@ is_domain_valid 'mail'
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/mail.conf
conf=$USER_DATA/mail.conf
# Defining fileds to select
fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL

View file

@ -15,9 +15,7 @@ domain=$2
format=${3-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/domain.func
source $VESTA/func/shared.sh
# Json function
json_list_ssl() {
@ -47,7 +45,7 @@ shell_list_ssl() {
check_args '2' "$#" 'user domain [format]'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
# Checking domain exist
is_domain_valid 'mail'
@ -56,12 +54,12 @@ is_domain_valid 'mail'
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ -e "$V_USERS/$user/mail/$domain.pem" ]; then
pem=$(cat $V_USERS/$user/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g')
if [ -e "$USER_DATA/mail/$domain.pem" ]; then
pem=$(cat $USER_DATA/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g')
fi
if [ -e "$V_USERS/$user/mail/$domain.pub" ]; then
pub=$(cat $V_USERS/$user/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g')
if [ -e "$USER_DATA/mail/$domain.pub" ]; then
pub=$(cat $USER_DATA/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g')
fi
# Listing domains

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: list mail domains
# options user [format]
# options: user [format]
#
# The function of obtaining the list of all user domains.
@ -14,8 +14,7 @@ user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
#----------------------------------------------------------#
@ -26,10 +25,10 @@ source $V_FUNC/shared.func
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -37,7 +36,7 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/mail.conf
conf=$USER_DATA/mail.conf
# Defining fileds to select
fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL"

View file

@ -12,16 +12,13 @@
# Argument defenition
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
# Json function
json_list_conf() {
lines=$(wc -l $V_CONF/vesta.conf | cut -f 1 -d ' ')
lines=$(wc -l $VESTA/conf/vesta.conf | cut -f 1 -d ' ')
i='0'
IFS=$'\n'
echo -e "{\n\t\"config\": {"
for str in $(cat $V_CONF/vesta.conf); do
for str in $(cat $VESTA/conf/vesta.conf); do
(( ++i))
key=${str%%=*}
value=${str#*=}
@ -37,7 +34,7 @@ json_list_conf() {
# Shell function
shell_list_conf() {
IFS=$'\n'
for str in $(cat $V_CONF/vesta.conf); do
for str in $(cat $VESTA/conf/vesta.conf); do
key=${str%%=*}
value=${str#*=}
echo "$key: ${value//\'/}"

View file

@ -13,8 +13,7 @@
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
# Json function
json_list_iface() {

View file

@ -15,15 +15,14 @@ IP=$ip
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $V_FUNC/ip.func
source $VESTA/func/shared.sh
source $VESTA/func/ip.sh
# Json function
json_list_ip() {
i=1
fileds_count=$(echo "$fields" | wc -w)
ip_data=$(cat $V_IPS/$IP)
ip_data=$(cat $VESTA/data/ips/$IP)
# Print top bracket
echo '{'
@ -58,7 +57,7 @@ json_list_ip() {
# Shell function
shell_list_ip() {
line=$(cat $V_IPS/$IP)
line=$(cat $VESTA/data/ips/$IP)
# Assing key=value
eval $line
@ -79,7 +78,7 @@ shell_list_ip() {
check_args '1' "$#" 'ip [format]'
# Checking argument format
format_validation 'ip'
validate_format 'ip'
# Checking ip
is_sys_ip_valid
@ -87,7 +86,7 @@ is_sys_ip_valid
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
conf=$V_IPS/$IP
conf=$VESTA/data/ips/$IP
# Defining fileds to select
fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS

View file

@ -13,8 +13,7 @@
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
# Json function
json_list_ips() {
@ -22,14 +21,14 @@ json_list_ips() {
echo '{'
# Definining ip list
ip_list=$(ls $V_IPS/)
ip_list=$(ls $VESTA/data/ips/)
fileds_count=$(echo "$fields" | wc -w)
# Starting main loop
for IP in $ip_list; do
# Assing key=value
ip_data=$(cat $V_IPS/$IP)
ip_data=$(cat $VESTA/data/ips/$IP)
eval $ip_data
# Closing bracket if there already was output
@ -68,7 +67,7 @@ json_list_ips() {
# Shell function
shell_list_ips() {
ip_list=$(ls $V_IPS/)
ip_list=$(ls $VESTA/data/ips/)
if [ -z "$nohead" ]; then
# Print brief info
@ -82,7 +81,7 @@ shell_list_ips() {
# Starting main loop
for IP in $ip_list; do
# Reading user data
ip_data=$(cat $V_IPS/$IP)
ip_data=$(cat $VESTA/data/ips/$IP)
# Assign key/value config
eval $ip_data
@ -96,7 +95,7 @@ shell_list_ips() {
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
conf=$V_IPS/*
conf=$VESTA/data/ips/*
# Defining fileds to select
fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS"

View file

@ -10,17 +10,15 @@
#----------------------------------------------------------#
format=${1-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_CONF/vesta.conf
source $VESTA/conf/vesta.conf
RRD=$VESTA/web/rrd
# Define json function
json_list_rrd() {
i=1
echo "{"
for type in $rrd_types; do
for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
if [ "$i" -ne 1 ]; then
echo -e "\t},"
fi
@ -73,8 +71,8 @@ shell_list_rrd() {
fi
for type in $rrd_types; do
for rrd in $(ls $V_RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
echo "$V_RRD/$type/$rrd.rrd"
for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do
echo "$RRD/$type/$rrd.rrd"
done
done
}

View file

@ -15,8 +15,7 @@ USER="$user"
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
# Json function
json_list_user() {
@ -73,10 +72,10 @@ shell_list_user() {
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -84,18 +83,18 @@ is_user_valid
#----------------------------------------------------------#
# Defining config
conf=$V_USERS/$user/user.conf
conf=$USER_DATA/user.conf
# Defining fileds to select
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_ALIASES $WEB_TPL
$DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES
$CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT $REPORTS
$RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB $SUSPENDED_DNS
$SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL $IP_OWNED $U_USERS
$U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB $U_BANDWIDTH
$U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS $U_DNS_RECORDS
$U_MAIL_DOMAINS $U_MAIL_ACCOUNTS $U_DATABASES $U_CRON_JOBS $U_BACKUPS
$DATE'
$CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT
$CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB
$SUSPENDED_DNS $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL
$IP_OWNED $U_USERS $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB
$U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS
$U_DNS_RECORDS $U_MAIL_DOMAINS $U_MAIL_ACCOUNTS $U_DATABASES $U_CRON_JOBS
$U_BACKUPS $TIME $DATE'
# Listing user
case $format in

View file

@ -14,8 +14,7 @@ user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
#----------------------------------------------------------#
# Verifications #
@ -25,10 +24,10 @@ source $V_FUNC/shared.func
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#
@ -36,7 +35,7 @@ is_user_valid
#----------------------------------------------------------#
# Checking config
conf=$V_USERS/$user/backup.conf
conf=$USER_DATA/backup.conf
if [ ! -e "$conf" ]; then
touch $conf
fi

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: list user ips
# options user [format]
# options: user [format]
#
# The function for obtainig the list of available ip addresses.
@ -14,16 +14,15 @@ user=$1
format=${2-shell}
# Importing variables
source $VESTA/conf/vars.conf
source $V_FUNC/shared.func
source $VESTA/func/shared.sh
# Json function
json_list_user_ips() {
# Print top bracket
echo '{'
fileds_count=$(echo "$fields" | wc -w)
for IP in $(ls $V_IPS/); do
source $V_IPS/$IP
for IP in $(ls $VESTA/data/ips/); do
source $VESTA/data/ips/$IP
if [ "$OWNER" = "$user" ]; then
# Closing bracket if there already was output
if [ -n "$data" ]; then
@ -83,8 +82,8 @@ json_list_user_ips() {
# Shell function
shell_list_user_ips() {
for IP in $(ls $V_IPS/); do
source $V_IPS/$IP
for IP in $(ls $VESTA/data/ips/); do
source $VESTA/data/ips/$IP
if [ "$OWNER" = "$user" ]; then
eval echo "$fields"
else
@ -104,10 +103,10 @@ shell_list_user_ips() {
check_args '1' "$#" 'user [format]'
# Checking argument format
format_validation 'user'
validate_format 'user'
# Checking user
is_user_valid
is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------#

Some files were not shown because too many files have changed in this diff Show more