Merge changes from upstream

I'm a little angry
This commit is contained in:
ZonD Eighty 2012-12-28 23:31:02 +04:00
commit 2b16d9bd83
254 changed files with 24485 additions and 24094 deletions

View file

@ -1,81 +1,81 @@
#!/bin/bash #!/bin/bash
# info: add cron job # info: add cron job
# options: user min hour day month wday command [job] # options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB]
# #
# The function adds a job to cron daemon. When executing commands, any output # The function adds a job to cron daemon. When executing commands, any output
# is mailed to user's email if parameter REPORTS is set to 'yes'. # is mailed to user's email if parameter REPORTS is set to 'yes'.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
min=$2 min=$2
hour=$3 hour=$3
day=$4 day=$4
month=$5 month=$5
wday=$6 wday=$6
command=$(echo $7 | sed -e "s/'/%quote%/g") command=$(echo $7 | sed -e "s/'/%quote%/g")
job=$8 job=$8
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
# Assing new value # Assing new value
A7="$command" A7="$command"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '7' "$#" 'user min hour day month wday command [job]' check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB]'
validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_package_full 'CRON_JOBS' is_package_full 'CRON_JOBS'
get_next_cronjob get_next_cronjob
validate_format 'job' validate_format 'job'
is_object_free 'cron' 'JOB' "$job" is_object_free 'cron' 'JOB' "$job"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Concatenating cron string # Concatenating cron string
str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
# Adding to crontab # Adding to crontab
echo "$str" >> $VESTA/data/users/$user/cron.conf echo "$str" >> $VESTA/data/users/$user/cron.conf
# Chaning permissions # Chaning permissions
chmod 660 $VESTA/data/users/$user/cron.conf chmod 660 $VESTA/data/users/$user/cron.conf
# Sort jobs by id number # Sort jobs by id number
sort_cron_jobs sort_cron_jobs
# Sync cronjobs with system crond # Sync cronjobs with system crond
sync_cron_jobs sync_cron_jobs
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing cron value # Increasing cron value
increase_user_value $user '$U_CRON_JOBS' increase_user_value $user '$U_CRON_JOBS'
# Restart crond # Restart crond
$BIN/v-restart-cron "$EVENT" $BIN/v-restart-cron "$EVENT"
# Logging # Logging
log_history "added cron job $job" log_history "added cron job $job"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,54 +1,54 @@
#!/bin/bash #!/bin/bash
# info: add cron reports # info: add cron reports
# opions: user # opions: user
# #
# The script for enabling reports on cron tasks and administrative # The script for enabling reports on cron tasks and administrative
# notifications. # notifications.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_system_enabled "$CRON_SYSTEM" is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user report value # Changing user report value
update_user_value "$user" '$CRON_REPORTS' 'yes' update_user_value "$user" '$CRON_REPORTS' 'yes'
# Sync system cron with user # Sync system cron with user
sync_cron_jobs sync_cron_jobs
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart crond # Restart crond
$BIN/v-restart-cron "$EVENT" $BIN/v-restart-cron "$EVENT"
# Logging # Logging
log_history "enabled cron reporting" log_history "enabled cron reporting"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,86 +1,86 @@
#!/bin/bash #!/bin/bash
# info: add database # info: add database
# options: user database dbuser dbpass type [host] [charset] # options: USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET]
# #
# The function creates the database concatenating username and user_db. # The function creates the database concatenating username and user_db.
# Supported yypes of databases you can get using v-list-sys-config script. # Supported yypes of databases you can get using v-list-sys-config script.
# If the host isn't stated and there are few hosts configured on the server, # If the host isn't stated and there are few hosts configured on the server,
# then the host will be defined by one of three algorithms. "First" will choose # then the host will be defined by one of three algorithms. "First" will choose
# the first host in the list. "Random" will chose the host by a chance. # the first host in the list. "Random" will chose the host by a chance.
# "Weight" will distribute new database through hosts evenly. Algorithm and # "Weight" will distribute new database through hosts evenly. Algorithm and
# types of supported databases is designated in the main configuration file. # types of supported databases is designated in the main configuration file.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
database="$user"_"$2" database="$user"_"$2"
dbuser="$user"_"$3" dbuser="$user"_"$3"
dbpass=$4 dbpass=$4
type=$5 type=$5
host=$6 host=$6
charset=${7-UTF8} charset=${7-UTF8}
charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]') charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]')
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/db.sh source $VESTA/func/db.sh
# Hiding password # Hiding password
A4='******' A4='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '5' "$#" 'user database dbuser dbpass type [host] [charset]' check_args '5' "$#" 'USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET]'
validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset' validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset'
is_system_enabled "$DB_SYSTEM" is_system_enabled "$DB_SYSTEM"
is_type_valid "$DB_SYSTEM" "$type" is_type_valid "$DB_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_free 'db' 'DB' "$database" is_object_free 'db' 'DB' "$database"
get_next_dbhost get_next_dbhost
is_object_valid "../../../conf/$type" 'HOST' "$host" is_object_valid "../../../conf/$type" 'HOST' "$host"
is_object_unsuspended "../../../conf/$type" 'HOST' "$host" is_object_unsuspended "../../../conf/$type" 'HOST' "$host"
#is_charset_valid #is_charset_valid
is_package_full 'DATABASES' is_package_full 'DATABASES'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Switching on db type # Switching on db type
case $type in case $type in
mysql) add_mysql_database ;; mysql) add_mysql_database ;;
pgsql) add_pgsql_database ;; pgsql) add_pgsql_database ;;
esac esac
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing counters # Increasing counters
increase_dbhost_values increase_dbhost_values
increase_user_value "$user" '$U_DATABASES' increase_user_value "$user" '$U_DATABASES'
# Adding db to db conf # Adding db to db conf
str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'" str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'"
str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$TIME'" str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$TIME'"
str="$str DATE='$DATE'" str="$str DATE='$DATE'"
echo "$str" >> $USER_DATA/db.conf echo "$str" >> $USER_DATA/db.conf
chmod 660 $USER_DATA/db.conf chmod 660 $USER_DATA/db.conf
# Logging # Logging
log_history "added $type database $database" log_history "added $type database $database"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: add new database server # info: add new database server
# options: type host port dbuser dbpass [max_db] [charsets] [template] # options: TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TEMPLATE]
# #
# The function add new database server to the server pool. It supports local # The function add new database server to the server pool. It supports local
# and remote database servers, which is useful for clusters. By adding a host # and remote database servers, which is useful for clusters. By adding a host
# you can set limit for number of databases on a host. Template parameter is # you can set limit for number of databases on a host. Template parameter is
# used only for PostgreSQL and has an default value "template1". You can read # used only for PostgreSQL and has an default value "template1". You can read
# more about templates in official PostgreSQL documentation. # more about templates in official PostgreSQL documentation.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
type=$1 type=$1
host=$2 host=$2
port=$3 port=$3
dbuser=$4 dbuser=$4
dbpass=$5 dbpass=$5
A5='******' A5='******'
charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
template=${8-template1} template=${8-template1}
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/db.sh source $VESTA/func/db.sh
# Hiding password # Hiding password
max_db=${6-500} max_db=${6-500}
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
args_usage='type host port dbuser dbpass [max_db] [charsets] [tpl]' args_usage='TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]'
check_args '5' "$#" "$args_usage" check_args '5' "$#" "$args_usage"
validate_format 'host' 'port' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template' validate_format 'host' 'port' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template'
is_system_enabled "$DB_SYSTEM" is_system_enabled "$DB_SYSTEM"
is_type_valid "$DB_SYSTEM" "$type" is_type_valid "$DB_SYSTEM" "$type"
is_dbhost_new is_dbhost_new
case $type in case $type in
mysql) is_mysql_host_alive ;; mysql) is_mysql_host_alive ;;
pgsql) is_pgsql_host_alive ;; pgsql) is_pgsql_host_alive ;;
esac esac
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Concatentating db host string # Concatentating db host string
case $type in case $type in
mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'";
str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''"; str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''";
str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'";; str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'";;
pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'";
str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'"; str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'";
str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'"; str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'";
str="$str TIME='$TIME' DATE='$DATE'";; str="$str TIME='$TIME' DATE='$DATE'";;
esac esac
# Adding host to conf # Adding host to conf
echo "$str" >> $VESTA/conf/$type.conf echo "$str" >> $VESTA/conf/$type.conf
chmod 660 $VESTA/conf/$type.conf chmod 660 $VESTA/conf/$type.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "added $type database server $host" '' 'admin' log_history "added $type database server $host" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,143 +1,143 @@
#!/bin/bash #!/bin/bash
# info: add dns domain # info: add dns domain
# options: user domain ip [template] [ns1] [ns2] [ns3] [ns4] [restart] # options: USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4] [RESTART]
# #
# The function adds DNS zone with records defined in the template. If the exp # The function adds DNS zone with records defined in the template. If the exp
# argument isn't stated, the expiration date value will be set to next year. # argument isn't stated, the expiration date value will be set to next year.
# The soa argument is responsible for the relevant record. By default the first # The soa argument is responsible for the relevant record. By default the first
# user's NS server is used. TTL is set as common for the zone and for all of # user's NS server is used. TTL is set as common for the zone and for all of
# its records with a default value of 14400 seconds. # its records with a default value of 14400 seconds.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ip=$3 ip=$3
template=$4 template=$4
ns1=$5 ns1=$5
ns2=$6 ns2=$6
ns3=$7 ns3=$7
ns4=$8 ns4=$8
restart=$9 restart=$9
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ip [template] [ns1] [ns2] [ns3] [ns4]' check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4]'
validate_format 'user' 'domain' 'ip' validate_format 'user' 'domain' 'ip'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'dns' is_domain_new 'dns'
is_package_full 'DNS_DOMAINS' is_package_full 'DNS_DOMAINS'
if [ ! -z "$template" ]; then if [ ! -z "$template" ]; then
validate_format 'template' validate_format 'template'
is_dns_template_valid is_dns_template_valid
else else
template=$(get_user_value '$TEMPLATE') template=$(get_user_value '$TEMPLATE')
is_dns_template_valid is_dns_template_valid
fi fi
if [ ! -z "$ns1" ]; then if [ ! -z "$ns1" ]; then
ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns1' validate_format 'ns1'
fi fi
if [ ! -z "$ns2" ]; then if [ ! -z "$ns2" ]; then
ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns2' validate_format 'ns2'
fi fi
if [ ! -z "$ns3" ]; then if [ ! -z "$ns3" ]; then
ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns3' validate_format 'ns3'
fi fi
if [ ! -z "$ns4" ]; then if [ ! -z "$ns4" ]; then
ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns4' validate_format 'ns4'
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining variables # Defining variables
if [ -z $ns2 ]; then if [ -z $ns2 ]; then
i=1 i=1
ns=$(get_user_value '$NS') ns=$(get_user_value '$NS')
for nameserver in ${ns//,/ };do for nameserver in ${ns//,/ };do
eval ns$i=$nameserver eval ns$i=$nameserver
(( ++i)) (( ++i))
done done
fi fi
soa="$ns1" soa="$ns1"
exp=$(date +%F -d "+ 1 year") exp=$(date +%F -d "+ 1 year")
ttl=14400 ttl=14400
# Adding zone to dns dir # Adding zone to dns dir
cat $DNSTPL/$template.tpl |\ cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \ -e "s/%domain%/$domain/g" \
-e "s/%ns1%/$ns1/g" \ -e "s/%ns1%/$ns1/g" \
-e "s/%ns2%/$ns2/g" \ -e "s/%ns2%/$ns2/g" \
-e "s/%ns3%/$ns3/g" \ -e "s/%ns3%/$ns3/g" \
-e "s/%ns4%/$ns4/g" \ -e "s/%ns4%/$ns4/g" \
-e "s/%time%/$TIME/g" \ -e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
chmod 660 $USER_DATA/dns/$domain.conf chmod 660 $USER_DATA/dns/$domain.conf
records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
# Adding dns.conf record # Adding dns.conf record
dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'" dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'" dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'"
dns_rec="$dns_rec DATE='$DATE'" dns_rec="$dns_rec DATE='$DATE'"
echo "$dns_rec" >> $USER_DATA/dns.conf echo "$dns_rec" >> $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf chmod 660 $USER_DATA/dns.conf
# Adding zone in named.conf # Adding zone in named.conf
named="zone \"$domain_idn\" {type master; file" named="zone \"$domain_idn\" {type master; file"
named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};"
echo "$named" >> /etc/named.conf echo "$named" >> /etc/named.conf
# Updating domain dns zone # Updating domain dns zone
update_domain_zone update_domain_zone
chmod 640 $conf chmod 640 $conf
chown root:named $conf chown root:named $conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing domain value # Increasing domain value
increase_user_value "$user" '$U_DNS_DOMAINS' increase_user_value "$user" '$U_DNS_DOMAINS'
increase_user_value "$user" '$U_DNS_RECORDS' "$records" increase_user_value "$user" '$U_DNS_RECORDS' "$records"
# Restart named # Restart named
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
fi fi
# Logging # Logging
log_history "added dns domain $domain" log_history "added dns domain $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,92 +1,92 @@
#!/bin/bash #!/bin/bash
# info: add dns domain record # info: add dns domain record
# options: user domain record type value [priority] [id] [restart] # options: USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]
# #
# The call is used for adding new DNS record. Complex records of TXT, MX and # The call is used for adding new DNS record. Complex records of TXT, MX and
# SRV types can be used by a filling in the 'value' argument. The function also # SRV types can be used by a filling in the 'value' argument. The function also
# gets an id parameter for definition of certain record identifier or for the # gets an id parameter for definition of certain record identifier or for the
# regulation of records. # regulation of records.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
record=$(idn -t --quiet -u "$3" ) record=$(idn -t --quiet -u "$3" )
record=$(echo "$record" | tr '[:upper:]' '[:lower:]') record=$(echo "$record" | tr '[:upper:]' '[:lower:]')
rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]') rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]')
dvalue=$(idn -t --quiet -u "$5" ) dvalue=$(idn -t --quiet -u "$5" )
dvalue=$(echo "$dvalue" | tr '[:upper:]' '[:lower:]') dvalue=$(echo "$dvalue" | tr '[:upper:]' '[:lower:]')
priority=$6 priority=$6
id=$7 id=$7
restart=$8 restart=$8
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '5' "$#" 'user domain record type value [priority] [id] [restart]' check_args '5' "$#" 'USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]'
validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' validate_format 'user' 'domain' 'record' 'rtype' 'dvalue'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_package_full 'DNS_RECORDS' is_package_full 'DNS_RECORDS'
get_next_dnsrecord get_next_dnsrecord
validate_format 'id' validate_format 'id'
is_object_free "dns/$domain" 'ID' "$id" is_object_free "dns/$domain" 'ID' "$id"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then
priority='' priority=''
fi fi
# Adding record # Adding record
zone="$USER_DATA/dns/$domain.conf" zone="$USER_DATA/dns/$domain.conf"
dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'" dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'"
dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
echo "$dns_rec" >> $zone echo "$dns_rec" >> $zone
chmod 660 $zone chmod 660 $zone
# Sorting records # Sorting records
sort_dns_records sort_dns_records
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Upddate counters # Upddate counters
records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
increase_user_value "$user" '$U_DNS_RECORDS' increase_user_value "$user" '$U_DNS_RECORDS'
# Restart named # Restart named
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
fi fi
# Logging # Logging
log_history "added $rtype dns record $record for $domain" log_history "added $rtype dns record $record for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,80 +1,80 @@
#!/bin/bash #!/bin/bash
# info: add dns domain or dns record based on web domain alias restart # info: add dns domain or dns record based on web domain alias restart
# options: user domain # options: USER DOMAIN
# #
# The function adds dns domain or dns record based on web domain alias. # The function adds dns domain or dns record based on web domain alias.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
dom_alias=$(idn -t --quiet -u "$3" ) dom_alias=$(idn -t --quiet -u "$3" )
dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4" restart="$4"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain alias' check_args '3' "$#" 'USER DOMAIN ALIAS'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
# Check if it a simple domain # Check if it a simple domain
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
$BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart $BIN/v-add-dns-domain $user $dom_alias $IP '' '' '' '' '' $restart
fi fi
else else
# Check subdomain # Check subdomain
sub=$(echo "$dom_alias" | cut -f1 -d . -s) sub=$(echo "$dom_alias" | cut -f1 -d . -s)
dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
$BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart $BIN/v-add-dns-domain $user $dom $IP '' '' '' '' '' $restart
$BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart
else else
if [ "$sub" == '*' ]; then if [ "$sub" == '*' ]; then
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
else else
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
fi fi
if [ -z "$rec" ]; then if [ -z "$rec" ]; then
$BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart $BIN/v-add-dns-domain-record $user $dom "$sub" A $IP '' '' $restart
fi fi
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# No Logging # No Logging
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: add mail domain account # info: add mail domain account
# options: user domain account password [quota] # options: USER DOMAIN ACCOUNT PASSWORD [QUOTA]
# #
# The function add new email account. # The function add new email account.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
password=$4 password=$4
quota=${5-0} quota=${5-0}
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
# Hiding password # Hiding password
A4='******' A4='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account password [quota]' check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]'
validate_format 'user' 'domain' 'account' 'password' 'quota' validate_format 'user' 'domain' 'account' 'password' 'quota'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_package_full 'MAIL_ACCOUNTS' is_package_full 'MAIL_ACCOUNTS'
is_mail_new "$account" is_mail_new "$account"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
if [ -x '/usr/bin/doveadm' ]; then if [ -x '/usr/bin/doveadm' ]; then
md5=$(/usr/bin/doveadm pw -s md5 -p "$password") md5=$(/usr/bin/doveadm pw -s md5 -p "$password")
else else
md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") md5=$(/usr/sbin/dovecotpw -s md5 -p "$password")
fi fi
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''"
str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
echo "$str" >> $USER_DATA/mail/$domain.conf echo "$str" >> $USER_DATA/mail/$domain.conf
chmod 660 $USER_DATA/mail/$domain.conf chmod 660 $USER_DATA/mail/$domain.conf
# Increase mail accounts counter # Increase mail accounts counter
accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ')
increase_user_value "$user" '$U_MAIL_ACCOUNTS' increase_user_value "$user" '$U_MAIL_ACCOUNTS'
update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts"
# Logging # Logging
log_history "added mail account $account@$domain" log_history "added mail account $account@$domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

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

View file

@ -1,64 +1,64 @@
#!/bin/bash #!/bin/bash
# info: add mail account autoreply message # info: add mail account autoreply message
# options: user domain account message # options: USER DOMAIN ACCOUNT MESSAGE
# #
# The function add new email account. # The function add new email account.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
autoreply=$4 autoreply=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account message' check_args '4' "$#" 'USER DOMAIN ACCOUNT MESSAGE'
validate_format 'user' 'domain' 'account' 'autoreply' validate_format 'user' 'domain' 'account' 'autoreply'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' # is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Add exim autoreply # Add exim autoreply
echo -e "$autoreply" > $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg echo -e "$autoreply" > $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg
chown -R root:mail $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg chown -R root:mail $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg
chmod 660 $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg chmod 660 $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding vesta alias # Adding vesta alias
echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg
chmod 660 $USER_DATA/mail/$account@$domain.msg chmod 660 $USER_DATA/mail/$account@$domain.msg
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes' update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes'
# Logging # Logging
log_history "added autoreply message on $account@$domain" log_history "added autoreply message on $account@$domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,73 +1,73 @@
#!/bin/bash #!/bin/bash
# info: add mail account forward address # info: add mail account forward address
# options: user domain account forward # options: USER DOMAIN ACCOUNT FORWARD
# #
# The function add new email account. # The function add new email account.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
forward=$4 forward=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account forward' check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
validate_format 'user' 'domain' 'account' 'forward' validate_format 'user' 'domain' 'account' 'forward'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD')
if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then
echo "Error: forward $forward exists" echo "Error: forward $forward exists"
log_event "$E_EXISTS $EVENT" log_event "$E_EXISTS $EVENT"
exit $E_EXISTS exit $E_EXISTS
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding forward to exim # Adding forward to exim
if [ -z "$fwd" ]; then if [ -z "$fwd" ]; then
fwd="$forward" fwd="$forward"
else else
fwd="$fwd,$forward" fwd="$fwd,$forward"
fi fi
sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases
echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Updating config # Updating config
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd"
# Logging # Logging
log_history "added forwarding from $account@$domain to $forward" log_history "added forwarding from $account@$domain to $forward"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,121 +1,121 @@
#!/bin/bash #!/bin/bash
# info: add mail domain # info: add mail domain
# options: user domain [antispam] [antivirus] [dkim] [dkim_size] # options: USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]
# #
# The function adds MAIL domain. # The function adds MAIL domain.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
antispam=${3-yes} antispam=${3-yes}
antivirus=${4-yes} antivirus=${4-yes}
dkim=${5-yes} dkim=${5-yes}
dkim_size=${6-512} dkim_size=${6-512}
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain [antispam] [antivirus] [dkim] [dkim_size]' check_args '2' "$#" 'USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]'
validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'mail' is_domain_new 'mail'
is_package_full 'MAIL_DOMAINS' is_package_full 'MAIL_DOMAINS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding domain directory # Adding domain directory
mkdir $HOMEDIR/$user/conf/mail/$domain mkdir $HOMEDIR/$user/conf/mail/$domain
touch $HOMEDIR/$user/conf/mail/$domain/aliases touch $HOMEDIR/$user/conf/mail/$domain/aliases
touch $HOMEDIR/$user/conf/mail/$domain/protection touch $HOMEDIR/$user/conf/mail/$domain/protection
touch $HOMEDIR/$user/conf/mail/$domain/passwd touch $HOMEDIR/$user/conf/mail/$domain/passwd
chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain
chmod 770 $HOMEDIR/$user/conf/mail/$domain chmod 770 $HOMEDIR/$user/conf/mail/$domain
chmod 660 $HOMEDIR/$user/conf/mail/$domain/* chmod 660 $HOMEDIR/$user/conf/mail/$domain/*
mkdir $HOMEDIR/$user/mail/$domain mkdir $HOMEDIR/$user/mail/$domain
chown $user:mail $HOMEDIR/$user/mail/$domain chown $user:mail $HOMEDIR/$user/mail/$domain
chmod 770 $HOMEDIR/$user/mail/$domain chmod 770 $HOMEDIR/$user/mail/$domain
# Adding symlink # Adding symlink
ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/
# Adding antispam protection # Adding antispam protection
if [ "$antispam" = 'yes' ]; then if [ "$antispam" = 'yes' ]; then
echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi fi
# Adding antivirus protection # Adding antivirus protection
if [ "$antivirus" = 'yes' ]; then if [ "$antivirus" = 'yes' ]; then
echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi fi
# Adding dkim # Adding dkim
if [ "$dkim" = 'yes' ]; then if [ "$dkim" = 'yes' ]; then
openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null
openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \
-out $USER_DATA/mail/$domain.pub &>/dev/null -out $USER_DATA/mail/$domain.pub &>/dev/null
chmod 660 $USER_DATA/mail/$domain.* chmod 660 $USER_DATA/mail/$domain.*
cp $USER_DATA/mail/$domain.pem $HOMEDIR/$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 chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem
chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem
# Adding dkim dns records # Adding dkim dns records
check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain")
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
record='_domainkey' record='_domainkey'
policy="\"t=y; o=~;\"" policy="\"t=y; o=~;\""
$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' record='mail._domainkey'
selector="\"k=rsa\; p=$p\"" selector="\"k=rsa\; p=$p\""
$BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector"
fi fi
fi fi
# Adding domain to vesta db # Adding domain to vesta db
s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'"
s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' TIME='$TIME'" s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' TIME='$TIME'"
s="$s DATE='$DATE'" s="$s DATE='$DATE'"
echo $s >> $USER_DATA/mail.conf echo $s >> $USER_DATA/mail.conf
touch $USER_DATA/mail/$domain.conf touch $USER_DATA/mail/$domain.conf
chmod 660 $USER_DATA/mail.conf chmod 660 $USER_DATA/mail.conf
chmod 660 $USER_DATA/mail/$domain.conf chmod 660 $USER_DATA/mail/$domain.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing domain value # Increasing domain value
increase_user_value "$user" '$U_MAIL_DOMAINS' increase_user_value "$user" '$U_MAIL_DOMAINS'
if [ "$dkim" = 'yes' ]; then if [ "$dkim" = 'yes' ]; then
increase_user_value "$user" '$U_MAIL_DKMI' increase_user_value "$user" '$U_MAIL_DKMI'
fi fi
# Logging # Logging
log_history "added mail domain $domain" log_history "added mail domain $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,58 +1,58 @@
#!/bin/bash #!/bin/bash
# info: add mail domain antispam support # info: add mail domain antispam support
# options: user domain # options: USER DOMAIN
# #
# The function enables spamassasin for incomming emails. # The function enables spamassasin for incomming emails.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM' is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding antispam key to config # Adding antispam key to config
if [ -z "$(grep spam $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then if [ -z "$(grep spam $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then
echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding antispam in config # Adding antispam in config
update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes' update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes'
# Logging # Logging
log_history "enabled antispam on $domain" log_history "enabled antispam on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,59 +1,59 @@
#!/bin/bash #!/bin/bash
# info: add mail domain antivirus support # info: add mail domain antivirus support
# options: user domain # options: USER DOMAIN
# #
# The function enables clamav scan for incomming emails. # The function enables clamav scan for incomming emails.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding antivirus key to config # Adding antivirus key to config
if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then
echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding antivirus in config # Adding antivirus in config
update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes' update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes'
# Logging # Logging
log_history "enabled antivirus on $domain" log_history "enabled antivirus on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,60 +1,60 @@
#!/bin/bash #!/bin/bash
# info: add mail domain catchall account # info: add mail domain catchall account
# options: user domain email # options: USER DOMAIN EMAIL
# #
# The function enables catchall account for incomming emails. # The function enables catchall account for incomming emails.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
email="$3" email="$3"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain email' check_args '3' "$#" 'USER DOMAIN EMAIL'
validate_format 'user' 'domain' 'email' validate_format 'user' 'domain' 'email'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL' is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding catchall alias # Adding catchall alias
sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding antispam in config # Adding antispam in config
update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email"
# Logging # Logging
log_history "added $email as catchall email for $domain" log_history "added $email as catchall email for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,81 +1,81 @@
#!/bin/bash #!/bin/bash
# info: add mail domain dkim support # info: add mail domain dkim support
# options: user domain [dkim_size] # options: USER DOMAIN [DKIM_SIZE]
# #
# The function adds DKIM signature to outgoing domain emails. # The function adds DKIM signature to outgoing domain emails.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
dkim_size=${3-512} dkim_size=${3-512}
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain [dkim_size]' check_args '2' "$#" 'USER DOMAIN [DKIM_SIZE]'
validate_format 'user' 'domain' 'dkim_size' validate_format 'user' 'domain' 'dkim_size'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM' is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Generating dkim # Generating dkim
openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null
openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \
-out $USER_DATA/mail/$domain.pub &>/dev/null -out $USER_DATA/mail/$domain.pub &>/dev/null
chmod 660 $USER_DATA/mail/$domain.* chmod 660 $USER_DATA/mail/$domain.*
# Adding dkim to config # Adding dkim to config
cp $USER_DATA/mail/$domain.pem $HOMEDIR/$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 chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem
chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem
# Checking dns domain # Checking dns domain
check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain")
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
# Adding dkim dns records # Adding dkim dns records
p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n')
record='_domainkey' record='_domainkey'
policy="\"t=y; o=~;\"" policy="\"t=y; o=~;\""
$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' record='mail._domainkey'
selector="\"k=rsa\; p=$p\"" selector="\"k=rsa\; p=$p\""
$BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector"
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding dkim in config # Adding dkim in config
update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes' update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes'
increase_user_value "$user" '$U_MAIL_DKMI' increase_user_value "$user" '$U_MAIL_DKMI'
# Logging # Logging
log_history "enabled DKIM support for $domain" log_history "enabled DKIM support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,100 +1,100 @@
#!/bin/bash #!/bin/bash
# info: add system ip address # info: add system ip address
# options: ip mask [interface] [user] [ip_status] [ip_name] # options: IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]
# #
# The function adds ip address into a system. It also creates rc scripts. You # The function adds ip address into a system. It also creates rc scripts. You
# can specify ip name which will be used as root domain for temporary aliases. # can specify ip name which will be used as root domain for temporary aliases.
# For example, if you set a1.myhosting.com as name, each new domain created on # For example, if you set a1.myhosting.com as name, each new domain created on
# this ip will automaticaly receive alias $domain.a1.myhosting.com. Of course # this ip will automaticaly receive alias $domain.a1.myhosting.com. Of course
# you must have wildcard record *.a1.myhosting.com pointed to ip. This feature # you must have wildcard record *.a1.myhosting.com pointed to ip. This feature
# is very handy when customer wants to test domain before dns migration. # is very handy when customer wants to test domain before dns migration.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
ip=${1// /} ip=${1// /}
mask=$2 mask=$2
interface="${3-eth0}" interface="${3-eth0}"
user="${4-admin}" user="${4-admin}"
ip_status="${5-shared}" # can be dedicated as well ip_status="${5-shared}" # can be dedicated as well
ip_name=$6 ip_name=$6
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'ip mask [interface] [user] [ip_status] [ip_name]' check_args '2' "$#" 'IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]'
validate_format 'ip' 'mask' 'interface' 'user' 'ip_status' validate_format 'ip' 'mask' 'interface' 'user' 'ip_status'
is_ip_free is_ip_free
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
if [ ! -z "$ip_name" ] ; then if [ ! -z "$ip_name" ] ; then
validate_format 'ip_name' validate_format 'ip_name'
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get full interface name # Get full interface name
get_ip_iface get_ip_iface
# Defining config paths # Defining config paths
conf='/etc/httpd/conf.d/vesta.conf' conf='/etc/httpd/conf.d/vesta.conf'
nconf='/etc/nginx/conf.d/vesta_ip.conf' nconf='/etc/nginx/conf.d/vesta_ip.conf'
iconf='/etc/sysconfig/network-scripts/ifcfg' iconf='/etc/sysconfig/network-scripts/ifcfg'
rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf'
# Adding ip # Adding ip
/sbin/ifconfig "$iface" "$ip" netmask "$mask" /sbin/ifconfig "$iface" "$ip" netmask "$mask"
# Adding startup script # Adding startup script
create_ip_startup create_ip_startup
# Adding vesta ip # Adding vesta ip
create_vesta_ip create_vesta_ip
# Namehosting support # Namehosting support
namehost_ip_support namehost_ip_support
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Updating user counters # Updating user counters
increase_user_value "$user" '$IP_OWNED' increase_user_value "$user" '$IP_OWNED'
if [ "$user" = 'admin' ]; then if [ "$user" = 'admin' ]; then
if [ "$ip_status" = 'shared' ]; then if [ "$ip_status" = 'shared' ]; then
for user in $(ls $VESTA/data/users); do for user in $(ls $VESTA/data/users); do
increase_user_value "$user" '$IP_AVAIL' increase_user_value "$user" '$IP_AVAIL'
done done
else else
increase_user_value 'admin' '$IP_AVAIL' increase_user_value 'admin' '$IP_AVAIL'
fi fi
else else
increase_user_value "$user" '$IP_AVAIL' increase_user_value "$user" '$IP_AVAIL'
increase_user_value 'admin' '$IP_AVAIL' increase_user_value 'admin' '$IP_AVAIL'
fi fi
# Restart web server # Restart web server
if [ "$web_restart" = 'yes' ]; then if [ "$web_restart" = 'yes' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "added system ip address $ip" '' 'admin' log_history "added system ip address $ip" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,218 +1,218 @@
#!/bin/bash #!/bin/bash
# info: add system user # info: add system user
# options: user password email [package] [fname] [lname] # options: USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]
# #
# The function creates new user account. # The function creates new user account.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
password=$2 password=$2
email=$3 email=$3
package=${4-default} package=${4-default}
fname=$5 fname=$5
lname=$6 lname=$6
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
# Hiding password # Hiding password
A2='******' A2='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
is_user_free() { is_user_free() {
check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
echo "Error: user $user exist" echo "Error: user $user exist"
log_event "$E_EXISTS" "$EVENT" log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS exit $E_EXISTS
fi fi
} }
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user password email [package] [fname] [lname]' check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]'
validate_format 'user' 'password' 'email' 'package' validate_format 'user' 'password' 'email' 'package'
if [ ! -z "$fname" ]; then if [ ! -z "$fname" ]; then
validate_format 'fname' 'lname' validate_format 'fname' 'lname'
fi fi
is_user_free "$user" is_user_free "$user"
is_package_valid is_package_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing package data # Parsing package data
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE) pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE)
# Checking shell # Checking shell
shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \') shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \')
shell=$(/usr/bin/chsh --list-shells | grep -w "$shell_conf" |head -n1) shell=$(/usr/bin/chsh --list-shells | grep -w "$shell_conf" |head -n1)
# Adding user # Adding user
/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" /usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
# Adding password # Adding password
echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null
# Building directory tree # Building directory tree
mkdir $HOMEDIR/$user/conf mkdir $HOMEDIR/$user/conf
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
mkdir $HOMEDIR/$user/conf/web mkdir $HOMEDIR/$user/conf/web
mkdir $HOMEDIR/$user/web mkdir $HOMEDIR/$user/web
mkdir $HOMEDIR/$user/tmp mkdir $HOMEDIR/$user/tmp
chmod 751 $HOMEDIR/$user/conf/web chmod 751 $HOMEDIR/$user/conf/web
chmod 751 $HOMEDIR/$user/web chmod 751 $HOMEDIR/$user/web
chmod 771 $HOMEDIR/$user/tmp chmod 771 $HOMEDIR/$user/tmp
chown $user:$user $HOMEDIR/$user/web chown $user:$user $HOMEDIR/$user/web
chown $user:$user $HOMEDIR/$user/tmp chown $user:$user $HOMEDIR/$user/tmp
fi fi
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
mkdir $HOMEDIR/$user/conf/mail mkdir $HOMEDIR/$user/conf/mail
mkdir $HOMEDIR/$user/mail mkdir $HOMEDIR/$user/mail
chmod 751 $HOMEDIR/$user/mail chmod 751 $HOMEDIR/$user/mail
chmod 751 $HOMEDIR/$user/conf/mail chmod 751 $HOMEDIR/$user/conf/mail
fi fi
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
mkdir $HOMEDIR/$user/conf/dns mkdir $HOMEDIR/$user/conf/dns
chmod 751 $HOMEDIR/$user/conf/dns chmod 751 $HOMEDIR/$user/conf/dns
fi fi
# Set permissions # Set permissions
chmod a+x $HOMEDIR/$user chmod a+x $HOMEDIR/$user
# Checking quota # Checking quota
if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then
DISK_QUOTA=$(echo "$pkg_data" | grep 'DISK_QUOTA' | cut -f 2 -d \') DISK_QUOTA=$(echo "$pkg_data" | grep 'DISK_QUOTA' | cut -f 2 -d \')
#$BIN/v-add-user_quota "$user" "$DISK_QUOTA" #$BIN/v-add-user_quota "$user" "$DISK_QUOTA"
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding user dir # Adding user dir
mkdir $USER_DATA mkdir $USER_DATA
chmod 770 $USER_DATA chmod 770 $USER_DATA
# Creating configuration files and pipes # Creating configuration files and pipes
touch $USER_DATA/backup.conf touch $USER_DATA/backup.conf
chmod 660 $USER_DATA/backup.conf chmod 660 $USER_DATA/backup.conf
touch $USER_DATA/history.log touch $USER_DATA/history.log
chmod 660 $USER_DATA/history.log chmod 660 $USER_DATA/history.log
touch $USER_DATA/stats.log touch $USER_DATA/stats.log
chmod 660 $USER_DATA/stats.log chmod 660 $USER_DATA/stats.log
echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
mkdir $USER_DATA/ssl mkdir $USER_DATA/ssl
chmod 770 $USER_DATA/ssl chmod 770 $USER_DATA/ssl
touch $USER_DATA/web.conf touch $USER_DATA/web.conf
chmod 660 $USER_DATA/web.conf chmod 660 $USER_DATA/web.conf
echo "$BIN/v-update-web-domains-traff $user" \ echo "$BIN/v-update-web-domains-traff $user" \
>> $VESTA/data/queue/traffic.pipe >> $VESTA/data/queue/traffic.pipe
echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe
fi fi
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
mkdir $USER_DATA/dns mkdir $USER_DATA/dns
chmod 770 $USER_DATA/dns chmod 770 $USER_DATA/dns
touch $USER_DATA/dns.conf touch $USER_DATA/dns.conf
chmod 660 $USER_DATA/dns.conf chmod 660 $USER_DATA/dns.conf
fi fi
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
mkdir $USER_DATA/mail mkdir $USER_DATA/mail
chmod 770 $USER_DATA/mail chmod 770 $USER_DATA/mail
touch $USER_DATA/mail.conf touch $USER_DATA/mail.conf
chmod 660 $USER_DATA/mail.conf chmod 660 $USER_DATA/mail.conf
echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe
fi fi
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
touch $USER_DATA/db.conf touch $USER_DATA/db.conf
chmod 660 $USER_DATA/db.conf chmod 660 $USER_DATA/db.conf
echo "v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe echo "v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe
fi fi
if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then
touch $USER_DATA/cron.conf touch $USER_DATA/cron.conf
chmod 660 $USER_DATA/cron.conf chmod 660 $USER_DATA/cron.conf
fi fi
# Filling user config # Filling user config
if [ "$user" != 'admin' ]; then if [ "$user" != 'admin' ]; then
ip_avail=$($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 u_users=0
else else
ip_avail=0 ip_avail=0
u_users=1 u_users=1
fi fi
echo "FNAME='$fname' echo "FNAME='$fname'
LNAME='$lname' LNAME='$lname'
PACKAGE='$package' PACKAGE='$package'
$pkg_data $pkg_data
CONTACT='$email' CONTACT='$email'
CRON_REPORTS='yes' CRON_REPORTS='yes'
MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)' MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)'
RKEY='$(gen_password)' RKEY='$(gen_password)'
SUSPENDED='no' SUSPENDED='no'
SUSPENDED_USERS='0' SUSPENDED_USERS='0'
SUSPENDED_WEB='0' SUSPENDED_WEB='0'
SUSPENDED_DNS='0' SUSPENDED_DNS='0'
SUSPENDED_MAIL='0' SUSPENDED_MAIL='0'
SUSPENDED_DB='0' SUSPENDED_DB='0'
SUSPENDED_CRON='0' SUSPENDED_CRON='0'
IP_AVAIL='$ip_avail' IP_AVAIL='$ip_avail'
IP_OWNED='0' IP_OWNED='0'
U_USERS='$u_users' U_USERS='$u_users'
U_DISK='0' U_DISK='0'
U_DISK_DIRS='0' U_DISK_DIRS='0'
U_DISK_WEB='0' U_DISK_WEB='0'
U_DISK_MAIL='0' U_DISK_MAIL='0'
U_DISK_DB='0' U_DISK_DB='0'
U_BANDWIDTH='0' U_BANDWIDTH='0'
U_WEB_DOMAINS='0' U_WEB_DOMAINS='0'
U_WEB_SSL='0' U_WEB_SSL='0'
U_WEB_ALIASES='0' U_WEB_ALIASES='0'
U_DNS_DOMAINS='0' U_DNS_DOMAINS='0'
U_DNS_RECORDS='0' U_DNS_RECORDS='0'
U_MAIL_DOMAINS='0' U_MAIL_DOMAINS='0'
U_MAIL_DKIM='0' U_MAIL_DKIM='0'
U_MAIL_ACCOUNTS='0' U_MAIL_ACCOUNTS='0'
U_DATABASES='0' U_DATABASES='0'
U_CRON_JOBS='0' U_CRON_JOBS='0'
U_BACKUPS='0' U_BACKUPS='0'
TIME='$TIME' TIME='$TIME'
DATE='$DATE'" > $USER_DATA/user.conf DATE='$DATE'" > $USER_DATA/user.conf
chmod 660 $USER_DATA/user.conf chmod 660 $USER_DATA/user.conf
# Updating admin counter # Updating admin counter
if [ "$user" != 'admin' ]; then if [ "$user" != 'admin' ]; then
increase_user_value 'admin' '$U_USERS' increase_user_value 'admin' '$U_USERS'
fi fi
# Logging # Logging
log_history "added system user $user" '' 'admin' log_history "added system user $user" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,46 +1,46 @@
#!/bin/bash #!/bin/bash
# info: schedule user backup creation # info: schedule user backup creation
# options: user # options: USER
# #
# The function for scheduling user backup creation. # The function for scheduling user backup creation.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_system_enabled "$BACKUP_SYSTEM" is_system_enabled "$BACKUP_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_backup_enabled is_backup_enabled
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding backup to pipe # Adding backup to pipe
echo "$user" >> $VESTA/data/queue/backup.pipe echo "$user" >> $VESTA/data/queue/backup.pipe
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: adding user package # info: adding user package
# options: pkg_dir package [rewrite] # options: PKG_DIR PACKAGE [REWRITE]
# #
# The function adds new user package to the system. # The function adds new user package to the system.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
pkg_dir=$1 pkg_dir=$1
package=$2 package=$2
rewrite=$3 rewrite=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
# Functions # Functions
is_package_new() { is_package_new() {
if [ -e "$VESTA/data/packages/$package.pkg" ]; then if [ -e "$VESTA/data/packages/$package.pkg" ]; then
echo "Error: package $package already exists." echo "Error: package $package already exists."
log_event "$E_EXISTS" "$EVENT" log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS exit $E_EXISTS
fi fi
} }
is_package_consistent() { is_package_consistent() {
source $pkg_dir/$package.pkg source $pkg_dir/$package.pkg
validate_format_int $WEB_DOMAINS validate_format_int $WEB_DOMAINS
validate_format_int $WEB_ALIASES validate_format_int $WEB_ALIASES
validate_format_int $DNS_DOMAINS validate_format_int $DNS_DOMAINS
validate_format_int $DNS_RECORDS validate_format_int $DNS_RECORDS
validate_format_int $MAIL_DOMAINS validate_format_int $MAIL_DOMAINS
validate_format_int $MAIL_ACCOUNTS validate_format_int $MAIL_ACCOUNTS
validate_format_int $DATABASES validate_format_int $DATABASES
validate_format_int $CRON_JOBS validate_format_int $CRON_JOBS
validate_format_int $DISK_QUOTA validate_format_int $DISK_QUOTA
validate_format_int $BACKUPS validate_format_int $BACKUPS
validate_format_shell $SHELL validate_format_shell $SHELL
} }
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'pkg_dir package' 'rewrite' check_args '2' "$#" 'PKG_DIR PACKAGE' 'rewrite'
validate_format 'pkg_dir' 'package' validate_format 'pkg_dir' 'package'
if [ "$rewrite" != 'yes' ]; then if [ "$rewrite" != 'yes' ]; then
is_package_new is_package_new
fi fi
is_package_valid "$pkg_dir" is_package_valid "$pkg_dir"
is_package_consistent is_package_consistent
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
cp -f $pkg_dir/$package.pkg $VESTA/data/packages/ cp -f $pkg_dir/$package.pkg $VESTA/data/packages/
chmod 644 $VESTA/data/packages/$package.pkg chmod 644 $VESTA/data/packages/$package.pkg
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
if [ "$rewrite" != 'yes' ]; then if [ "$rewrite" != 'yes' ]; then
log_history "added user package $package" '' 'admin' log_history "added user package $package" '' 'admin'
else else
log_history "updated user package $package" '' 'admin' log_history "updated user package $package" '' 'admin'
fi fi
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,190 +1,190 @@
#!/bin/bash #!/bin/bash
# info: add web domain # info: add web domain
# options: user domain ip [template] [restart] # options: USER DOMAIN IP [TEMPLATE] [RESTART]
# #
# The function adds virtual host to a server. In cases when a template is # The function adds virtual host to a server. In cases when a template is
# undefined in the script, the template "default" will be used. The alias of # undefined in the script, the template "default" will be used. The alias of
# www.domain.tld type will be automatically assigned to the domain. If ip have # www.domain.tld type will be automatically assigned to the domain. If ip have
# assocated dns name, this domain will also get the alias domain-tpl.$ipname. # assocated dns name, this domain will also get the alias domain-tpl.$ipname.
# An alias with the ip name is useful during the site testing while dns isn't # An alias with the ip name is useful during the site testing while dns isn't
# moved to a server yet. # moved to a server yet.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ip=$3 ip=$3
template=$4 template=$4
restart=$5 restart=$5
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ip [template] [restart]' check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [RESTART]'
validate_format 'user' 'domain' 'ip' validate_format 'user' 'domain' 'ip'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_domain_new 'web' is_domain_new 'web'
is_ip_valid is_ip_valid
is_ip_avalable is_ip_avalable
is_package_full 'WEB_DOMAINS' is_package_full 'WEB_DOMAINS'
if [ ! -z "$template" ]; then if [ ! -z "$template" ]; then
validate_format 'template' validate_format 'template'
is_apache_template_valid is_apache_template_valid
else else
template=$(get_user_value '$TEMPLATE') template=$(get_user_value '$TEMPLATE')
is_apache_template_valid is_apache_template_valid
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining domain aliases # Defining domain aliases
IP=$ip IP=$ip
ip_name=$(get_ip_name) ip_name=$(get_ip_name)
ip_name_idn=$(idn -t --quiet -a "$ip_name") ip_name_idn=$(idn -t --quiet -a "$ip_name")
domain_alias="www.$domain" domain_alias="www.$domain"
domain_alias_idn="www.$domain_idn" domain_alias_idn="www.$domain_idn"
if [ ! -z "$ip_name" ]; then if [ ! -z "$ip_name" ]; then
domain_alias_dash="${domain//./-}.$ip_name" domain_alias_dash="${domain//./-}.$ip_name"
domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn"
aliases="$domain_alias,$domain_alias_dash" aliases="$domain_alias,$domain_alias_dash"
aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" aliases_idn="$domain_alias_idn,$domain_alias_dash_idn"
alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn" alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn"
else else
aliases="$domain_alias" aliases="$domain_alias"
aliases_idn="$domain_alias_idn" aliases_idn="$domain_alias_idn"
alias_string="ServerAlias $domain_alias_idn" alias_string="ServerAlias $domain_alias_idn"
fi fi
# Defining vars for add_config function # Defining vars for add_config function
group="$user" group="$user"
email="$user@$domain" email="$user@$domain"
docroot="$HOMEDIR/$user/web/$domain/public_html" docroot="$HOMEDIR/$user/web/$domain/public_html"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$template.tpl" tpl_file="$WEBTPL/apache_$template.tpl"
elog='' elog=''
cgi='' cgi=''
cgi_option='+ExecCGI' cgi_option='+ExecCGI'
# Adding domain to the httpd.conf # Adding domain to the httpd.conf
add_web_config add_web_config
# Building directory tree # Building directory tree
mkdir $HOMEDIR/$user/web/$domain \ mkdir $HOMEDIR/$user/web/$domain \
$HOMEDIR/$user/web/$domain/public_html \ $HOMEDIR/$user/web/$domain/public_html \
$HOMEDIR/$user/web/$domain/public_shtml \ $HOMEDIR/$user/web/$domain/public_shtml \
$HOMEDIR/$user/web/$domain/document_errors \ $HOMEDIR/$user/web/$domain/document_errors \
$HOMEDIR/$user/web/$domain/cgi-bin \ $HOMEDIR/$user/web/$domain/cgi-bin \
$HOMEDIR/$user/web/$domain/private \ $HOMEDIR/$user/web/$domain/private \
$HOMEDIR/$user/web/$domain/stats \ $HOMEDIR/$user/web/$domain/stats \
$HOMEDIR/$user/web/$domain/logs $HOMEDIR/$user/web/$domain/logs
# Adding domain logs # Adding domain logs
touch /var/log/httpd/domains/$domain.bytes \ touch /var/log/httpd/domains/$domain.bytes \
/var/log/httpd/domains/$domain.log \ /var/log/httpd/domains/$domain.log \
/var/log/httpd/domains/$domain.error.log /var/log/httpd/domains/$domain.error.log
# Adding symlink for logs # Adding symlink for logs
ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/ ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/
# Adding domain skeleton # Adding domain skeleton
if [ -e "$WEBTPL/skel/public_html/" ]; then if [ -e "$WEBTPL/skel/public_html/" ]; then
cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/ cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/
fi fi
if [ -e "$WEBTPL/skel/public_shtml/" ]; then if [ -e "$WEBTPL/skel/public_shtml/" ]; then
cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/ cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/
fi fi
if [ -e "$WEBTPL/skel/document_errors/" ]; then if [ -e "$WEBTPL/skel/document_errors/" ]; then
cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/
fi fi
if [ -e "$WEBTPL/skel/cgi-bin/" ]; then if [ -e "$WEBTPL/skel/cgi-bin/" ]; then
cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/ cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/
fi fi
# Changing tpl values # Changing tpl values
for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do
sed -i "s/%domain%/$domain/g" $file sed -i "s/%domain%/$domain/g" $file
done done
# Changing file owner # Changing file owner
chown -R $user:$user $HOMEDIR/$user/web/$domain chown -R $user:$user $HOMEDIR/$user/web/$domain
chown root:$user /var/log/httpd/domains/$domain.* chown root:$user /var/log/httpd/domains/$domain.*
chown root:apache $conf chown root:apache $conf
# Changing file permissions # Changing file permissions
chmod 660 $conf chmod 660 $conf
chmod 551 $HOMEDIR/$user/web/$domain chmod 551 $HOMEDIR/$user/web/$domain
chmod 771 $HOMEDIR/$user/web/$domain/private chmod 771 $HOMEDIR/$user/web/$domain/private
chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
chmod 771 $HOMEDIR/$user/web/$domain/public_html chmod 771 $HOMEDIR/$user/web/$domain/public_html
chmod 771 $HOMEDIR/$user/web/$domain/public_shtml chmod 771 $HOMEDIR/$user/web/$domain/public_shtml
chmod 771 $HOMEDIR/$user/web/$domain/document_errors chmod 771 $HOMEDIR/$user/web/$domain/document_errors
chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/*
chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/* chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/*
chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/* chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/*
chmod 551 $HOMEDIR/$user/web/$domain/stats chmod 551 $HOMEDIR/$user/web/$domain/stats
chmod 551 $HOMEDIR/$user/web/$domain/logs chmod 551 $HOMEDIR/$user/web/$domain/logs
chmod 640 /var/log/httpd/domains/$domain.* chmod 640 /var/log/httpd/domains/$domain.*
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
fi fi
# Checking main vesta httpd config # Checking main vesta httpd config
main_conf='/etc/httpd/conf.d/vesta.conf' main_conf='/etc/httpd/conf.d/vesta.conf'
main_conf_check=$(grep "$conf" $main_conf ) main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then if [ -z "$main_conf_check" ]; then
echo "Include $conf" >>$main_conf echo "Include $conf" >>$main_conf
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing counters # Increasing counters
increase_ip_value "$ip" increase_ip_value "$ip"
increase_user_value "$user" '$U_WEB_DOMAINS' increase_user_value "$user" '$U_WEB_DOMAINS'
increase_user_value "$user" '$U_WEB_ALIASES' increase_user_value "$user" '$U_WEB_ALIASES'
# Defining domain variables # Defining domain variables
str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'" str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'"
str="$str CGI='yes' ELOG='yes' SSL='no' SSL_HOME='same' FTP_USER=''" str="$str CGI='yes' ELOG='yes' SSL='no' SSL_HOME='same' FTP_USER=''"
str="$str FTP_MD5='' NGINX='' NGINX_EXT='' STATS='' STATS_USER=''" str="$str FTP_MD5='' NGINX='' NGINX_EXT='' STATS='' STATS_USER=''"
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'" str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
str="$str TIME='$TIME' DATE='$DATE'" str="$str TIME='$TIME' DATE='$DATE'"
# Registering domain # Registering domain
echo "$str" >> $USER_DATA/web.conf echo "$str" >> $USER_DATA/web.conf
chmod 660 $USER_DATA/web.conf chmod 660 $USER_DATA/web.conf
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "added web domain $domain" log_history "added web domain $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,109 +1,109 @@
#!/bin/bash #!/bin/bash
# info: add web domain alias # info: add web domain alias
# options: user domain alias [restart] # options: USER DOMAIN ALIAS [RESTART]
# #
# The call is intended for adding aliases to a domain (it is also called # The call is intended for adding aliases to a domain (it is also called
# "domain parking"). The function supports wildcards *.domain.tpl. # "domain parking"). The function supports wildcards *.domain.tpl.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
dom_alias=$(idn -t --quiet -u "$3" ) dom_alias=$(idn -t --quiet -u "$3" )
dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4" restart="$4"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain dom_alias [restart]' check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]'
validate_format 'user' 'domain' 'dom_alias' validate_format 'user' 'domain' 'dom_alias'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_domain_new 'web' "$dom_alias" is_domain_new 'web' "$dom_alias"
is_package_full 'WEB_ALIASES' is_package_full 'WEB_ALIASES'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Parsing domain aliases # Parsing domain aliases
if [ -z "$ALIAS" ]; then if [ -z "$ALIAS" ]; then
ALIAS="$dom_alias" ALIAS="$dom_alias"
else else
ALIAS="$ALIAS,$dom_alias" ALIAS="$ALIAS,$dom_alias"
fi fi
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Recreating vhost # Recreating vhost
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding new alias # Adding new alias
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
# Update counters # Update counters
increase_user_value "$user" '$U_WEB_ALIASES' increase_user_value "$user" '$U_WEB_ALIASES'
# Adding task to the vesta pipe # Adding task to the vesta pipe
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
log_history "added $dom_alias as alias for $domain" log_history "added $dom_alias as alias for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,80 +1,80 @@
#!/bin/bash #!/bin/bash
# info: add cgi support for domain # info: add cgi support for domain
# options: user domain # options: USER DOMAIN
# #
# The function switches on cgi support by adding +ExecCGI directive into # The function switches on cgi support by adding +ExecCGI directive into
# webserver configuration file. The use of this function is provided for # webserver configuration file. The use of this function is provided for
# cases, when temporary cgi support is necessary, for other cases use of # cases, when temporary cgi support is necessary, for other cases use of
# templates is recommended. # templates is recommended.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI' is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
CGI='yes' CGI='yes'
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Recreating vhost # Recreating vhost
del_web_config del_web_config
add_web_config add_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config value # Update config value
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes' update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes'
# Restart web server # Restart web server
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
# Logging # Logging
log_history "enabled cgi support for $domain" log_history "enabled cgi support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,99 +1,99 @@
#!/bin/bash #!/bin/bash
# info: add error logging for domain # info: add error logging for domain
# options: user domain [restart] # options: USER DOMAIN [RESTART]
# #
# The function enables a separate ErrorLog file for a domain, accessible for # The function enables a separate ErrorLog file for a domain, accessible for
# reading by users. # reading by users.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
restart="$3" restart="$3"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain [restart]' check_args '2' "$#" 'USER DOMAIN [RESTART]'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
if [ $ELOG == 'yes' ]; then if [ $ELOG == 'yes' ]; then
exit 0 exit 0
fi fi
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
ELOG='yes' ELOG='yes'
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Recreating vhost # Recreating vhost
del_web_config del_web_config
add_web_config add_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes' update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes'
# Adding task to the vesta pipe # Adding task to the vesta pipe
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "enabled error logging for $domain" log_history "enabled error logging for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,71 +1,71 @@
#!/bin/bash #!/bin/bash
# info: add ftp account for web domain. # info: add ftp account for web domain.
# options: user domain ftp_user ftp_password # options: USER DOMAIN FTP_USER FTP_PASSWORD
# #
# The function creates addutional ftp account for web domain. # The function creates addutional ftp account for web domain.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ftp_user=${1}_${3} ftp_user=${1}_${3}
ftp_password=$4 ftp_password=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
# Hiding password # Hiding password
A4='******' A4='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain ftp_user ftp_password' check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD'
validate_format 'user' 'domain' 'ftp_user' 'ftp_password' validate_format 'user' 'domain' 'ftp_user' 'ftp_password'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get domain values # Get domain values
get_domain_values 'web' get_domain_values 'web'
if [ ! -z "$FTP_USER" ]; then if [ ! -z "$FTP_USER" ]; then
/usr/sbin/userdel $FTP_USER /usr/sbin/userdel $FTP_USER
fi fi
# Adding user # Adding user
/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ /usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \
-d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1
echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null
ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user"
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5"
# Logging # Logging
log_history "added ftp account $ftp_user for $domain" log_history "added ftp account $ftp_user for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,111 +1,111 @@
#!/bin/bash #!/bin/bash
# info: add webdomain nginx support # info: add webdomain nginx support
# options: user domain [template] [extentions] [restart] # options: USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]
# #
# The function enables nginx support for a domain. It can significantly improve # The function enables nginx support for a domain. It can significantly improve
# website speed. # website speed.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
template=$3 template=$3
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
extentions=${4-$default_extentions} extentions=${4-$default_extentions}
restart="$5" restart="$5"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain [template] [extentions] [restart]' check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]'
validate_format 'user' 'domain' 'extentions' validate_format 'user' 'domain' 'extentions'
is_system_enabled "$PROXY_SYSTEM" is_system_enabled "$PROXY_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX' is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX'
if [ ! -z "$template" ]; then if [ ! -z "$template" ]; then
validate_format 'template' validate_format 'template'
is_nginx_template_valid is_nginx_template_valid
else else
template=$(get_user_value '$TEMPLATE') template=$(get_user_value '$TEMPLATE')
is_nginx_template_valid is_nginx_template_valid
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining domain parameters # Defining domain parameters
get_domain_values 'web' get_domain_values 'web'
NGINX="$template" NGINX="$template"
NGINX_EXT="$extentions" NGINX_EXT="$extentions"
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
add_web_config add_web_config
# Set permission and ownership # Set permission and ownership
chown root:nginx $conf chown root:nginx $conf
chmod 640 $conf chmod 640 $conf
# Checking main vesta httpd config # Checking main vesta httpd config
main_conf='/etc/nginx/conf.d/vesta_users.conf' main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf ) main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf echo "include $conf;" >>$main_conf
fi fi
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf
chmod 640 $conf chmod 640 $conf
main_conf='/etc/nginx/conf.d/vesta_users.conf' main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf ) main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf echo "include $conf;" >>$main_conf
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
log_history "enabled nginx support for $domain" log_history "enabled nginx support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,136 +1,136 @@
#!/bin/bash #!/bin/bash
# info: adding ssl for domain # info: adding ssl for domain
# options: user domain ssl_dir [ssl_home] [restart] # options: USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]
# #
# The function turns on SSL support for a domain. Parameter ssl_dir is a path # The function turns on SSL support for a domain. Parameter ssl_dir is a path
# to directory where 2 or 3 ssl files can be found. Certificate file # to directory where 2 or 3 ssl files can be found. Certificate file
# domain.tld.crt and its key domain.tld.key are mandatory. Certificate # domain.tld.crt and its key domain.tld.key are mandatory. Certificate
# authority domain.tld.ca file is optional. If home directory parameter # authority domain.tld.ca file is optional. If home directory parameter
# (ssl_home) is not set, https domain uses public_shtml as separate # (ssl_home) is not set, https domain uses public_shtml as separate
# documentroot directory. # documentroot directory.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ssl_dir=$3 ssl_dir=$3
ssl_home=${4-same} ssl_home=${4-same}
restart="$5" restart="$5"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ssl_dir [ssl_home] [restart]' check_args '3' "$#" 'USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]'
validate_format 'user' 'domain' 'ssl_dir' validate_format 'user' 'domain' 'ssl_dir'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL' is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL'
is_ip_owner is_ip_owner
is_web_domain_cert_valid is_web_domain_cert_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding certificate to user data directory # Adding certificate to user data directory
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt 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.key $USER_DATA/ssl/$domain.key
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem
if [ -e "$ssl_dir/$domain.ca" ]; then if [ -e "$ssl_dir/$domain.ca" ]; then
cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca
cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem
fi fi
chmod 660 $USER_DATA/ssl/$domain.* chmod 660 $USER_DATA/ssl/$domain.*
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
SSL_HOME="$ssl_home" SSL_HOME="$ssl_home"
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Adding domain to the shttpd.conf # Adding domain to the shttpd.conf
add_web_config add_web_config
chown root:apache $conf chown root:apache $conf
chmod 640 $conf chmod 640 $conf
# Adding certificate to user dir # Adding certificate to user dir
cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt 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.key $HOMEDIR/$user/conf/web/ssl.$domain.key
cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca
fi fi
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot
fi fi
# Checking main vesta httpd config # Checking main vesta httpd config
main_conf='/etc/httpd/conf.d/vesta.conf' main_conf='/etc/httpd/conf.d/vesta.conf'
main_conf_check=$(grep "$conf" $main_conf ) main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then if [ -z "$main_conf_check" ]; then
echo "Include $conf" >> $main_conf echo "Include $conf" >> $main_conf
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf # Adding domain to the snginx.conf
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf
chmod 640 $conf chmod 640 $conf
# Checking vesta nginx config # Checking vesta nginx config
main_conf='/etc/nginx/conf.d/vesta_users.conf' main_conf='/etc/nginx/conf.d/vesta_users.conf'
main_conf_check=$(grep "$conf" $main_conf ) main_conf_check=$(grep "$conf" $main_conf )
if [ -z "$main_conf_check" ]; then if [ -z "$main_conf_check" ]; then
echo "include $conf;" >>$main_conf echo "include $conf;" >>$main_conf
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Increasing domain value # Increasing domain value
increase_user_value "$user" '$U_WEB_SSL' increase_user_value "$user" '$U_WEB_SSL'
# Adding ssl values # Adding ssl values
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "enabled ssl support for $domain" log_history "enabled ssl support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,91 +1,91 @@
#!/bin/bash #!/bin/bash
# info: add log analyzer to generate domain statitics # info: add log analyzer to generate domain statitics
# options: user domain type # options: USER DOMAIN TYPE
# #
# The call is used for enabling log analyzer system to a domain. At this time # The call is used for enabling log analyzer system to a domain. At this time
# two types of these system is supported - awstats and webalizer. For viewing # two types of these system is supported - awstats and webalizer. For viewing
# the domain statistics use http://domain.tld/vstats/ link. Access this page # the domain statistics use http://domain.tld/vstats/ link. Access this page
# is not protected by default. If you want to secure it with passwords you # is not protected by default. If you want to secure it with passwords you
# should use v-add-web-domain_stat_auth script. # should use v-add-web-domain_stat_auth script.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
type=$3 type=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain type' check_args '3' "$#" 'USER DOMAIN TYPE'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_type_valid "$STATS_SYSTEM" "$type" is_type_valid "$STATS_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user" "$user" is_object_valid 'user' 'USER' "$user" "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS' is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parse aliases # Parse aliases
get_domain_values 'web' get_domain_values 'web'
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Adding statistic config # Adding statistic config
cat $WEBTPL/$type.tpl |\ cat $WEBTPL/$type.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" \ -e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \ -e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \ -e "s/%user%/$user/g" \
-e "s/%home%/${HOMEDIR////\/}/g" \ -e "s/%home%/${HOMEDIR////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \ -e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $HOMEDIR/$user/conf/web/$type.$domain.conf > $HOMEDIR/$user/conf/web/$type.$domain.conf
if [ "$type" == 'awstats' ]; then if [ "$type" == 'awstats' ]; then
ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf /etc/awstats/ ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf /etc/awstats/
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Schedule statistic processing # Schedule statistic processing
echo "$BIN/v-update-web-domain-stat $user $domain" >> \ echo "$BIN/v-update-web-domain-stat $user $domain" >> \
$VESTA/data/queue/webstats.pipe $VESTA/data/queue/webstats.pipe
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
# Logging # Logging
log_history "enabled web log analyzer for $domain" log_history "enabled web log analyzer for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
# Build stats # Build stats
exec $BIN/v-update-web-domain-stat $user $domain exec $BIN/v-update-web-domain-stat $user $domain
exit exit

View file

@ -1,72 +1,72 @@
#!/bin/bash #!/bin/bash
# info: add password protection to web domain statistics # info: add password protection to web domain statistics
# options: user domain stats_user stats_password # options: USER DOMAIN STATS_USER STATS_PASSWORD
# #
# The call is used for securing the web statistics page. # The call is used for securing the web statistics page.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
stats_user=$3 stats_user=$3
stats_pass=$4 stats_pass=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
# Hiding password # Hiding password
A4='******' A4='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain stats_user stats_pass' check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS'
validate_format 'user' 'domain' 'stats_user' 'stats_pass' validate_format 'user' 'domain' 'stats_user' 'stats_pass'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Definining statistic dir # Definining statistic dir
stats_dir="$HOMEDIR/$user/web/$domain/stats" stats_dir="$HOMEDIR/$user/web/$domain/stats"
# Adding htaccess file # Adding htaccess file
echo "AuthUserFile $stats_dir/.htpasswd echo "AuthUserFile $stats_dir/.htpasswd
AuthName \"Web Statistics\" AuthName \"Web Statistics\"
AuthType Basic AuthType Basic
Require valid-user" > $stats_dir/.htaccess Require valid-user" > $stats_dir/.htaccess
# Generating htaccess user and password # Generating htaccess user and password
rm -f $stats_dir/.htpasswd rm -f $stats_dir/.htpasswd
htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null
stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :) stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :)
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding stats user in config # Adding stats user in config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user"
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt" update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt"
# Logging # Logging
log_history "added password protection for web stats on $domain" log_history "added password protection for web stats on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

File diff suppressed because it is too large Load diff

View file

@ -1,39 +1,39 @@
#!/bin/bash #!/bin/bash
# info: backup all users # info: backup all users
# options: none # options: NONE
# #
# The function backups all system users. # The function backups all system users.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Importing system enviroment as we run this script # Importing system enviroment as we run this script
# mostly by cron wich not read it by itself # mostly by cron wich not read it by itself
source /etc/profile source /etc/profile
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
for user in $(ls $VESTA/data/users); do for user in $(ls $VESTA/data/users); do
check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf) check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf)
if [ ! -z "$check_suspend" ]; then if [ ! -z "$check_suspend" ]; then
$BIN/v-backup-user $user >> $VESTA/log/backup.log 2>&1 $BIN/v-backup-user $user >> $VESTA/log/backup.log 2>&1
fi fi
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# No Logging # No Logging
#log_event "$OK" "$EVENT" #log_event "$OK" "$EVENT"
exit exit

View file

@ -1,73 +1,73 @@
#!/bin/bash #!/bin/bash
# info: change cron job # info: change cron job
# options: user job min hour day month wday command # options: USER JOB MIN HOUR DAY MONTH WDAY COMMAND
# #
# The function is used for changing existing job. It fully replace job # The function is used for changing existing job. It fully replace job
# parameters with new one but with same id. # parameters with new one but with same id.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
job=$2 job=$2
min=$3 min=$3
hour=$4 hour=$4
day=$5 day=$5
month=$6 month=$6
wday=$7 wday=$7
command=$8 command=$8
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '7' "$#" 'user job min hour day month wday command' check_args '7' "$#" 'USER JOB MIN HOUR DAY MONTH WDAY COMMAND'
validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command'
is_system_enabled $CRON_SYSTEM is_system_enabled $CRON_SYSTEM
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job" is_object_valid 'cron' 'JOB' "$job"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Concatenating cron string # Concatenating cron string
command=$(echo $command | sed -e "s/'/%quote%/g" -e "s/:/%dots%/g") 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="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'"
str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
# Deleting old job # Deleting old job
sed -i "/JOB='$job' /d" $USER_DATA/cron.conf sed -i "/JOB='$job' /d" $USER_DATA/cron.conf
# Adding new # Adding new
echo "$str" >> $USER_DATA/cron.conf echo "$str" >> $USER_DATA/cron.conf
# Sorting jobs by id # Sorting jobs by id
sort_cron_jobs sort_cron_jobs
# Sync system cron with user # Sync system cron with user
sync_cron_jobs sync_cron_jobs
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart crond # Restart crond
$BIN/v-restart-cron "$EVENT" $BIN/v-restart-cron "$EVENT"
# Logging # Logging
log_history "changed cron job $job" log_history "changed cron job $job"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,65 +1,65 @@
#!/bin/bash #!/bin/bash
# info: change database password # info: change database password
# options: user database dbpass # options: USER DATABASE DBPASS
# #
# The function for changing database user password to a database. It uses the # The function for changing database user password to a database. It uses the
# full name of database as argument. # full name of database as argument.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
database=$2 database=$2
dbpass=$3 dbpass=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/db.sh source $VESTA/func/db.sh
# Hiding password # Hiding password
A3='******' A3='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user database dbpass' check_args '3' "$#" 'USER DATABASE DBPASS'
validate_format 'user' 'database' 'dbpass' validate_format 'user' 'database' 'dbpass'
is_system_enabled "$DB_SYSTEM" is_system_enabled "$DB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'db' 'DB' "$database" is_object_valid 'db' 'DB' "$database"
is_object_unsuspended 'db' 'DB' "$database" is_object_unsuspended 'db' 'DB' "$database"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get database values # Get database values
get_database_values get_database_values
case $TYPE in case $TYPE in
mysql) change_mysql_password ;; mysql) change_mysql_password ;;
pgsql) change_pgsql_password ;; pgsql) change_pgsql_password ;;
esac esac
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config value # Update config value
update_object_value 'db' 'DB' "$database" '$MD5' "$md5" update_object_value 'db' 'DB' "$database" '$MD5' "$md5"
# Logging # Logging
log_history "changed $database database password" log_history "changed $database database password"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,53 +1,53 @@
#!/bin/bash #!/bin/bash
# info: change dns domain expiriation date # info: change dns domain expiriation date
# options: user domain exp # options: USER DOMAIN EXP
# #
# The function of changing the term of expiration domain's registration. The # The function of changing the term of expiration domain's registration. The
# serial number will be refreshed automatically during update. # serial number will be refreshed automatically during update.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
exp=$3 exp=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain exp' check_args '3' "$#" 'USER DOMAIN EXP'
validate_format 'user' 'domain' 'exp' validate_format 'user' 'domain' 'exp'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing exp # Changing exp
update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp" update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed whois expiriation date for $domain" log_history "changed whois expiriation date for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,69 +1,69 @@
#!/bin/bash #!/bin/bash
# info: change dns domain ip address # info: change dns domain ip address
# options: user domain ip # options: USER DOMAIN IP
# #
# The function for changing the main ip of DNS zone. # The function for changing the main ip of DNS zone.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ip=$3 ip=$3
restart=$4 restart=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ip' check_args '3' "$#" 'USER DOMAIN IP'
validate_format 'user' 'domain' 'ip' validate_format 'user' 'domain' 'ip'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get old ip # Get old ip
get_domain_values 'dns' get_domain_values 'dns'
old=$IP old=$IP
# Changing ip # Changing ip
update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip"
# Changing records # Changing records
sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart named # Restart named
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
fi fi
# Logging # Logging
log_history "changed dns ip for $domain to $ip" log_history "changed dns ip for $domain to $ip"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,77 +1,77 @@
#!/bin/bash #!/bin/bash
# info: change dns domain record # info: change dns domain record
# options: user domain id value [priority] # options: USER DOMAIN ID VALUE [PRIORITY]
# #
# The function for changing DNS record. # The function for changing DNS record.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
id=$3 id=$3
dvalue=$(idn -t --quiet -u "$4" ) dvalue=$(idn -t --quiet -u "$4" )
dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]') dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]')
priority=$5 priority=$5
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain id value [priority]' check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY]'
validate_format 'user' 'domain' 'id' 'dvalue' validate_format 'user' 'domain' 'id' 'dvalue'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_object_valid "dns/$domain" 'ID' "$id" is_object_valid "dns/$domain" 'ID' "$id"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting old record # Deleting old record
line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
eval $line eval $line
if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then
priority='' priority=''
fi fi
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
# Adding record # Adding record
dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'" dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'"
dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
echo "$dns_rec" >> $USER_DATA/dns/$domain.conf echo "$dns_rec" >> $USER_DATA/dns/$domain.conf
# Sorting records # Sorting records
sort_dns_records sort_dns_records
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart named # Restart named
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
# Logging # Logging
log_history "changed dns record on $domain to $dvalue" log_history "changed dns record on $domain to $dvalue"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,63 +1,63 @@
#!/bin/bash #!/bin/bash
# info: change dns domain soa record # info: change dns domain soa record
# options: user domain soa # options: USER DOMAIN SOA
# #
# The function for changing SOA record. This type of records can not be # The function for changing SOA record. This type of records can not be
# modified by v-change-dns-domain-record call. # modified by v-change-dns-domain-record call.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
restart=$4 restart=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain soa' check_args '3' "$#" 'USER DOMAIN SOA'
validate_format 'user' 'domain' 'soa' validate_format 'user' 'domain' 'soa'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing soa # Changing soa
update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa" update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart named # Restart named
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
fi fi
# Logging # Logging
log_history "changed soa record for $domain to $soa" log_history "changed soa record for $domain to $soa"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,84 +1,84 @@
#!/bin/bash #!/bin/bash
# info: change dns domain template # info: change dns domain template
# options: user domain # options: USER DOMAIN
# #
# The function for changing the template of records. By updating old records # The function for changing the template of records. By updating old records
# will be removed and new records will be generated in accordance with # will be removed and new records will be generated in accordance with
# parameters of new template. # parameters of new template.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
template=$3 template=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain template' check_args '3' "$#" 'USER DOMAIN TEMPLATE'
validate_format 'user' 'domain' 'template' validate_format 'user' 'domain' 'template'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_dns_template_valid is_dns_template_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining variables # Defining variables
ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP') ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP')
i=1 i=1
ns=$(get_user_value '$NS') ns=$(get_user_value '$NS')
for nameserver in ${ns//,/ };do for nameserver in ${ns//,/ };do
eval ns$i=$nameserver eval ns$i=$nameserver
(( ++i)) (( ++i))
done done
# Changing tpl # Changing tpl
update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template" update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
# Adding zone to dns dir # Adding zone to dns dir
cat $DNSTPL/$template.tpl |\ cat $DNSTPL/$template.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \ -e "s/%domain%/$domain/g" \
-e "s/%ns1%/$ns1/g" \ -e "s/%ns1%/$ns1/g" \
-e "s/%ns2%/$ns2/g" \ -e "s/%ns2%/$ns2/g" \
-e "s/%ns3%/$ns3/g" \ -e "s/%ns3%/$ns3/g" \
-e "s/%ns4%/$ns4/g" \ -e "s/%ns4%/$ns4/g" \
-e "s/%time%/$TIME/g" \ -e "s/%time%/$TIME/g" \
-e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart named # Restart named
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
# Logging # Logging
log_history "changed dns template for $domain to $template" '' 'admin' log_history "changed dns template for $domain to $template" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,62 +1,62 @@
#!/bin/bash #!/bin/bash
# info: change dns domain ttl # info: change dns domain ttl
# options: user domain ttl # options: USER DOMAIN TTL
# #
# The function for chaning the time to live TTL parameter for all records. # The function for chaning the time to live TTL parameter for all records.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ttl=$3 ttl=$3
restart=$4 restart=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ttl' check_args '3' "$#" 'USER DOMAIN TTL'
validate_format 'user' 'domain' 'ttl' validate_format 'user' 'domain' 'ttl'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing ttl # Changing ttl
update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl" update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart named # Restart named
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
fi fi
# Logging # Logging
log_history "changed TTL for $domain to $ttl" log_history "changed TTL for $domain to $ttl"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,72 +1,72 @@
#!/bin/bash #!/bin/bash
# info: change mail account password # info: change mail account password
# options: user domain account password # options: USER DOMAIN ACCOUNT PASSWORD
# #
# The function changes email account password. # The function changes email account password.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
password=$4 password=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
# Hiding password # Hiding password
A4='******' A4='******'
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account password' check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD'
validate_format 'user' 'domain' 'account' 'password' validate_format 'user' 'domain' 'account' 'password'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
if [ -x '/usr/bin/doveadm' ]; then if [ -x '/usr/bin/doveadm' ]; then
md5=$(/usr/bin/doveadm pw -s md5 -p "$password") md5=$(/usr/bin/doveadm pw -s md5 -p "$password")
else else
md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") md5=$(/usr/sbin/dovecotpw -s md5 -p "$password")
fi fi
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update md5 # Update md5
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5"
# Logging # Logging
log_history "changed password for $account@$domain" log_history "changed password for $account@$domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,62 +1,62 @@
#!/bin/bash #!/bin/bash
# info: change mail account quota # info: change mail account quota
# options: user domain account quota # options: USER DOMAIN ACCOUNT QUOTA
# #
# The function changes email account disk quota. # The function changes email account disk quota.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
quota=$4 quota=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account quota' check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA'
validate_format 'user' 'domain' 'account' 'quota' validate_format 'user' 'domain' 'account' 'quota'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5')
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota"
echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update quota # Update quota
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota" update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota"
# Logging # Logging
log_history "changed mail quota for $account@$domain to $quota" log_history "changed mail quota for $account@$domain to $quota"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,59 +1,59 @@
#!/bin/bash #!/bin/bash
# info: change mail domain catchall email # info: change mail domain catchall email
# options: user domain email # options: USER DOMAIN EMAIL
# #
# The function changes mail domain cathcall. # The function changes mail domain cathcall.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
email="$3" email="$3"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain email' check_args '3' "$#" 'USER DOMAIN EMAIL'
validate_format 'user' 'domain' 'email' validate_format 'user' 'domain' 'email'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Change cathcall alias # Change cathcall alias
sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Change catchall in config # Change catchall in config
update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email"
# Logging # Logging
log_history "changed catchall email for $domain to $email" log_history "changed catchall email for $domain to $email"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,51 +1,51 @@
#!/bin/bash #!/bin/bash
# info: change sysconfig value # info: change sysconfig value
# options: key value # options: KEY VALUE
# #
# The function is for changing main config settings such as COMPANY_NAME or # The function is for changing main config settings such as COMPANY_NAME or
# COMPANY_EMAIL and so on. # COMPANY_EMAIL and so on.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
value=$2 value=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'key value' check_args '2' "$#" 'KEY VALUE'
validate_format 'key' validate_format 'key'
check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf)
if [ -z "$check_ckey" ]; then if [ -z "$check_ckey" ]; then
echo "Error: key $key not found" echo "Error: key $key not found"
log_event "$E_INVALID" "$EVENT" log_event "$E_INVALID" "$EVENT"
exit $E_INVALID exit $E_INVALID
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Updating conf # Updating conf
sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,47 +1,47 @@
#!/bin/bash #!/bin/bash
# info: change ip name # info: change ip name
# options: ip name # options: IP NAME
# #
# The function for changing dns domain associated with ip. # The function for changing dns domain associated with ip.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
ip=$1 ip=$1
ip_name=$2 ip_name=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'ip ip_name' check_args '2' "$#" 'IP IP_NAME'
validate_format 'ip' 'ip_name' validate_format 'ip' 'ip_name'
is_ip_valid is_ip_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing ip name # Changing ip name
update_ip_value '$NAME' "$ip_name" update_ip_value '$NAME' "$ip_name"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed associated dns on $ip to $domain" '' 'admin' log_history "changed associated dns on $ip to $domain" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,81 +1,81 @@
#!/bin/bash #!/bin/bash
# info: change ip owner # info: change ip owner
# options: ip user # options: IP USER
# #
# The function of changing ip address ownership. # The function of changing ip address ownership.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
ip=$1 ip=$1
user=$2 user=$2
# Includes # Includes
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'ip user' check_args '2' "$#" 'IP USER'
validate_format 'ip' 'user' validate_format 'ip' 'user'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_ip_valid is_ip_valid
is_ip_key_empty '$U_WEB_DOMAINS' is_ip_key_empty '$U_WEB_DOMAINS'
is_ip_key_empty '$U_SYS_USERS' is_ip_key_empty '$U_SYS_USERS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing ip owner # Changing ip owner
ip_owner=$(get_ip_value '$OWNER') ip_owner=$(get_ip_value '$OWNER')
if [ "$ip_owner" != "$user" ]; then if [ "$ip_owner" != "$user" ]; then
ip_status="$(get_ip_value '$STATUS')" ip_status="$(get_ip_value '$STATUS')"
update_ip_value '$OWNER' "$user" update_ip_value '$OWNER' "$user"
decrease_user_value "$ip_owner" '$IP_OWNED' decrease_user_value "$ip_owner" '$IP_OWNED'
if [ "$ip_owner" = 'admin' ]; then if [ "$ip_owner" = 'admin' ]; then
if [ "$ip_status" = 'shared' ]; then if [ "$ip_status" = 'shared' ]; then
for vesta_user in $(ls $VESTA/data/users); do for vesta_user in $(ls $VESTA/data/users); do
decrease_user_value "$vesta_user" '$IP_AVAIL' decrease_user_value "$vesta_user" '$IP_AVAIL'
done done
else else
decrease_user_value 'admin' '$IP_AVAIL' decrease_user_value 'admin' '$IP_AVAIL'
fi fi
else else
decrease_user_value "$ip_owner" '$IP_AVAIL' decrease_user_value "$ip_owner" '$IP_AVAIL'
decrease_user_value 'admin' '$IP_AVAIL' decrease_user_value 'admin' '$IP_AVAIL'
fi fi
increase_user_value "$user" '$IP_OWNED' increase_user_value "$user" '$IP_OWNED'
if [ "$user" = 'admin' ]; then if [ "$user" = 'admin' ]; then
if [ "$ip_status" = 'shared' ]; then if [ "$ip_status" = 'shared' ]; then
for user in $(ls $VESTA/data/users); do for user in $(ls $VESTA/data/users); do
increase_user_value "$user" '$IP_AVAIL' increase_user_value "$user" '$IP_AVAIL'
done done
else else
increase_user_value 'admin' '$IP_AVAIL' increase_user_value 'admin' '$IP_AVAIL'
fi fi
else else
increase_user_value "$user" '$IP_AVAIL' increase_user_value "$user" '$IP_AVAIL'
increase_user_value 'admin' '$IP_AVAIL' increase_user_value 'admin' '$IP_AVAIL'
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed owner of $ip to $user" '' 'admin' log_history "changed owner of $ip to $user" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,60 +1,60 @@
#!/bin/bash #!/bin/bash
# info: change ip status # info: change ip status
# options: ip ip_status # options: IP IP_STATUS
# #
# The function of changing an ip address's status. # The function of changing an ip address's status.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
ip=$1 ip=$1
ip_status=$2 ip_status=$2
# Includes # Includes
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'ip ip_status' check_args '2' "$#" 'IP IP_STATUS'
validate_format 'ip' 'ip_status' validate_format 'ip' 'ip_status'
is_ip_valid is_ip_valid
if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then
echo "Error: status $ip_status is already set" echo "Error: status $ip_status is already set"
log_event "$E_EXISTS" "$EVENT" log_event "$E_EXISTS" "$EVENT"
exit $E_EXISTS exit $E_EXISTS
fi fi
web_domains=$(get_ip_value '$U_WEB_DOMAINS') web_domains=$(get_ip_value '$U_WEB_DOMAINS')
sys_user=$(get_ip_value '$U_SYS_USERS') sys_user=$(get_ip_value '$U_SYS_USERS')
ip_owner=$(get_ip_value '$OWNER') ip_owner=$(get_ip_value '$OWNER')
if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
echo "Error: ip $ip is used" echo "Error: ip $ip is used"
log_event "$E_INUSE" "$EVENT" log_event "$E_INUSE" "$EVENT"
exit $E_INUSE exit $E_INUSE
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing ip name # Changing ip name
update_ip_value '$STATUS' "$ip_status" update_ip_value '$STATUS' "$ip_status"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed $ip status to $ip_status" '' 'admin' log_history "changed $ip status to $ip_status" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,51 +1,51 @@
#!/bin/bash #!/bin/bash
# info: change user contact email # info: change user contact email
# options: user email # options: USER EMAIL
# #
# The function for changing of e-mail associated with a certain user. # The function for changing of e-mail associated with a certain user.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
email=$2 email=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user email' check_args '2' "$#" 'USER EMAIL'
validate_format 'user' 'email' validate_format 'user' 'email'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user contact email # Changing user contact email
old_email=$(get_user_value '$CONTACT') old_email=$(get_user_value '$CONTACT')
update_user_value "$user" '$CONTACT' "$email" update_user_value "$user" '$CONTACT' "$email"
pw_str=$(grep -n "^$user:" /etc/passwd) pw_str=$(grep -n "^$user:" /etc/passwd)
str=$(echo "$pw_str" | cut -f 1 -d :) str=$(echo "$pw_str" | cut -f 1 -d :)
sed -i "$str s/$old_email/$email/g" /etc/passwd sed -i "$str s/$old_email/$email/g" /etc/passwd
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed contact email to $email" log_history "changed contact email to $email"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,53 +1,53 @@
#!/bin/bash #!/bin/bash
# info: change user full name # info: change user full name
# options: user fname lname # options: USER FNAME LNAME
# #
# The function allow to change user's full name. # The function allow to change user's full name.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
fname=$2 fname=$2
lname=$3 lname=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user fname lname' check_args '3' "$#" 'USER FNAME LNAME'
validate_format 'user' 'fname' 'lname' validate_format 'user' 'fname' 'lname'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get old values # Get old values
old_fname=$(get_user_value '$FNAME') old_fname=$(get_user_value '$FNAME')
old_lname=$(get_user_value '$LNAME') old_lname=$(get_user_value '$LNAME')
# Changing ns values # Changing ns values
update_user_value "$user" '$FNAME' "$fname" update_user_value "$user" '$FNAME' "$fname"
update_user_value "$user" '$LNAME' "$lname" update_user_value "$user" '$LNAME' "$lname"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed user name to $fname $lname" log_history "changed user name to $fname $lname"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,66 +1,66 @@
#!/bin/bash #!/bin/bash
# info: change user nameservers # info: change user nameservers
# options: user ns1 ns2 [ns3] [ns4] # options: USER NS1 NS2 [NS3] [NS4]
# #
# The function for changing default nameservers for speciefic user. # The function for changing default nameservers for speciefic user.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
ns3=$4 ns3=$4
ns4=$5 ns4=$5
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
# Checking args # Checking args
check_args '3' "$#" 'user ns1 ns2 [ns3] [ns4]' check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]'
# Checking argument format # Checking argument format
validate_format 'user' 'ns1' 'ns2' validate_format 'user' 'ns1' 'ns2'
if [ ! -z "$ns3" ]; then if [ ! -z "$ns3" ]; then
ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns3' validate_format 'ns3'
fi fi
if [ ! -z "$ns4" ]; then if [ ! -z "$ns4" ]; then
ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
validate_format 'ns4' validate_format 'ns4'
fi fi
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Merging values # Merging values
ns="$ns1,$ns2,$ns3,$ns4" ns="$ns1,$ns2,$ns3,$ns4"
ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//") ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//")
# Changing ns values # Changing ns values
update_user_value "$user" '$NS' "$ns" update_user_value "$user" '$NS' "$ns"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed user nameservers to $ns1, $ns2" log_history "changed user nameservers to $ns1, $ns2"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,144 +1,144 @@
#!/bin/bash #!/bin/bash
# info: change user package # info: change user package
# options: user package [force] # options: USER PACKAGE [FORCE]
# #
# The function changes user's hosting package. # The function changes user's hosting package.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
package=$2 package=$2
force=$3 force=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
is_package_avalable() { is_package_avalable() {
# Parsing user data # Parsing user data
usr_data=$(cat $USER_DATA/user.conf) usr_data=$(cat $USER_DATA/user.conf)
IFS=$'\n' IFS=$'\n'
for key in $usr_data; do for key in $usr_data; do
eval ${key%%=*}=${key#*=} eval ${key%%=*}=${key#*=}
done done
WEB_DOMAINS='0' WEB_DOMAINS='0'
DATABASES='0' DATABASES='0'
MAIL_DOMAINS='0' MAIL_DOMAINS='0'
DNS_DOMAINS='0' DNS_DOMAINS='0'
DISK_QUOTA='0' DISK_QUOTA='0'
BANDWIDTH='0' BANDWIDTH='0'
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\
grep -v DATE) grep -v DATE)
eval $pkg_data eval $pkg_data
# Comparing user data with package # Comparing user data with package
if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\ if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\
[[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\ [[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\
[[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\ [[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\
[[ "$DATABASES" -lt "$U_DATABASES" ]] ||\ [[ "$DATABASES" -lt "$U_DATABASES" ]] ||\
[[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\ [[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\
[[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\ [[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\
[[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then [[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then
echo "Error: Package not cover current usage" echo "Error: Package not cover current usage"
log_event "$E_LIMIT" "$EVENT" log_event "$E_LIMIT" "$EVENT"
exit $E_LIMIT exit $E_LIMIT
fi fi
} }
change_user_package() { change_user_package() {
usr_data=$(cat $USER_DATA/user.conf) usr_data=$(cat $USER_DATA/user.conf)
eval $usr_data eval $usr_data
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\
grep -v DATE) grep -v DATE)
eval $pkg_data eval $pkg_data
echo "FNAME='$FNAME' echo "FNAME='$FNAME'
LNAME='$LNAME' LNAME='$LNAME'
PACKAGE='$package' PACKAGE='$package'
TEMPLATE='$TEMPLATE' TEMPLATE='$TEMPLATE'
WEB_DOMAINS='$WEB_DOMAINS' WEB_DOMAINS='$WEB_DOMAINS'
WEB_ALIASES='$WEB_ALIASES' WEB_ALIASES='$WEB_ALIASES'
DNS_DOMAINS='$DNS_DOMAINS' DNS_DOMAINS='$DNS_DOMAINS'
DNS_RECORDS='$DNS_RECORDS' DNS_RECORDS='$DNS_RECORDS'
MAIL_DOMAINS='$MAIL_DOMAINS' MAIL_DOMAINS='$MAIL_DOMAINS'
MAIL_ACCOUNTS='$MAIL_ACCOUNTS' MAIL_ACCOUNTS='$MAIL_ACCOUNTS'
DATABASES='$DATABASES' DATABASES='$DATABASES'
CRON_JOBS='$CRON_JOBS' CRON_JOBS='$CRON_JOBS'
DISK_QUOTA='$DISK_QUOTA' DISK_QUOTA='$DISK_QUOTA'
BANDWIDTH='$BANDWIDTH' BANDWIDTH='$BANDWIDTH'
NS='$NS' NS='$NS'
SHELL='$SHELL' SHELL='$SHELL'
BACKUPS='$BACKUPS' BACKUPS='$BACKUPS'
CONTACT='$CONTACT' CONTACT='$CONTACT'
CRON_REPORTS='$CRON_REPORTS' CRON_REPORTS='$CRON_REPORTS'
MD5='$MD5' MD5='$MD5'
RKEY='$RKEY' RKEY='$RKEY'
SUSPENDED='$SUSPENDED' SUSPENDED='$SUSPENDED'
SUSPENDED_USERS='$SUSPENDED_USERS' SUSPENDED_USERS='$SUSPENDED_USERS'
SUSPENDED_WEB='$SUSPENDED_WEB' SUSPENDED_WEB='$SUSPENDED_WEB'
SUSPENDED_DNS='$SUSPENDED_DNS' SUSPENDED_DNS='$SUSPENDED_DNS'
SUSPENDED_MAIL='$SUSPENDED_MAIL' SUSPENDED_MAIL='$SUSPENDED_MAIL'
SUSPENDED_DB='$SUSPENDED_DB' SUSPENDED_DB='$SUSPENDED_DB'
SUSPENDED_CRON='$SUSPENDED_CRON' SUSPENDED_CRON='$SUSPENDED_CRON'
IP_AVAIL='$IP_AVAIL' IP_AVAIL='$IP_AVAIL'
IP_OWNED='$IP_OWNED' IP_OWNED='$IP_OWNED'
U_USERS='$U_USERS' U_USERS='$U_USERS'
U_DISK='$U_DISK' U_DISK='$U_DISK'
U_DISK_DIRS='$U_DISK_DIRS' U_DISK_DIRS='$U_DISK_DIRS'
U_DISK_WEB='$U_DISK_WEB' U_DISK_WEB='$U_DISK_WEB'
U_DISK_MAIL='$U_DISK_MAIL' U_DISK_MAIL='$U_DISK_MAIL'
U_DISK_DB='$U_DISK_DB' U_DISK_DB='$U_DISK_DB'
U_BANDWIDTH='$U_BANDWIDTH' U_BANDWIDTH='$U_BANDWIDTH'
U_WEB_DOMAINS='$U_WEB_DOMAINS' U_WEB_DOMAINS='$U_WEB_DOMAINS'
U_WEB_SSL='$U_WEB_SSL' U_WEB_SSL='$U_WEB_SSL'
U_WEB_ALIASES='$U_WEB_ALIASES' U_WEB_ALIASES='$U_WEB_ALIASES'
U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_DOMAINS='$U_DNS_DOMAINS'
U_DNS_RECORDS='$U_DNS_RECORDS' U_DNS_RECORDS='$U_DNS_RECORDS'
U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DOMAINS='$U_MAIL_DOMAINS'
U_MAIL_DKIM='$U_MAIL_DKIM' U_MAIL_DKIM='$U_MAIL_DKIM'
U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS'
U_DATABASES='$U_DATABASES' U_DATABASES='$U_DATABASES'
U_CRON_JOBS='$U_CRON_JOBS' U_CRON_JOBS='$U_CRON_JOBS'
U_BACKUPS='$U_BACKUPS' U_BACKUPS='$U_BACKUPS'
TIME='$TIME' TIME='$TIME'
DATE='$DATE'" > $USER_DATA/user.conf DATE='$DATE'" > $USER_DATA/user.conf
} }
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user package [force]' check_args '2' "$#" 'USER PACKAGE [FORCE]'
validate_format 'user' 'package' validate_format 'user' 'package'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_package_valid is_package_valid
if [ "$force" != 'yes' ];then if [ "$force" != 'yes' ];then
is_package_avalable is_package_avalable
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user package # Changing user package
change_user_package change_user_package
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "changed $user package to $package" '' 'admin' log_history "changed $user package to $package" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,57 +1,57 @@
#!/bin/bash #!/bin/bash
# info: change user password # info: change user password
# options: user password # options: USER PASSWORD
# #
# The function changes user's password and updates RKEY value. # The function changes user's password and updates RKEY value.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
password=$2 password=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
# Hiding password # Hiding password
A2="******" A2="******"
EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'" EVENT="DATE='$DATE' TIME='$TIME' CMD='$SCRIPT' A1='$A1' A2='$A2' A3='$A3'"
EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'" EVENT="$EVENT A4='$A4' A5='$A5' A6='$A6' A7='$A7' A8='$A8' A9='$A9'"
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user password' check_args '2' "$#" 'USER PASSWORD'
validate_format 'user' 'password' validate_format 'user' 'password'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user password # Changing user password
echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null
md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing RKEY value # Changing RKEY value
update_user_value "$user" '$RKEY' "$(gen_password)" update_user_value "$user" '$RKEY' "$(gen_password)"
update_user_value "$user" '$MD5' "$md5" update_user_value "$user" '$MD5' "$md5"
# Logging # Logging
log_history "changed password" log_history "changed password"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,54 +1,54 @@
#!/bin/bash #!/bin/bash
# info: change user shell # info: change user shell
# options: user shell # options: USER SHELL
# #
# The function changes system shell of a user. Shell gives abilty to use ssh. # The function changes system shell of a user. Shell gives abilty to use ssh.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
shell=$2 shell=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user shell' check_args '2' "$#" 'USER SHELL'
validate_format 'user' 'shell' validate_format 'user' 'shell'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get shell full path # Get shell full path
shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1) shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1)
# Changing passwd file # Changing passwd file
/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null /usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
shell=$(basename $shell_path) shell=$(basename $shell_path)
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user shell # Changing user shell
update_user_value "$user" '$SHELL' "$shell" update_user_value "$user" '$SHELL' "$shell"
# Logging # Logging
log_history "changed $user shell to $shell" '' 'admin' log_history "changed $user shell to $shell" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,49 +1,49 @@
#!/bin/bash #!/bin/bash
# info: change user default template # info: change user default template
# options: user template # options: USER TEMPLATE
# #
# The function changes default user web template. # The function changes default user web template.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
template=$2 template=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user template' check_args '2' "$#" 'USER TEMPLATE'
validate_format 'user' 'template' validate_format 'user' 'template'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_apache_template_valid is_apache_template_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user shell # Changing user shell
update_user_value "$user" '$TEMPLATE' "$template" update_user_value "$user" '$TEMPLATE' "$template"
# Logging # Logging
log_history "changed $user template to $template" '' 'admin' log_history "changed $user template to $template" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,62 +1,62 @@
#!/bin/bash #!/bin/bash
# info: add ftp account for web domain. # info: add ftp account for web domain.
# options: user domain ftp_user ftp_password # options: USER DOMAIN FTP_USER FTP_PASSWORD
# #
# The function creates addutional ftp account for web domain. # The function creates addutional ftp account for web domain.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ftp_user=${1}_${3} ftp_user=${1}_${3}
ftp_password=$4 ftp_password=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain ftp_user ftp_password' check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD'
validate_format 'user' 'domain' 'ftp_user' 'ftp_password' validate_format 'user' 'domain' 'ftp_user' 'ftp_password'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_empty 'web' 'DOMAIN' "$domain" '$FTP_USER' is_object_value_empty 'web' 'DOMAIN' "$domain" '$FTP_USER'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding user # Adding user
/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ /usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \
-d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1
echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null echo "$ftp_password" | /usr/bin/passwd "$ftp_user" --stdin &>/dev/null
ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)" ftp_md5="$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user"
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5"
# Logging # Logging
log_history "added ftp account $ftp_user for $domain" log_history "added ftp account $ftp_user for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,96 +1,96 @@
#!/bin/bash #!/bin/bash
# info: change web domain ip address # info: change web domain ip address
# options: user domain ip [restart] # options: USER DOMAIN IP [RESTART]
# #
# The call is used for changing the site ip address. The ip change will be # The call is used for changing the site ip address. The ip change will be
# performed for a virtual apache host and for a configuration nginx file both. # performed for a virtual apache host and for a configuration nginx file both.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ip=$3 ip=$3
restart=$4 restart=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ip [restart]' check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
validate_format 'user' 'domain' 'ip' validate_format 'user' 'domain' 'ip'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_ip_valid is_ip_valid
is_ip_avalable is_ip_avalable
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Define variable for replace # Define variable for replace
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
old=$IP old=$IP
new=$ip new=$ip
replace_web_config replace_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
replace_web_config replace_web_config
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
replace_web_config replace_web_config
fi fi
# Checking nginx # Checking nginx
if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
replace_web_config replace_web_config
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update counters # Update counters
increase_ip_value "$new" increase_ip_value "$new"
decrease_ip_value "$old" decrease_ip_value "$old"
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip" update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip"
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "changed web domain $domain ip to $ip" log_history "changed web domain $domain ip to $ip"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,101 +1,101 @@
#!/bin/bash #!/bin/bash
# info: change web domain nginx template # info: change web domain nginx template
# options: user domain template [extentions] [restart] # options: USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]
# #
# The function changes template of nginx.conf configuration file. The content # The function changes template of nginx.conf configuration file. The content
# of webdomain directories remains untouched. # of webdomain directories remains untouched.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
template=$3 template=$3
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\ default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm" exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
extentions=${4-$default_extentions} extentions=${4-$default_extentions}
restart="$5" restart="$5"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain template [extentions] [restart]' check_args '3' "$#" 'USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]'
validate_format 'user' 'domain' 'template' validate_format 'user' 'domain' 'template'
is_system_enabled "$PROXY_SYSTEM" is_system_enabled "$PROXY_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
is_nginx_template_valid is_nginx_template_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
# Delete old vhost # Delete old vhost
del_web_config del_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi
# Add new vhost # Add new vhost
NGINX="$template" NGINX="$template"
NGINX_EXT="$extentions" NGINX_EXT="$extentions"
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
upd_web_domain_values upd_web_domain_values
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf
chmod 640 $conf chmod 640 $conf
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf
chmod 640 $conf chmod 640 $conf
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
# Restart web # Restart web
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "changed nginx template for $domain to $template" log_history "changed nginx template for $domain to $template"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: change domain ssl certificate # info: change domain ssl certificate
# options: user domain ssl_dir # options: USER DOMAIN SSL_DIR
# #
# The function changes SSL domain certificate and the key. If ca file present # The function changes SSL domain certificate and the key. If ca file present
# it will be replaced as well. # it will be replaced as well.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ssl_dir=$3 ssl_dir=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ssl_dir' check_args '3' "$#" 'USER DOMAIN SSL_DIR'
validate_format 'user' 'domain' 'ssl_dir' validate_format 'user' 'domain' 'ssl_dir'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
is_web_domain_cert_valid is_web_domain_cert_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting old certificate # Deleting old certificate
tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d)
rm -f $HOMEDIR/$user/conf/ssl.$domain.* rm -f $HOMEDIR/$user/conf/ssl.$domain.*
mv $USER_DATA/ssl/$domain.* $tmpdir mv $USER_DATA/ssl/$domain.* $tmpdir
chown -R $user:$user $tmpdir chown -R $user:$user $tmpdir
# Adding new certificate to user data directory # Adding new certificate to user data directory
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt 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.key $USER_DATA/ssl/$domain.key
cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem
if [ -e "$ssl_dir/$domain.ca" ]; then if [ -e "$ssl_dir/$domain.ca" ]; then
cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca
cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem
fi fi
# Adding new certificate to user dir # Adding new certificate to user dir
cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt 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.key $HOMEDIR/$user/conf/ssl.$domain.key
cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart web server # Restart web server
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
# Logging # Logging
log_history "changed ssl certificate for $domain" log_history "changed ssl certificate for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: changing domain ssl home # info: changing domain ssl home
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
ssl_home=$3 ssl_home=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain ssl_home' check_args '3' "$#" 'USER DOMAIN SSL_HOME'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get domain values # Get domain values
get_domain_values 'web' get_domain_values 'web'
old_ssl_home=$SSL_HOME old_ssl_home=$SSL_HOME
SSL_HOME=$ssl_home SSL_HOME=$ssl_home
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
# Parsing tpl_option # Parsing tpl_option
case $SSL_HOME in case $SSL_HOME in
single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; single) new="$HOMEDIR/$user/web/$domain/public_shtml" ;
old="$HOMEDIR/$user/web/$domain/public_html" ;; old="$HOMEDIR/$user/web/$domain/public_html" ;;
same) new="$HOMEDIR/$user/web/$domain/public_html" ; same) new="$HOMEDIR/$user/web/$domain/public_html" ;
old="$HOMEDIR/$user/web/$domain/public_shtml" ;; old="$HOMEDIR/$user/web/$domain/public_shtml" ;;
*) check_args '3' "2" 'user domain sslhome' *) check_args '3' "2" 'USER DOMAIN SSLHOME'
esac esac
# Changing sslhome directory # Changing sslhome directory
replace_web_config replace_web_config
# Checking nginx config # Checking nginx config
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web//snginx.conf" conf="$HOMEDIR/$user/conf/web//snginx.conf"
replace_web_config replace_web_config
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
# Restart web server # Restart web server
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
# Logging # Logging
log_history "changed ssl home for $domain to $ssl_home" log_history "changed ssl home for $domain to $ssl_home"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,95 +1,95 @@
#!/bin/bash #!/bin/bash
# info: change web domain statistics # info: change web domain statistics
# options: user domain type # options: USER DOMAIN TYPE
# #
# The function of deleting site's system of statistics. Its type is # The function of deleting site's system of statistics. Its type is
# automatically chooses from client's configuration file. # automatically chooses from client's configuration file.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
type=$3 type=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain type' check_args '3' "$#" 'USER DOMAIN TYPE'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_type_valid "$STATS_SYSTEM" "$type" is_type_valid "$STATS_SYSTEM" "$type"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining statistic type # Defining statistic type
get_domain_values 'web' get_domain_values 'web'
# Comparing stats types # Comparing stats types
if [ "$STATS" == $type ]; then if [ "$STATS" == $type ]; then
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit 0 exit 0
fi fi
# Defining statistic dir # Defining statistic dir
stats_dir="$HOMEDIR/$user/web/$domain/stats" stats_dir="$HOMEDIR/$user/web/$domain/stats"
# Deleting dir content # Deleting dir content
rm -rf $stats_dir/* rm -rf $stats_dir/*
# Deleting config # Deleting config
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Adding statistic config # Adding statistic config
cat $WEBTPL/$type.tpl |\ cat $WEBTPL/$type.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" \ -e "s/%proxy_port%/$PROXY_PORT/g" \
-e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
-e "s/%domain_idn%/$domain_idn/g" \ -e "s/%domain_idn%/$domain_idn/g" \
-e "s/%domain%/$domain/g" \ -e "s/%domain%/$domain/g" \
-e "s/%user%/$user/g" \ -e "s/%user%/$user/g" \
-e "s/%home%/${HOMEDIR////\/}/g" \ -e "s/%home%/${HOMEDIR////\/}/g" \
-e "s/%alias%/${aliases//,/ }/g" \ -e "s/%alias%/${aliases//,/ }/g" \
-e "s/%alias_idn%/${aliases_idn//,/ }/g" \ -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
> $HOMEDIR/$user/conf/web/$type.$domain.conf > $HOMEDIR/$user/conf/web/$type.$domain.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
# Logging # Logging
log_history "changed web log stats for $domain to $type" log_history "changed web log stats for $domain to $type"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
# Build stats # Build stats
exec $BIN/v-update-web-domain-stat $user $domain exec $BIN/v-update-web-domain-stat $user $domain
exit exit

View file

@ -1,110 +1,110 @@
#!/bin/bash #!/bin/bash
# info: change web domain template # info: change web domain template
# options: user domain template [restart] # options: USER DOMAIN TEMPLATE [RESTART]
# #
# The function changes template of httpd.conf configuration file. The content # The function changes template of httpd.conf configuration file. The content
# of webdomain directories remains untouched. # of webdomain directories remains untouched.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
template=$3 template=$3
restart=$4 restart=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain template [restart]' check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
validate_format 'user' 'domain' 'template' validate_format 'user' 'domain' 'template'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_apache_template_valid is_apache_template_valid
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
# Deleting domain # Deleting domain
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
old_tpl=$TPL old_tpl=$TPL
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
del_web_config del_web_config
# Deleting ssl vhost # Deleting ssl vhost
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
fi fi
# Defining variables for new vhost config # Defining variables for new vhost config
upd_web_domain_values upd_web_domain_values
tpl_file="$WEBTPL/apache_$template.tpl" tpl_file="$WEBTPL/apache_$template.tpl"
# Checking error log # Checking error log
if [ "$ELOG" = 'no' ]; then if [ "$ELOG" = 'no' ]; then
elog='#' elog='#'
else else
elog='' elog=''
fi fi
# Adding domain to the httpd.conf # Adding domain to the httpd.conf
add_web_config add_web_config
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot
fi fi
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$template.stpl" tpl_file="$WEBTPL/apache_$template.stpl"
add_web_config add_web_config
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache_$template.sh ]; then
$WEBTPL/apache_$template.sh \ $WEBTPL/apache_$template.sh \
"$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot" "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing tpl in config # Changing tpl in config
update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template" update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
# Restart web # Restart web
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "changed web domain template for $domain to $template" '' 'admin' log_history "changed web domain template for $domain to $template" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,62 +1,62 @@
#!/bin/bash #!/bin/bash
# info: delete cron job # info: delete cron job
# options: user job # options: USER JOB
# #
# The function deletes cron job. # The function deletes cron job.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
job=$2 job=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user job' check_args '2' "$#" 'USER JOB'
validate_format 'user' 'job' validate_format 'user' 'job'
is_system_enabled "$CRON_SYSTEM" is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'cron' 'JOB' "$job" is_object_valid 'cron' 'JOB' "$job"
is_object_unsuspended 'cron' 'JOB' "$job" is_object_unsuspended 'cron' 'JOB' "$job"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting job # Deleting job
sed -i "/JOB='$job' /d" $USER_DATA/cron.conf sed -i "/JOB='$job' /d" $USER_DATA/cron.conf
# Sorting jobs by id # Sorting jobs by id
sort_cron_jobs sort_cron_jobs
# Sync system cron with user # Sync system cron with user
sync_cron_jobs sync_cron_jobs
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Decreasing cron value # Decreasing cron value
decrease_user_value "$user" '$U_CRON_JOBS' decrease_user_value "$user" '$U_CRON_JOBS'
# Restart crond # Restart crond
$BIN/v-restart-cron "$EVENT" $BIN/v-restart-cron "$EVENT"
# Logging # Logging
log_history "deleted cron job $job" log_history "deleted cron job $job"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,54 +1,54 @@
#!/bin/bash #!/bin/bash
# info: delete cron reports # info: delete cron reports
# options: user # options: USER
# #
# The script for disabling reports on cron tasks and administrative # The script for disabling reports on cron tasks and administrative
# notifications. # notifications.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_system_enabled "$CRON_SYSTEM" is_system_enabled "$CRON_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Changing user report value # Changing user report value
update_user_value "$user" '$CRON_REPORTS' 'no' update_user_value "$user" '$CRON_REPORTS' 'no'
# Sync system cron with user # Sync system cron with user
sync_cron_jobs sync_cron_jobs
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart crond # Restart crond
$BIN/v-restart-cron "$EVENT" $BIN/v-restart-cron "$EVENT"
# Logging # Logging
log_history "disabled cron reporting" log_history "disabled cron reporting"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,65 +1,65 @@
#!/bin/bash #!/bin/bash
# info: delete database # info: delete database
# options: user database # options: USER DATABASE
# #
# The function for deleting the database. If database user have access to # The function for deleting the database. If database user have access to
# another database, he will not be deleted. # another database, he will not be deleted.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
database=$2 database=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/db.sh source $VESTA/func/db.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user database' check_args '2' "$#" 'USER DATABASE'
validate_format 'user' 'database' validate_format 'user' 'database'
is_system_enabled "$DB_SYSTEM" is_system_enabled "$DB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'db' 'DB' "$database" is_object_valid 'db' 'DB' "$database"
is_object_unsuspended 'db' 'DB' "$database" is_object_unsuspended 'db' 'DB' "$database"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get database values # Get database values
get_database_values get_database_values
# Switching on db type # Switching on db type
case $TYPE in case $TYPE in
mysql) delete_mysql_database ;; mysql) delete_mysql_database ;;
pgsql) delete_pgsql_database ;; pgsql) delete_pgsql_database ;;
esac esac
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting database # Deleting database
sed -i "/DB='$database' /d" $USER_DATA/db.conf sed -i "/DB='$database' /d" $USER_DATA/db.conf
# Decreasing counters # Decreasing counters
decrease_dbhost_values decrease_dbhost_values
decrease_user_value "$user" '$U_DATABASES' decrease_user_value "$user" '$U_DATABASES'
# Logging # Logging
log_history "deleted $database database" log_history "deleted $database database"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,50 +1,50 @@
#!/bin/bash #!/bin/bash
# info: delete database server # info: delete database server
# options: type host # options: TYPE HOST
# #
# The function for deleting the database host from vesta configuration. It will # The function for deleting the database host from vesta configuration. It will
# be deleted if there are no databases created on it only. # be deleted if there are no databases created on it only.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
type=$1 type=$1
host=$2 host=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/db.sh source $VESTA/func/db.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" "type host" check_args '2' "$#" 'TYPE HOST'
validate_format 'type' 'host' validate_format 'type' 'host'
is_system_enabled "$DB_SYSTEM" is_system_enabled "$DB_SYSTEM"
is_type_valid "$DB_SYSTEM" "$type" is_type_valid "$DB_SYSTEM" "$type"
is_object_valid "../../conf/$type" 'HOST' "$host" is_object_valid "../../conf/$type" 'HOST' "$host"
is_dbhost_free is_dbhost_free
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting server # Deleting server
sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "deleted $type database server $host" '' 'admin' log_history "deleted $type database server $host" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,48 +1,48 @@
#!/bin/bash #!/bin/bash
# info: delete user databases # info: delete user databases
# options: user # options: USER
# #
# The function deletes all user databases. # The function deletes all user databases.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_system_enabled "$DB_SYSTEM" is_system_enabled "$DB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Starting delete loop # Starting delete loop
for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do
$BIN/v-delete-database "$user" "$database" $BIN/v-delete-database "$user" "$database"
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,70 +1,70 @@
#!/bin/bash #!/bin/bash
# info: delete dns domain # info: delete dns domain
# options: user domain # options: USER DOMAIN
# #
# The function for deleting DNS domain. By deleting it all records will also be # The function for deleting DNS domain. By deleting it all records will also be
# deleted. # deleted.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
restart="$3" restart="$3"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ')
# Deleting domain in named.conf # Deleting domain in named.conf
sed -i "/\/$domain.db\"/d" /etc/named.conf sed -i "/\/$domain.db\"/d" /etc/named.conf
rm -f $HOMEDIR/$user/conf/dns/$domain.db rm -f $HOMEDIR/$user/conf/dns/$domain.db
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting domain # Deleting domain
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf
rm -f $USER_DATA/dns/$domain.conf rm -f $USER_DATA/dns/$domain.conf
# Decreasing domain value # Decreasing domain value
decrease_user_value "$user" '$U_DNS_DOMAINS' decrease_user_value "$user" '$U_DNS_DOMAINS'
decrease_user_value "$user" '$U_DNS_RECORDS' "$records" decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
# Restart named # Restart named
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
fi fi
# Logging # Logging
log_history "deleted dns domain $domain" log_history "deleted dns domain $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,64 +1,64 @@
#!/bin/bash #!/bin/bash
# info: delete dns record # info: delete dns record
# options: user domain id # options: USER DOMAIN ID
# #
# The function for deleting a certain record of DNS zone. # The function for deleting a certain record of DNS zone.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
id=$3 id=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain id' check_args '3' "$#" 'USER DOMAIN ID'
validate_format 'user' 'domain' 'id' validate_format 'user' 'domain' 'id'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
is_object_unsuspended 'dns' 'DOMAIN' "$domain" is_object_unsuspended 'dns' 'DOMAIN' "$domain"
is_object_valid "dns/$domain" 'ID' "$id" is_object_valid "dns/$domain" 'ID' "$id"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting record # Deleting record
sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf
# Updating zone # Updating zone
update_domain_zone update_domain_zone
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Upddate counters # Upddate counters
records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
decrease_user_value "$user" '$U_DNS_RECORDS' decrease_user_value "$user" '$U_DNS_RECORDS'
# Restart named # Restart named
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
# Logging # Logging
log_history "deleted dns record $id on $domain" log_history "deleted dns record $id on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,50 +1,50 @@
#!/bin/bash #!/bin/bash
# info: delete dns domains # info: delete dns domains
# options: user # options: USER
# #
# The function for deleting all users DNS domains. # The function for deleting all users DNS domains.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Starting delete loop # Starting delete loop
for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v-delete-dns-domain "$user" "$domain" 'no' $BIN/v-delete-dns-domain "$user" "$domain" 'no'
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart named # Restart named
$BIN/v-restart-dns "$EVENT" $BIN/v-restart-dns "$EVENT"
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: delete dns domain or dns record based on web domain alias # info: delete dns domain or dns record based on web domain alias
# options: user domain # options: USER DOMAIN
# #
# The function deletes dns domain or dns record based on web domain alias. # The function deletes dns domain or dns record based on web domain alias.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
dom_alias=$(idn -t --quiet -u "$3" ) dom_alias=$(idn -t --quiet -u "$3" )
dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4" restart="$4"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain alias' check_args '3' "$#" 'USER DOMAIN ALIAS'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_system_enabled "$DNS_SYSTEM" is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
# Check if it a simple domain # Check if it a simple domain
if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then
$BIN/v-delete-dns-domain $user $dom_alias $IP $restart $BIN/v-delete-dns-domain $user $dom_alias $IP $restart
fi fi
else else
# Check subdomain # Check subdomain
sub=$(echo "$dom_alias" | cut -f1 -d . -s) sub=$(echo "$dom_alias" | cut -f1 -d . -s)
root=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) root=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
if [ -e "$USER_DATA/dns/$root.conf" ]; then if [ -e "$USER_DATA/dns/$root.conf" ]; then
if [ "$sub" == '*' ]; then if [ "$sub" == '*' ]; then
rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf) rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf)
else else
rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf) rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf)
fi fi
if [ ! -z "$rec" ]; then if [ ! -z "$rec" ]; then
eval "$rec" eval "$rec"
$BIN/v-delete-dns-domain-record $user "$root" "$ID" $BIN/v-delete-dns-domain-record $user "$root" "$ID"
fi fi
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,70 +1,70 @@
#!/bin/bash #!/bin/bash
# info: delete mail account # info: delete mail account
# options: user domain account # options: USER DOMAIN ACCOUNT
# #
# The function deletes email account. # The function deletes email account.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain account' check_args '3' "$#" 'USER DOMAIN ACCOUNT'
validate_format 'user' 'domain' 'account' validate_format 'user' 'domain' 'account'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS')
for al in ${aliases//,/ }; do for al in ${aliases//,/ }; do
sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases
done done
sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd
rm -rf $HOMEDIR/$user/mail/$domain/$account rm -rf $HOMEDIR/$user/mail/$domain/$account
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf
# Decrease mail accounts counter # Decrease mail accounts counter
accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ')
decrease_user_value "$user" '$U_MAIL_ACCOUNTS' decrease_user_value "$user" '$U_MAIL_ACCOUNTS'
update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts"
# Logging # Logging
log_history "deleted $account@$domain mail account" log_history "deleted $account@$domain mail account"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,70 +1,70 @@
#!/bin/bash #!/bin/bash
# info: delete mail account alias aka nickname # info: delete mail account alias aka nickname
# options: user domain account alias # options: USER DOMAIN ACCOUNT ALIAS
# #
# The function deletes email account alias. # The function deletes email account alias.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
malias=$4 malias=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account alias' check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS'
validate_format 'user' 'domain' 'account' 'malias' validate_format 'user' 'domain' 'account' 'malias'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS')
if [ -z "$(echo $aliases | grep -w $malias)" ]; then if [ -z "$(echo $aliases | grep -w $malias)" ]; then
echo "Error: alias $malias is not exist" echo "Error: alias $malias is not exist"
log_event "$E_NOTEXIST $EVENT" log_event "$E_NOTEXIST $EVENT"
exit $E_NOTEXIST exit $E_NOTEXIST
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases
aliases=$(echo "$aliases" |\ aliases=$(echo "$aliases" |\
sed -e "s/,/\n/g"|\ sed -e "s/,/\n/g"|\
sed -e "s/^$malias$//g"|\ sed -e "s/^$malias$//g"|\
sed -e "/^$/d"|\ sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g') sed -e ':a;N;$!ba;s/\n/,/g')
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases"
# Logging # Logging
log_history "deleted alias $malias on $account@$domain" log_history "deleted alias $malias on $account@$domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,61 +1,61 @@
#!/bin/bash #!/bin/bash
# info: delete mail account autoreply message # info: delete mail account autoreply message
# options: user domain account alias # options: USER DOMAIN ACCOUNT ALIAS
# #
# The function delete email account autoreply. # The function delete email account autoreply.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
malias=$4 malias=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain account' check_args '3' "$#" 'USER DOMAIN ACCOUNT'
validate_format 'user' 'domain' 'account' validate_format 'user' 'domain' 'account'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg
rm -f $USER_DATA/mail/$domain/$account@$domain.msg rm -f $USER_DATA/mail/$domain/$account@$domain.msg
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no' update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no'
# Logging # Logging
log_history "$EVENT" log_history "$EVENT"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,72 +1,72 @@
#!/bin/bash #!/bin/bash
# info: delte mail account forward # info: delte mail account forward
# options: user domain account email # options: USER DOMAIN ACCOUNT EMAIL
# #
# The function add delete email account forward address. # The function add delete email account forward address.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
account=$3 account=$3
forward=$4 forward=$4
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '4' "$#" 'user domain account forward' check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD'
validate_format 'user' 'domain' 'account' 'forward' validate_format 'user' 'domain' 'account' 'forward'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account" is_object_valid "mail/$domain" 'ACCOUNT' "$account"
is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account"
fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD')
if [ -z "$(echo $fwd | grep -w $forward)" ]; then if [ -z "$(echo $fwd | grep -w $forward)" ]; then
echo "Error: forward $forward is not exist" echo "Error: forward $forward is not exist"
log_event "$E_NOTEXIST $EVENT" log_event "$E_NOTEXIST $EVENT"
exit $E_NOTEXIST exit $E_NOTEXIST
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
fwd=$(echo "$fwd" |\ fwd=$(echo "$fwd" |\
sed -e "s/,/\n/g"|\ sed -e "s/,/\n/g"|\
sed -e "s/^$forward$//g"|\ sed -e "s/^$forward$//g"|\
sed -e "/^$/d"|\ sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g') sed -e ':a;N;$!ba;s/\n/,/g')
sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases
echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd"
# Logging # Logging
log_history "deleted $forward forward on $account@$domain" log_history "deleted $forward forward on $account@$domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,72 +1,72 @@
#!/bin/bash #!/bin/bash
# info: delete mail domain # info: delete mail domain
# options: user domain # options: USER DOMAIN
# #
# The function for deleting MAIL domain. By deleting it all accounts will # The function for deleting MAIL domain. By deleting it all accounts will
# also be deleted. # also be deleted.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get domain values # Get domain values
get_domain_values 'mail' get_domain_values 'mail'
accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ')
rm -f /etc/exim/domains/$domain rm -f /etc/exim/domains/$domain
rm -rf $HOMEDIR/$user/conf/$domain rm -rf $HOMEDIR/$user/conf/$domain
rm -rf $HOMEDIR/$user/mail/$domain rm -rf $HOMEDIR/$user/mail/$domain
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete domain config # Delete domain config
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf
rm -f $USER_DATA/mail/$domain.conf rm -f $USER_DATA/mail/$domain.conf
rm -f $USER_DATA/mail/$domain.pem rm -f $USER_DATA/mail/$domain.pem
rm -f $USER_DATA/mail/$domain.pub rm -f $USER_DATA/mail/$domain.pub
rm -f $USER_DATA/mail/*@$domain.msg rm -f $USER_DATA/mail/*@$domain.msg
# Decreasing domain value # Decreasing domain value
decrease_user_value "$user" '$U_MAIL_DOMAINS' decrease_user_value "$user" '$U_MAIL_DOMAINS'
if [ "$DKIM" = 'yes' ]; then if [ "$DKIM" = 'yes' ]; then
decrease_user_value "$user" '$U_MAIL_DKMI' decrease_user_value "$user" '$U_MAIL_DKMI'
fi fi
decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts"
# Logging # Logging
log_history "deleted mail domain $domain" log_history "deleted mail domain $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,57 +1,57 @@
#!/bin/bash #!/bin/bash
# info: delete mail domain antispam support # info: delete mail domain antispam support
# options: user domain # options: USER DOMAIN
# #
# The function disable spamassasin for incomming emails. # The function disable spamassasin for incomming emails.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM' is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete antispam key # Delete antispam key
sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete antispam in config # Delete antispam in config
update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no' update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no'
# Logging # Logging
log_history "disabled antispam support for $domain" log_history "disabled antispam support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,57 +1,57 @@
#!/bin/bash #!/bin/bash
# info: delete mail domain antivirus support # info: delete mail domain antivirus support
# options: user domain # options: USER DOMAIN
# #
# The function disables clamav scan for incomming emails. # The function disables clamav scan for incomming emails.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete antivirus key # Delete antivirus key
sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete antivirus in config # Delete antivirus in config
update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no' update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no'
# Logging # Logging
log_history "disabled antivirus support on $domain" log_history "disabled antivirus support on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,57 +1,57 @@
#!/bin/bash #!/bin/bash
# info: delete mail domain catchall email # info: delete mail domain catchall email
# options: user domain # options: USER DOMAIN
# #
# The function disables mail domain cathcall. # The function disables mail domain cathcall.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL' is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete cathcall alias # Delete cathcall alias
sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Delete catchall in config # Delete catchall in config
update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' '' update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' ''
# Logging # Logging
log_history "delted catchall email on $domain" log_history "delted catchall email on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,69 +1,69 @@
#!/bin/bash #!/bin/bash
# info: delete mail domain dkim support # info: delete mail domain dkim support
# options: user domain [dkim_size] # options: USER DOMAIN [DKIM_SIZE]
# #
# The function delete DKIM domain pem. # The function delete DKIM domain pem.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain=$(echo $domain | tr '[:upper:]' '[:lower:]') domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain" is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_unsuspended 'mail' 'DOMAIN' "$domain" is_object_unsuspended 'mail' 'DOMAIN' "$domain"
is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM' is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Generating dkim # Generating dkim
rm -f $USER_DATA/mail/$domain.pem rm -f $USER_DATA/mail/$domain.pem
rm -f $USER_DATA/mail/$domain.pub rm -f $USER_DATA/mail/$domain.pub
rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem
# Checking dns domain # Checking dns domain
check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain")
if [ "$?" -eq 0 ]; then if [ "$?" -eq 0 ]; then
records=$($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 ' ') dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ')
for id in $dkim_records; do for id in $dkim_records; do
$BIN/v-delete-dns-domain-record $user $domain $id $BIN/v-delete-dns-domain-record $user $domain $id
done done
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Updatoing config # Updatoing config
update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no' update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no'
decrease_user_value "$user" '$U_MAIL_DKMI' decrease_user_value "$user" '$U_MAIL_DKMI'
# Logging # Logging
log_history "disabled DKIM support on $domain" log_history "disabled DKIM support on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,47 +1,47 @@
#!/bin/bash #!/bin/bash
# info: delete mail domains # info: delete mail domains
# options: user # options: USER
# #
# The function for deleting all users mail domains. # The function for deleting all users mail domains.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_system_enabled "$MAIL_SYSTEM" is_system_enabled "$MAIL_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Starting delete loop # Starting delete loop
for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v-delete-mail-domain "$user" "$domain" $BIN/v-delete-mail-domain "$user" "$domain"
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,94 +1,94 @@
#!/bin/bash #!/bin/bash
# info: delete system ip # info: delete system ip
# options: ip # options: IP
# #
# The function for deleting a system ip. It does not allow to delete first ip # The function for deleting a system ip. It does not allow to delete first ip
# on interface and do not allow to delete ip which is used by a web domain. # on interface and do not allow to delete ip which is used by a web domain.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
ip=$1 ip=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'ip' check_args '1' "$#" 'IP'
validate_format 'ip' validate_format 'ip'
is_ip_valid "$ip" is_ip_valid "$ip"
is_ip_key_empty '$U_WEB_DOMAINS' is_ip_key_empty '$U_WEB_DOMAINS'
is_ip_key_empty '$U_SYS_USERS' is_ip_key_empty '$U_SYS_USERS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining config paths # Defining config paths
conf='/etc/httpd/conf.d/vesta.conf' conf='/etc/httpd/conf.d/vesta.conf'
nconf='/etc/nginx/conf.d/vesta_ip.conf' nconf='/etc/nginx/conf.d/vesta_ip.conf'
iconf='/etc/sysconfig/network-scripts/ifcfg' iconf='/etc/sysconfig/network-scripts/ifcfg'
rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf'
# Get ip owner # Get ip owner
user="$(get_ip_value '$OWNER')" user="$(get_ip_value '$OWNER')"
ip_status="$(get_ip_value '$STATUS')" ip_status="$(get_ip_value '$STATUS')"
# Deleting interface # Deleting interface
get_current_interface get_current_interface
/sbin/ifconfig "$interface" down /sbin/ifconfig "$interface" down
# Deleting startup script # Deleting startup script
rm -f $iconf-$interface rm -f $iconf-$interface
# Deleting vesta ip # Deleting vesta ip
rm -f $VESTA/data/ips/$ip rm -f $VESTA/data/ips/$ip
# Deleting namehosting support # Deleting namehosting support
namehost_ip_disable namehost_ip_disable
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Updating user conf # Updating user conf
if [ ! -z "$user" ]; then if [ ! -z "$user" ]; then
decrease_user_value "$user" '$IP_OWNED' decrease_user_value "$user" '$IP_OWNED'
fi fi
if [ "$user" = 'admin' ]; then if [ "$user" = 'admin' ]; then
if [ "$ip_status" = 'shared' ]; then if [ "$ip_status" = 'shared' ]; then
for user in $(ls $VESTA/data/users/); do for user in $(ls $VESTA/data/users/); do
decrease_user_value "$user" '$IP_AVAIL' decrease_user_value "$user" '$IP_AVAIL'
done done
else else
decrease_user_value 'admin' '$IP_AVAIL' decrease_user_value 'admin' '$IP_AVAIL'
fi fi
else else
decrease_user_value "$user" '$IP_AVAIL' decrease_user_value "$user" '$IP_AVAIL'
decrease_user_value 'admin' '$IP_AVAIL' decrease_user_value 'admin' '$IP_AVAIL'
fi fi
# Adding task to the vesta pipe # Adding task to the vesta pipe
if [ "$web_restart" = 'yes' ]; then if [ "$web_restart" = 'yes' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "delted system ip address $ip" '' 'admin' log_history "delted system ip address $ip" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,113 +1,113 @@
#!/bin/bash #!/bin/bash
# info: delete user # info: delete user
# options: user # options: USER
# #
# This function deletes a certain user and all his resourses such as domains, # This function deletes a certain user and all his resourses such as domains,
# databases, cron jobs, etc. # databases, cron jobs, etc.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
restart=$2 restart=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
source $VESTA/func/db.sh source $VESTA/func/db.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
if [ "$user" = 'admin' ]; then if [ "$user" = 'admin' ]; then
exit exit
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Checking web system is enabled # Checking web system is enabled
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-web-domains $user $restart $BIN/v-unsuspend-web-domains $user $restart
$BIN/v-delete-web-domains $user $restart $BIN/v-delete-web-domains $user $restart
rv="$?" rv="$?"
if [ "$rv" -ne '0' ]; then if [ "$rv" -ne '0' ]; then
exit $rv exit $rv
fi fi
fi fi
# Checking dns system is enabled # Checking dns system is enabled
if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-dns-domains $user $restart $BIN/v-unsuspend-dns-domains $user $restart
$BIN/v-delete-dns-domains $user $restart $BIN/v-delete-dns-domains $user $restart
rv="$?" rv="$?"
if [ "$rv" -ne '0' ]; then if [ "$rv" -ne '0' ]; then
exit $rv exit $rv
fi fi
fi fi
# Checking mail system is enabled # Checking mail system is enabled
if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-mail-domains $user $BIN/v-unsuspend-mail-domains $user
$BIN/v-delete-mail-domains $user $BIN/v-delete-mail-domains $user
rv="$?" rv="$?"
if [ "$rv" -ne '0' ]; then if [ "$rv" -ne '0' ]; then
exit $rv exit $rv
fi fi
fi fi
# Checking db system is enabled # Checking db system is enabled
if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then
$BIN/v-unsuspend-databases $user $BIN/v-unsuspend-databases $user
$BIN/v-delete-databases $user $BIN/v-delete-databases $user
rv="$?" rv="$?"
if [ "$rv" -ne '0' ]; then if [ "$rv" -ne '0' ]; then
exit $rv exit $rv
fi fi
fi fi
# Checking ip # Checking ip
$BIN/v-delete-user-ips "$user" $BIN/v-delete-user-ips "$user"
rv="$?" rv="$?"
if [ "$rv" -ne '0' ]; then if [ "$rv" -ne '0' ]; then
exit $rv exit $rv
fi fi
# Deleteing user pipes # Deleteing user pipes
sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe
sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe
# Removing system user # Removing system user
/usr/sbin/userdel -f $user /usr/sbin/userdel -f $user
rm -rf $HOMEDIR/$user rm -rf $HOMEDIR/$user
rm -f /var/spool/mail/$user rm -f /var/spool/mail/$user
rm -f /var/spool/cron/$user rm -f /var/spool/cron/$user
rm -rf $USER_DATA rm -rf $USER_DATA
# Updating admin counter # Updating admin counter
if [ "$user" != 'admin' ]; then if [ "$user" != 'admin' ]; then
decrease_user_value 'admin' '$U_USERS' decrease_user_value 'admin' '$U_USERS'
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_history "deleted system user $user" '' 'admin' log_history "deleted system user $user" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,53 +1,53 @@
#!/bin/bash #!/bin/bash
# info: delete user backup # info: delete user backup
# options: user nackup # options: USER NACKUP
# #
# The function deletes user backup. # The function deletes user backup.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
backup=$(echo $2| cut -f 2 -d \.) backup=$(echo $2| cut -f 2 -d \.)
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user backup' check_args '2' "$#" 'USER BACKUP'
validate_format 'user' 'backup' validate_format 'user' 'backup'
is_system_enabled "$BACKUP_SYSTEM" is_system_enabled "$BACKUP_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'backup' 'BACKUP' "$2" is_object_valid 'backup' 'BACKUP' "$2"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting backup # Deleting backup
rm -f $BACKUP/$2 rm -f $BACKUP/$2
sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update counter # Update counter
U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l)
update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
# Logging # Logging
log_history "deleted backup archive $backup" log_history "deleted backup archive $backup"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,63 +1,63 @@
#!/bin/bash #!/bin/bash
# info: delete user ips # info: delete user ips
# options: user # options: USER
# #
# The function deletes all user's ip addresses. # The function deletes all user's ip addresses.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user' check_args '1' "$#" 'USER'
validate_format 'user' validate_format 'user'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
if [ "$user" = 'admin' ]; then if [ "$user" = 'admin' ]; then
exit exit
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing user ips # Parsing user ips
ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:)
for ip in $ip_list; do for ip in $ip_list; do
ip=$(basename $ip) ip=$(basename $ip)
# Checking webdomains and users # Checking webdomains and users
is_ip_key_empty '$U_WEB_DOMAINS' is_ip_key_empty '$U_WEB_DOMAINS'
is_ip_key_empty '$U_SYS_USERS' is_ip_key_empty '$U_SYS_USERS'
# Assig ip to main account # Assig ip to main account
update_ip_value '$OWNER' 'admin' update_ip_value '$OWNER' 'admin'
update_ip_value '$STATUS' 'dedicated' update_ip_value '$STATUS' 'dedicated'
increase_user_value 'admin' '$IP_OWNED' increase_user_value 'admin' '$IP_OWNED'
increase_user_value 'admin' '$IP_AVAIL' increase_user_value 'admin' '$IP_AVAIL'
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,55 +1,55 @@
#!/bin/bash #!/bin/bash
# info: delete user package # info: delete user package
# options: package # options: PACKAGE
# #
# The function for deleting user package. It does not allow to delete pacakge # The function for deleting user package. It does not allow to delete pacakge
# if it is in use. # if it is in use.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
package=$1 package=$1
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
# Functions # Functions
is_package_in_use() { is_package_in_use() {
check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf) check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf)
if [ ! -z "$check_package" ]; then if [ ! -z "$check_package" ]; then
echo "Error: package $package is in use" echo "Error: package $package is in use"
log_event "$E_INUSE" "$EVENT" log_event "$E_INUSE" "$EVENT"
exit $E_INUSE exit $E_INUSE
fi fi
} }
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'package' check_args '1' "$#" 'PACKAGE'
validate_format 'package' validate_format 'package'
is_package_valid is_package_valid
is_package_in_use is_package_in_use
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting user package # Deleting user package
rm -f $VESTA/data/packages/$package.pkg rm -f $VESTA/data/packages/$package.pkg
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
log_history "deleted user package $package" '' 'admin' log_history "deleted user package $package" '' 'admin'
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,165 +1,165 @@
#!/bin/bash #!/bin/bash
# info: delete web domain # info: delete web domain
# options: user domain # options: USER DOMAIN
# #
# The call of function leads to the removal of domain and all its components # The call of function leads to the removal of domain and all its components
# (statistics, folders contents, ssl certificates, etc.). This operation is # (statistics, folders contents, ssl certificates, etc.). This operation is
# not fully supported by "undo" function, so the data recovery is possible # not fully supported by "undo" function, so the data recovery is possible
# only with a help of reserve copy. # only with a help of reserve copy.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
restart=$3 restart=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
source $VESTA/func/ip.sh source $VESTA/func/ip.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Get template name # Get template name
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Deleting domain # Deleting domain
del_web_config del_web_config
# Checking aliases # Checking aliases
if [ ! -z "$ALIAS" ]; then if [ ! -z "$ALIAS" ]; then
aliases=$(echo $ALIAS | tr ',' '\n' | wc -l ) aliases=$(echo $ALIAS | tr ',' '\n' | wc -l )
else else
aliases=0 aliases=0
fi fi
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
# Deleting certificates # Deleting certificates
rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* rm -f $HOMEDIR/$user/conf/web/ssl.$domain.*
rm -f $USER_DATA/ssl/$domain.* rm -f $USER_DATA/ssl/$domain.*
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi
fi fi
# Checking stats # Checking stats
if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then
sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
rm -f /etc/awstats/$STATS.$domain.conf rm -f /etc/awstats/$STATS.$domain.conf
fi fi
# Deleting ftp account # Deleting ftp account
if [ ! -z "$FTP_USER" ]; then if [ ! -z "$FTP_USER" ]; then
/usr/sbin/userdel $FTP_USER /usr/sbin/userdel $FTP_USER
fi fi
# Deleting directory # Deleting directory
rm -rf $HOMEDIR/$user/web/$domain rm -rf $HOMEDIR/$user/web/$domain
# Deleting logs # Deleting logs
rm -f /var/log/httpd/domains/$domain.log* rm -f /var/log/httpd/domains/$domain.log*
rm -f /var/log/httpd/domains/$domain.bytes rm -f /var/log/httpd/domains/$domain.bytes
rm -f /var/log/httpd/domains/$domain.error* rm -f /var/log/httpd/domains/$domain.error*
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting domain # Deleting domain
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
# Checking last ssl domain # Checking last ssl domain
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l)
if [ "$ssl_dom" -eq '0' ]; then if [ "$ssl_dom" -eq '0' ]; then
sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf
fi fi
# Checking last domain # Checking last domain
domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ')
if [ "$domains" -eq '0' ]; then if [ "$domains" -eq '0' ]; then
conf='/etc/httpd/conf.d/vesta.conf' conf='/etc/httpd/conf.d/vesta.conf'
line=$(grep -n "$HOMEDIR/$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 if [ ! -z "$line" ]; then
sed -i "$line d" $conf sed -i "$line d" $conf
fi fi
fi fi
# Checking last nginx domain # Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf' conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then if [ -z "$last_snginx" ]; then
sline=$(grep -n "$HOMEDIR/$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 if [ ! -z "$sline" ]; then
sed -i "$sline d" $conf sed -i "$sline d" $conf
fi fi
rm -f $HOMEDIR/$user/conf/web/snginx.conf rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi fi
if [ -z "$last_nginx" ]; then if [ -z "$last_nginx" ]; then
line=$(grep -n "$HOMEDIR/$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 if [ ! -z "$line" ]; then
sed -i "$line d" $conf sed -i "$line d" $conf
fi fi
rm -f $HOMEDIR/$user/conf/web/nginx.conf rm -f $HOMEDIR/$user/conf/web/nginx.conf
fi fi
# Decrease counters # Decrease counters
decrease_ip_value "$IP" decrease_ip_value "$IP"
decrease_user_value "$user" '$U_WEB_DOMAINS' decrease_user_value "$user" '$U_WEB_DOMAINS'
decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases" decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases"
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
decrease_user_value "$user" '$U_WEB_SSL' decrease_user_value "$user" '$U_WEB_SSL'
fi fi
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "deleted web domain $domain" log_history "deleted web domain $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,108 +1,108 @@
#!/bin/bash #!/bin/bash
# info: delete web domain alias # info: delete web domain alias
# options: user domain alias [restart] # options: USER DOMAIN ALIAS [RESTART]
# #
# The function of deleting the alias domain (parked domain). By this call # The function of deleting the alias domain (parked domain). By this call
# default www aliase can be removed as well. # default www aliase can be removed as well.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain" ) domain_idn=$(idn -t --quiet -a "$domain" )
dom_alias=$(idn -t --quiet -u "$3" ) dom_alias=$(idn -t --quiet -u "$3" )
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4" restart="$4"
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain dom_alias [restart]' check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]'
validate_format 'user' 'domain' 'dom_alias' validate_format 'user' 'domain' 'dom_alias'
is_system_enabled 'WEB_SYSTEM' is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
get_domain_values 'web' get_domain_values 'web'
if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then
echo "Error: alias $dom_alias not exist" echo "Error: alias $dom_alias not exist"
log_event "$E_NOTEXIST" "$EVENT" log_event "$E_NOTEXIST" "$EVENT"
exit $E_NOTEXIST exit $E_NOTEXIST
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining new alias string # Defining new alias string
ALIAS=$(echo "$ALIAS" |\ ALIAS=$(echo "$ALIAS" |\
sed -e "s/,/\n/g"|\ sed -e "s/,/\n/g"|\
sed -e "s/^$dom_alias$//g"|\ sed -e "s/^$dom_alias$//g"|\
sed -e "/^$/d"|\ sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g') sed -e ':a;N;$!ba;s/\n/,/g')
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Recreating vhost # Recreating vhost
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
# Update counters # Update counters
decrease_user_value "$user" '$U_WEB_ALIASES' decrease_user_value "$user" '$U_WEB_ALIASES'
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "deleted alias $dom_alias on $domain" log_history "deleted alias $dom_alias on $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,79 +1,79 @@
#!/bin/bash #!/bin/bash
# info: delete web domain cgi support # info: delete web domain cgi support
# options: user domain # options: USER DOMAIN
# #
# The function for deleting cgi support (adds -ExecCGI directive into # The function for deleting cgi support (adds -ExecCGI directive into
# configuration file). It is recommended to apply this function only for a # configuration file). It is recommended to apply this function only for a
# temporary use (for lightening the consequences of DDoS, for example); # temporary use (for lightening the consequences of DDoS, for example);
# otherwise it is preferable to use templates. # otherwise it is preferable to use templates.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI' is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
CGI='no' CGI='no'
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Recreating vhost # Recreating vhost
del_web_config del_web_config
add_web_config add_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no' update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no'
# Restart web server # Restart web server
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
# Logging # Logging
log_history "disabled cgi support for $domain" log_history "disabled cgi support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,97 +1,97 @@
#!/bin/bash #!/bin/bash
# info: delete web domain error loggin support # info: delete web domain error loggin support
# options: user domain [restart] # options: USER DOMAIN [RESTART]
# #
# The function of disabling error logging feature. It comments ErrorLog # The function of disabling error logging feature. It comments ErrorLog
# direcitve in apache or/and nginx configuration. The data already collected # direcitve in apache or/and nginx configuration. The data already collected
# remains untouched. # remains untouched.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
restart=$3 restart=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain [restart]' check_args '2' "$#" 'USER DOMAIN [RESTART]'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" "$user" is_object_valid 'user' 'USER' "$user" "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG' is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
ELOG='no' ELOG='no'
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
upd_web_domain_values upd_web_domain_values
# Recreating vhost # Recreating vhost
del_web_config del_web_config
add_web_config add_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config
fi fi
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no' update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no'
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "disabled error logging for $domain" log_history "disabled error logging for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,58 +1,58 @@
#!/bin/bash #!/bin/bash
# info: delete webdomain ftp account. # info: delete webdomain ftp account.
# options: user domain # options: USER DOMAIN
# #
# The function deletes additional ftp account. # The function deletes additional ftp account.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$FTP_USER' is_object_value_exist 'web' 'DOMAIN' "$domain" '$FTP_USER'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Adding user # Adding user
get_domain_values 'web' get_domain_values 'web'
/usr/sbin/userdel $FTP_USER /usr/sbin/userdel $FTP_USER
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' '' update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' ''
update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' '' update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' ''
# Logging # Logging
log_history "deleted ftp account $FTP_USER for $domain" log_history "deleted ftp account $FTP_USER for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,87 +1,87 @@
#!/bin/bash #!/bin/bash
# info: deleting web domain nginx configuration # info: deleting web domain nginx configuration
# options: user domain # options: USER DOMAIN
# #
# The function of deleting the virtualhost nginx configuration. # The function of deleting the virtualhost nginx configuration.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
restart=$3 restart=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining domain parameters # Defining domain parameters
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx_$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' '' update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' ''
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' '' update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' ''
# Checking last nginx domain # Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf' conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then if [ -z "$last_snginx" ]; then
sed -i "/$user\/conf\/web\/snginx.conf/d" $conf sed -i "/$user\/conf\/web\/snginx.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/snginx.conf rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi fi
if [ -z "$last_nginx" ]; then if [ -z "$last_nginx" ]; then
sed -i "/$user\/conf\/web\/nginx.conf/d" $conf sed -i "/$user\/conf\/web\/nginx.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/nginx.conf rm -f $HOMEDIR/$user/conf/web/nginx.conf
fi fi
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "disabled nginx support for $domain" log_history "disabled nginx support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,101 +1,101 @@
#!/bin/bash #!/bin/bash
# info: delete web domain ssl support # info: delete web domain ssl support
# options: user domain # options: USER DOMAIN
# #
# The function disable https support and deletes SSL certificates. # The function disable https support and deletes SSL certificates.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
restart=$3 restart=$3
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache_$TPL.stpl"
# Deleting domain # Deleting domain
del_web_config del_web_config
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx_$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi
# Deleting old certificate # Deleting old certificate
tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d)
rm -f $HOMEDIR/$user/conf/ssl.$domain.* rm -f $HOMEDIR/$user/conf/ssl.$domain.*
mv $USER_DATA/ssl/$domain.* $tmpdir mv $USER_DATA/ssl/$domain.* $tmpdir
chown -R $user:$user $tmpdir chown -R $user:$user $tmpdir
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no' update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no'
# Checking last ssl domain # Checking last ssl domain
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
main_conf='/etc/httpd/conf.d/vesta.conf' main_conf='/etc/httpd/conf.d/vesta.conf'
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
if [ -z "$ssl_dom" ]; then if [ -z "$ssl_dom" ]; then
sed -i "/Include ${conf////\/}/d" $main_conf sed -i "/Include ${conf////\/}/d" $main_conf
rm -f $conf rm -f $conf
fi fi
# Checking last nginx domain # Checking last nginx domain
conf='/etc/nginx/conf.d/vesta_users.conf' conf='/etc/nginx/conf.d/vesta_users.conf'
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
if [ -z "$last_snginx" ]; then if [ -z "$last_snginx" ]; then
sed -i "/$user\/conf\/web\/snginx.conf/d" $conf sed -i "/$user\/conf\/web\/snginx.conf/d" $conf
rm -f $HOMEDIR/$user/conf/web/snginx.conf rm -f $HOMEDIR/$user/conf/web/snginx.conf
fi fi
# Decreasing domain value # Decreasing domain value
decrease_user_value "$user" '$U_WEB_SSL' decrease_user_value "$user" '$U_WEB_SSL'
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_history "disabled ssl support for $domain" log_history "disabled ssl support for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,69 +1,69 @@
#!/bin/bash #!/bin/bash
# info: delete web domain statistics # info: delete web domain statistics
# options: user domain # options: USER DOMAIN
# #
# The function of deleting site's system of statistics. Its type is # The function of deleting site's system of statistics. Its type is
# automatically chooses from client's configuration file. # automatically chooses from client's configuration file.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining statistic type # Defining statistic type
get_domain_values 'web' get_domain_values 'web'
# Defining statistic dir # Defining statistic dir
stats_dir="$HOMEDIR/$user/web/$domain/stats" stats_dir="$HOMEDIR/$user/web/$domain/stats"
# Deleting dir content # Deleting dir content
rm -rf $stats_dir/* rm -rf $stats_dir/*
# Deleting config # Deleting config
rm -f /etc/awstats/$STATS.$domain.conf rm -f /etc/awstats/$STATS.$domain.conf
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Deleting pipe command # Deleting pipe command
sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' '' update_object_value 'web' 'DOMAIN' "$domain" '$STATS' ''
# Logging # Logging
log_history "disabled web log analyzer for $domain" log_history "disabled web log analyzer for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,61 +1,61 @@
#!/bin/bash #!/bin/bash
# info: disable webdomain stats authentication support # info: disable webdomain stats authentication support
# options: user domain # options: USER DOMAIN
# #
# The function removes authentication of statistics system. If the script is # The function removes authentication of statistics system. If the script is
# called without naming a certain user, all users will be removed. After # called without naming a certain user, all users will be removed. After
# deleting all of them statistics will be accessible for view without an # deleting all of them statistics will be accessible for view without an
# authentication. # authentication.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user domain' check_args '2' "$#" 'USER DOMAIN'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain" is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER' is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER'
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Definining statistic dir # Definining statistic dir
rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd
rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Update config # Update config
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' '' update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' ''
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' '' update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' ''
# Logging # Logging
log_history "disabled web stats password protection for $domain" log_history "disabled web stats password protection for $domain"
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,53 +1,53 @@
#!/bin/bash #!/bin/bash
# info: delete web domains # info: delete web domains
# options: user [restart] # options: USER [RESTART]
# #
# The function deteles all user's webdomains. # The function deteles all user's webdomains.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
restart=$2 restart=$2
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '1' "$#" 'user [restart]' check_args '1' "$#" 'USER [RESTART]'
validate_format 'user' validate_format 'user'
is_system_enabled "$WEB_SYSTEM" is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Starting delete loop # Starting delete loop
for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
$BIN/v-delete-web-domain "$user" "$domain" 'no' $BIN/v-delete-web-domain "$user" "$domain" 'no'
done done
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Restart web server # Restart web server
if [ "$restart" != 'no' ]; then if [ "$restart" != 'no' ]; then
$BIN/v-restart-web "$EVENT" $BIN/v-restart-web "$EVENT"
fi fi
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

View file

@ -1,47 +1,47 @@
#!/bin/bash #!/bin/bash
# info: get dns domain value # info: get dns domain value
# options: user domain key # options: USER DOMAIN KEY
# #
# The function for getting a certain DNS domain parameter. # The function for getting a certain DNS domain parameter.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Includes # Includes
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain key' check_args '3' "$#" 'USER DOMAIN KEY'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_valid 'dns' 'DOMAIN' "$domain" is_object_valid 'dns' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Print # Print
get_object_value 'dns' 'DOMAIN' "$domain" "$key" get_object_value 'dns' 'DOMAIN' "$domain" "$key"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
# Logging # Logging
log_event "$OK" "$EVENT" log_event "$OK" "$EVENT"
exit exit

49
bin/v-get-mail-account-value Executable file
View file

@ -0,0 +1,49 @@
#!/bin/bash
# info: get mail account value
# options: USER DOMAIN ACCOUNT KEY
#
# The function for getting a certain mail account parameter.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
account=$3
key=$(echo "$4"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Includes
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN KEY'
validate_format 'user' 'domain'
is_object_valid 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain"
is_object_valid "mail/$domain" 'ACCOUNT' "$account"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Print
get_object_value "mail/$domain" 'ACCOUNT' "$account" "$key"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$EVENT"
exit

47
bin/v-get-mail-domain-value Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
# info: get mail domain value
# options: USER DOMAIN KEY
#
# The function for getting a certain mail domain parameter.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Includes
source $VESTA/func/main.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'USER DOMAIN KEY'
validate_format 'user' 'domain'
is_object_valid 'user' 'USER' "$user"
is_object_valid 'mail' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Print
get_object_value 'mail' 'DOMAIN' "$domain" "$key"
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$EVENT"
exit

View file

@ -1,45 +1,45 @@
#!/bin/bash #!/bin/bash
# info: get user value # info: get user value
# options: user key # options: USER KEY
# #
# The function for obtaining certain user's parameters. # The function for obtaining certain user's parameters.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user key' check_args '2' "$#" 'USER KEY'
validate_format 'user' validate_format 'user'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Checking key # Checking key
value=$(get_user_value "$key") value=$(get_user_value "$key")
# Printing value # Printing value
echo "$value" echo "$value"
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
exit exit

View file

@ -1,49 +1,49 @@
#!/bin/bash #!/bin/bash
# info: get web domain value # info: get web domain value
# options: user domain key # options: USER DOMAIN KEY
# #
# The function is intended for obtaining a domain value by the key. This call # The function is intended for obtaining a domain value by the key. This call
# is useful for arranging composite queries. The answer is displayed only in # is useful for arranging composite queries. The answer is displayed only in
# raw form; output formats aren't supported. # raw form; output formats aren't supported.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
domain=$(idn -t --quiet -u "$2" ) domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain") domain_idn=$(idn -t --quiet -a "$domain")
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
# Includes # Includes
source $VESTA/conf/vesta.conf source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh source $VESTA/func/main.sh
source $VESTA/func/domain.sh source $VESTA/func/domain.sh
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '3' "$#" 'user domain key' check_args '3' "$#" 'USER DOMAIN KEY'
validate_format 'user' 'domain' validate_format 'user' 'domain'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user" is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain" is_object_valid 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
get_domain_values 'web' get_domain_values 'web'
eval echo $key eval echo $key
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
exit exit

View file

@ -1,91 +1,91 @@
#!/bin/bash #!/bin/bash
# info: list cron job # info: list cron job
# options: user job [format] # options: USER JOB [FORMAT]
# #
# The function of obtaining cron job settings. # The function of obtaining cron job settings.
#----------------------------------------------------------# #----------------------------------------------------------#
# Variable&Function # # Variable&Function #
#----------------------------------------------------------# #----------------------------------------------------------#
# Argument defenition # Argument defenition
user=$1 user=$1
job=$2 job=$2
format=${3-shell} format=${3-shell}
# Includes # Includes
source $VESTA/func/main.sh source $VESTA/func/main.sh
# Json function # Json function
json_list_job() { json_list_job() {
i=1 i=1
fileds_count=$(echo "$fields" | wc -w) fileds_count=$(echo "$fields" | wc -w)
line=$(grep "JOB='$job'" $conf) line=$(grep "JOB='$job'" $conf)
echo '{' echo '{'
eval $line eval $line
for field in $fields; do for field in $fields; do
eval value=$field eval value=$field
value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g")
if [ "$i" -eq 1 ]; then if [ "$i" -eq 1 ]; then
echo -e "\t\"$value\": {" echo -e "\t\"$value\": {"
else else
if [ "$fileds_count" -eq "$i" ]; then if [ "$fileds_count" -eq "$i" ]; then
echo -e "\t\t\"${field//$/}\": \"$value\"" echo -e "\t\t\"${field//$/}\": \"$value\""
else else
echo -e "\t\t\"${field//$/}\": \"$value\"," echo -e "\t\t\"${field//$/}\": \"$value\","
fi fi
fi fi
(( ++i)) (( ++i))
done done
if [ -n "$value" ]; then if [ -n "$value" ]; then
echo -e ' }' echo -e ' }'
fi fi
echo -e "}" echo -e "}"
} }
# Shell function # Shell function
shell_list_job() { shell_list_job() {
line=$(grep "JOB='$job'" $conf) line=$(grep "JOB='$job'" $conf)
eval $line eval $line
for field in $fields; do for field in $fields; do
eval key="$field" eval key="$field"
if [ -z "$key" ]; then if [ -z "$key" ]; then
key=NULL key=NULL
fi fi
echo "${field//$/}: $key " echo "${field//$/}: $key "
done done
} }
#----------------------------------------------------------# #----------------------------------------------------------#
# Verifications # # Verifications #
#----------------------------------------------------------# #----------------------------------------------------------#
check_args '2' "$#" 'user job [format]' check_args '2' "$#" 'USER JOB [FORMAT]'
is_object_valid 'user' 'USER' "$user" is_object_valid 'user' 'USER' "$user"
#----------------------------------------------------------# #----------------------------------------------------------#
# Action # # Action #
#----------------------------------------------------------# #----------------------------------------------------------#
# Defining config and fields to select # Defining config and fields to select
conf=$USER_DATA/cron.conf conf=$USER_DATA/cron.conf
fields="\$JOB \$MIN \$HOUR \$DAY \$MONTH \$WDAY \$CMD \$SUSPENDED" fields="\$JOB \$MIN \$HOUR \$DAY \$MONTH \$WDAY \$CMD \$SUSPENDED"
fields="$fields \$TIME \$DATE" fields="$fields \$TIME \$DATE"
# Listing domains # Listing domains
case $format in case $format in
json) json_list_job ;; json) json_list_job ;;
plain) nohead=1; shell_list_job ;; plain) nohead=1; shell_list_job ;;
shell) shell_list_job |column -t ;; shell) shell_list_job |column -t ;;
*) check_args '2' '0' 'user job [format]' *) check_args '2' '0' 'USER JOB [FORMAT]'
esac esac
#----------------------------------------------------------# #----------------------------------------------------------#
# Vesta # # Vesta #
#----------------------------------------------------------# #----------------------------------------------------------#
exit exit

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