diff --git a/bin/v-add-cron-job b/bin/v-add-cron-job index 8b2ad562..08784e1f 100755 --- a/bin/v-add-cron-job +++ b/bin/v-add-cron-job @@ -1,81 +1,81 @@ -#!/bin/bash -# info: add cron job -# options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] -# -# 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'. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -min=$2 -hour=$3 -day=$4 -month=$5 -wday=$6 -command=$(echo $7 | sed -e "s/'/%quote%/g") -job=$8 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Assing new value -A7="$command" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB]' -validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' -is_system_enabled $CRON_SYSTEM -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_package_full 'CRON_JOBS' -get_next_cronjob -validate_format 'job' -is_object_free 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Concatenating cron string -str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" -str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" - -# Adding to crontab -echo "$str" >> $VESTA/data/users/$user/cron.conf - -# Chaning permissions -chmod 660 $VESTA/data/users/$user/cron.conf - -# Sort jobs by id number -sort_cron_jobs - -# Sync cronjobs with system crond -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing cron value -increase_user_value $user '$U_CRON_JOBS' - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "added cron job $job" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add cron job +# options: USER MIN HOUR DAY MONTH WDAY COMMAND [JOB] +# +# 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'. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +min=$2 +hour=$3 +day=$4 +month=$5 +wday=$6 +command=$(echo $7 | sed -e "s/'/%quote%/g") +job=$8 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Assing new value +A7="$command" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '7' "$#" 'USER MIN HOUR DAY MONTH WDAY COMMAND [JOB]' +validate_format 'user' 'min' 'hour' 'day' 'month' 'wday' 'command' +is_system_enabled $CRON_SYSTEM +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_package_full 'CRON_JOBS' +get_next_cronjob +validate_format 'job' +is_object_free 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Concatenating cron string +str="JOB='$job' MIN='$min' HOUR='$hour' DAY='$day' MONTH='$month' WDAY='$wday'" +str="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" + +# Adding to crontab +echo "$str" >> $VESTA/data/users/$user/cron.conf + +# Chaning permissions +chmod 660 $VESTA/data/users/$user/cron.conf + +# Sort jobs by id number +sort_cron_jobs + +# Sync cronjobs with system crond +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing cron value +increase_user_value $user '$U_CRON_JOBS' + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "added cron job $job" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-cron-report b/bin/v-add-cron-report index b40727cd..fd969bd6 100755 --- a/bin/v-add-cron-report +++ b/bin/v-add-cron-report @@ -1,54 +1,54 @@ -#!/bin/bash -# info: add cron reports -# opions: user -# -# The script for enabling reports on cron tasks and administrative -# notifications. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user report value -update_user_value "$user" '$CRON_REPORTS' 'yes' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "enabled cron reporting" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add cron reports +# opions: user +# +# The script for enabling reports on cron tasks and administrative +# notifications. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user report value +update_user_value "$user" '$CRON_REPORTS' 'yes' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "enabled cron reporting" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-database b/bin/v-add-database index aa0e9658..923a48a5 100755 --- a/bin/v-add-database +++ b/bin/v-add-database @@ -1,86 +1,86 @@ -#!/bin/bash -# info: add database -# options: USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET] -# -# The function creates the database concatenating username and user_db. -# 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, -# 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. -# "Weight" will distribute new database through hosts evenly. Algorithm and -# types of supported databases is designated in the main configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database="$user"_"$2" -dbuser="$user"_"$3" -dbpass=$4 -type=$5 -host=$6 -charset=${7-UTF8} -charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]') - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - -# Hiding password -A4='******' -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'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '5' "$#" 'USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET]' -validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset' -is_system_enabled "$DB_SYSTEM" -is_type_valid "$DB_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_free 'db' 'DB' "$database" -get_next_dbhost -is_object_valid "../../../conf/$type" 'HOST' "$host" -is_object_unsuspended "../../../conf/$type" 'HOST' "$host" -#is_charset_valid -is_package_full 'DATABASES' - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on db type -case $type in - mysql) add_mysql_database ;; - pgsql) add_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing counters -increase_dbhost_values -increase_user_value "$user" '$U_DATABASES' - -# Adding db to db conf -str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'" -str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$TIME'" -str="$str DATE='$DATE'" -echo "$str" >> $USER_DATA/db.conf -chmod 660 $USER_DATA/db.conf - -# Logging -log_history "added $type database $database" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add database +# options: USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET] +# +# The function creates the database concatenating username and user_db. +# 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, +# 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. +# "Weight" will distribute new database through hosts evenly. Algorithm and +# types of supported databases is designated in the main configuration file. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database="$user"_"$2" +dbuser="$user"_"$3" +dbpass=$4 +type=$5 +host=$6 +charset=${7-UTF8} +charset=$(echo "$charset" |tr '[:lower:]' '[:upper:]') + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + +# Hiding password +A4='******' +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'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '5' "$#" 'USER DATABASE DBUSER DBPASS TYPE [HOST] [CHARSET]' +validate_format 'user' 'database' 'dbuser' 'dbpass' 'charset' +is_system_enabled "$DB_SYSTEM" +is_type_valid "$DB_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_free 'db' 'DB' "$database" +get_next_dbhost +is_object_valid "../../../conf/$type" 'HOST' "$host" +is_object_unsuspended "../../../conf/$type" 'HOST' "$host" +#is_charset_valid +is_package_full 'DATABASES' + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on db type +case $type in + mysql) add_mysql_database ;; + pgsql) add_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing counters +increase_dbhost_values +increase_user_value "$user" '$U_DATABASES' + +# Adding db to db conf +str="DB='$database' DBUSER='$dbuser' MD5='$md5' HOST='$host' TYPE='$type'" +str="$str CHARSET='$charset' U_DISK='0' SUSPENDED='no' TIME='$TIME'" +str="$str DATE='$DATE'" +echo "$str" >> $USER_DATA/db.conf +chmod 660 $USER_DATA/db.conf + +# Logging +log_history "added $type database $database" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-database-server b/bin/v-add-database-server index 2f9e6839..48007097 100755 --- a/bin/v-add-database-server +++ b/bin/v-add-database-server @@ -1,79 +1,79 @@ -#!/bin/bash -# info: add new database server -# options: TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TEMPLATE] -# -# 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 -# 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 -# more about templates in official PostgreSQL documentation. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 -port=$3 -dbuser=$4 -dbpass=$5 -A5='******' -charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} -template=${8-template1} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - -# Hiding password -max_db=${6-500} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -args_usage='TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]' -check_args '5' "$#" "$args_usage" -validate_format 'host' 'port' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template' -is_system_enabled "$DB_SYSTEM" -is_type_valid "$DB_SYSTEM" "$type" -is_dbhost_new -case $type in - mysql) is_mysql_host_alive ;; - pgsql) is_pgsql_host_alive ;; -esac - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Concatentating db host string -case $type in - mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; - str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''"; - str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'";; - pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; - str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'"; - str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'"; - str="$str TIME='$TIME' DATE='$DATE'";; -esac - -# Adding host to conf -echo "$str" >> $VESTA/conf/$type.conf -chmod 660 $VESTA/conf/$type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "added $type database server $host" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add new database server +# options: TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TEMPLATE] +# +# 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 +# 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 +# more about templates in official PostgreSQL documentation. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 +port=$3 +dbuser=$4 +dbpass=$5 +A5='******' +charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8} +template=${8-template1} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + +# Hiding password +max_db=${6-500} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +args_usage='TYPE HOST PORT DBUSER DBPASS [MAX_DB] [CHARSETS] [TPL]' +check_args '5' "$#" "$args_usage" +validate_format 'host' 'port' 'dbuser' 'dbpass' 'max_db' 'charsets' 'template' +is_system_enabled "$DB_SYSTEM" +is_type_valid "$DB_SYSTEM" "$type" +is_dbhost_new +case $type in + mysql) is_mysql_host_alive ;; + pgsql) is_pgsql_host_alive ;; +esac + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Concatentating db host string +case $type in + mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; + str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''"; + str="$str U_DB_BASES='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'";; + pgsql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass' PORT='$port'"; + str="$str CHARSETS='$charsets' TPL='$template' MAX_DB='$max_db'"; + str="$str U_SYS_USERS='' U_DB_BASES='0' SUSPENDED='no'"; + str="$str TIME='$TIME' DATE='$DATE'";; +esac + +# Adding host to conf +echo "$str" >> $VESTA/conf/$type.conf +chmod 660 $VESTA/conf/$type.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "added $type database server $host" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-dns-domain b/bin/v-add-dns-domain index 03fc7f45..060a7103 100755 --- a/bin/v-add-dns-domain +++ b/bin/v-add-dns-domain @@ -1,143 +1,143 @@ -#!/bin/bash -# info: add dns domain -# options: USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4] [RESTART] -# -# 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. -# 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 -# its records with a default value of 14400 seconds. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -template=$4 -ns1=$5 -ns2=$6 -ns3=$7 -ns4=$8 -restart=$9 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4]' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'dns' -is_package_full 'DNS_DOMAINS' -if [ ! -z "$template" ]; then - validate_format 'template' - is_dns_template_valid -else - template=$(get_user_value '$TEMPLATE') - is_dns_template_valid -fi - -if [ ! -z "$ns1" ]; then - ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns1' -fi -if [ ! -z "$ns2" ]; then - ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns2' -fi - -if [ ! -z "$ns3" ]; then - ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns3' -fi -if [ ! -z "$ns4" ]; then - ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns4' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining variables -if [ -z $ns2 ]; then - i=1 - ns=$(get_user_value '$NS') - for nameserver in ${ns//,/ };do - eval ns$i=$nameserver - (( ++i)) - done -fi -soa="$ns1" -exp=$(date +%F -d "+ 1 year") -ttl=14400 - - -# Adding zone to dns dir -cat $DNSTPL/$template.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf -chmod 660 $USER_DATA/dns/$domain.conf -records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" - -# Adding dns.conf record -dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'" -dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'" -dns_rec="$dns_rec DATE='$DATE'" - -echo "$dns_rec" >> $USER_DATA/dns.conf -chmod 660 $USER_DATA/dns.conf - -# Adding zone in named.conf -named="zone \"$domain_idn\" {type master; file" -named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" -echo "$named" >> /etc/named.conf - -# Updating domain dns zone -update_domain_zone - -chmod 640 $conf -chown root:named $conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_DNS_DOMAINS' -increase_user_value "$user" '$U_DNS_RECORDS' "$records" - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "added dns domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add dns domain +# options: USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4] [RESTART] +# +# 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. +# 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 +# its records with a default value of 14400 seconds. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +template=$4 +ns1=$5 +ns2=$6 +ns3=$7 +ns4=$8 +restart=$9 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [NS1] [NS2] [NS3] [NS4]' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_domain_new 'dns' +is_package_full 'DNS_DOMAINS' +if [ ! -z "$template" ]; then + validate_format 'template' + is_dns_template_valid +else + template=$(get_user_value '$TEMPLATE') + is_dns_template_valid +fi + +if [ ! -z "$ns1" ]; then + ns1=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns1' +fi +if [ ! -z "$ns2" ]; then + ns2=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns2' +fi + +if [ ! -z "$ns3" ]; then + ns3=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns3' +fi +if [ ! -z "$ns4" ]; then + ns4=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns4' +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining variables +if [ -z $ns2 ]; then + i=1 + ns=$(get_user_value '$NS') + for nameserver in ${ns//,/ };do + eval ns$i=$nameserver + (( ++i)) + done +fi +soa="$ns1" +exp=$(date +%F -d "+ 1 year") +ttl=14400 + + +# Adding zone to dns dir +cat $DNSTPL/$template.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%ns1%/$ns1/g" \ + -e "s/%ns2%/$ns2/g" \ + -e "s/%ns3%/$ns3/g" \ + -e "s/%ns4%/$ns4/g" \ + -e "s/%time%/$TIME/g" \ + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf +chmod 660 $USER_DATA/dns/$domain.conf +records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')" + +# Adding dns.conf record +dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'" +dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'" +dns_rec="$dns_rec DATE='$DATE'" + +echo "$dns_rec" >> $USER_DATA/dns.conf +chmod 660 $USER_DATA/dns.conf + +# Adding zone in named.conf +named="zone \"$domain_idn\" {type master; file" +named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" +echo "$named" >> /etc/named.conf + +# Updating domain dns zone +update_domain_zone + +chmod 640 $conf +chown root:named $conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing domain value +increase_user_value "$user" '$U_DNS_DOMAINS' +increase_user_value "$user" '$U_DNS_RECORDS' "$records" + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "added dns domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-dns-domain-record b/bin/v-add-dns-domain-record index e59fbec4..12a64c3a 100755 --- a/bin/v-add-dns-domain-record +++ b/bin/v-add-dns-domain-record @@ -1,92 +1,92 @@ -#!/bin/bash -# info: add dns domain record -# options: USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART] -# -# 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 -# gets an id parameter for definition of certain record identifier or for the -# regulation of records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -record=$(idn -t --quiet -u "$3" ) -record=$(echo "$record" | tr '[:upper:]' '[:lower:]') -rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]') -dvalue=$(idn -t --quiet -u "$5" ) -dvalue=$(echo "$dvalue" | tr '[:upper:]' '[:lower:]') -priority=$6 -id=$7 -restart=$8 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '5' "$#" 'USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]' -validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_package_full 'DNS_RECORDS' -get_next_dnsrecord -validate_format 'id' -is_object_free "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then - priority='' -fi - -# Adding record -zone="$USER_DATA/dns/$domain.conf" -dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'" -dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $zone -chmod 660 $zone - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Upddate counters -records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -increase_user_value "$user" '$U_DNS_RECORDS' - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "added $rtype dns record $record for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add dns domain record +# options: USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART] +# +# 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 +# gets an id parameter for definition of certain record identifier or for the +# regulation of records. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +record=$(idn -t --quiet -u "$3" ) +record=$(echo "$record" | tr '[:upper:]' '[:lower:]') +rtype=$(echo "$4"| tr '[:lower:]' '[:upper:]') +dvalue=$(idn -t --quiet -u "$5" ) +dvalue=$(echo "$dvalue" | tr '[:upper:]' '[:lower:]') +priority=$6 +id=$7 +restart=$8 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '5' "$#" 'USER DOMAIN RECORD TYPE VALUE [PRIORITY] [ID] [RESTART]' +validate_format 'user' 'domain' 'record' 'rtype' 'dvalue' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_package_full 'DNS_RECORDS' +get_next_dnsrecord +validate_format 'id' +is_object_free "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$rtype" != 'MX' ] && [ "$rtype" != 'SRV' ]; then + priority='' +fi + +# Adding record +zone="$USER_DATA/dns/$domain.conf" +dns_rec="ID='$id' RECORD='$record' TYPE='$rtype' PRIORITY='$priority'" +dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $zone +chmod 660 $zone + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Upddate counters +records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" +update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +increase_user_value "$user" '$U_DNS_RECORDS' + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "added $rtype dns record $record for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-dns-on-web-alias b/bin/v-add-dns-on-web-alias index c5890b18..1c0077c7 100755 --- a/bin/v-add-dns-on-web-alias +++ b/bin/v-add-dns-on-web-alias @@ -1,87 +1,87 @@ -#!/bin/bash -# info: add dns domain or dns record based on web domain alias restart -# options: USER DOMAIN -# -# The function adds dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ALIAS' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Check if it a simple domain -if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then - if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-add-dns-domain \ - $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null - fi -else - # Check subdomain - sub=$(echo "$dom_alias" | cut -f1 -d . -s) - dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) - if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then - $BIN/v-add-dns-domain \ - $user $dom $IP '' '' '' '' '' $restart > /dev/null - - if [ $? -eq 0 ]; then - $BIN/v-add-dns-domain-record \ - $user $dom "$sub" A $IP '' '' $restart - fi - else - if [ "$sub" == '*' ]; then - rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) - else - rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) - fi - if [ -z "$rec" ]; then - $BIN/v-add-dns-domain-record \ - $user $dom "$sub" A $IP '' '' $restart > /dev/null - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging - -exit +#!/bin/bash +# info: add dns domain or dns record based on web domain alias restart +# options: USER DOMAIN +# +# The function adds dns domain or dns record based on web domain alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ALIAS' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Check if it a simple domain +if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then + if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then + $BIN/v-add-dns-domain \ + $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null + fi +else + # Check subdomain + sub=$(echo "$dom_alias" | cut -f1 -d . -s) + dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) + if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then + $BIN/v-add-dns-domain \ + $user $dom $IP '' '' '' '' '' $restart > /dev/null + + if [ $? -eq 0 ]; then + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart + fi + else + if [ "$sub" == '*' ]; then + rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf) + else + rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf) + fi + if [ -z "$rec" ]; then + $BIN/v-add-dns-domain-record \ + $user $dom "$sub" A $IP '' '' $restart > /dev/null + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging + +exit diff --git a/bin/v-add-mail-account b/bin/v-add-mail-account index f3e6f921..67020b5e 100755 --- a/bin/v-add-mail-account +++ b/bin/v-add-mail-account @@ -1,79 +1,79 @@ -#!/bin/bash -# info: add mail domain account -# options: USER DOMAIN ACCOUNT PASSWORD [QUOTA] -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -password=$4 -quota=${5-0} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -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'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]' -validate_format 'user' 'domain' 'account' 'password' 'quota' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_package_full 'MAIL_ACCOUNTS' -is_mail_new "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x '/usr/bin/doveadm' ]; then - md5=$(/usr/bin/doveadm pw -s md5 -p "$password") -else - md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") -fi - -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" -str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$str" >> $USER_DATA/mail/$domain.conf -chmod 660 $USER_DATA/mail/$domain.conf - -# Increase mail accounts counter -accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') -increase_user_value "$user" '$U_MAIL_ACCOUNTS' -update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" - -# Logging -log_history "added mail account $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain account +# options: USER DOMAIN ACCOUNT PASSWORD [QUOTA] +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +password=$4 +quota=${5-0} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +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'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD [QUOTA]' +validate_format 'user' 'domain' 'account' 'password' 'quota' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_package_full 'MAIL_ACCOUNTS' +is_mail_new "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x '/usr/bin/doveadm' ]; then + md5=$(/usr/bin/doveadm pw -s md5 -p "$password") +else + md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") +fi + +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +str="ACCOUNT='$account' ALIAS='' QUOTA='$quota' AUTOREPLY='no' FWD=''" +str="$str MD5='$md5' U_DISK='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$str" >> $USER_DATA/mail/$domain.conf +chmod 660 $USER_DATA/mail/$domain.conf + +# Increase mail accounts counter +accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') +increase_user_value "$user" '$U_MAIL_ACCOUNTS' +update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" + +# Logging +log_history "added mail account $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-account-alias b/bin/v-add-mail-account-alias index 2e523f08..cff53695 100755 --- a/bin/v-add-mail-account-alias +++ b/bin/v-add-mail-account-alias @@ -1,68 +1,68 @@ -#!/bin/bash -# info: add mail account alias aka nickname -# options: USER DOMAIN ACCOUNT ALIAS -# -# The function add new email alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -malias=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' -validate_format 'user' 'domain' 'account' 'malias' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_mail_new "$malias" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding exim alias -str="$malias@$domain:$account@$domain" -echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding vesta alias -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -if [ -z "$aliases" ]; then - aliases="$malias" -else - aliases="$aliases,$malias" -fi -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" - -# Logging -log_history "added alias $malias to $account@$domain " -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail account alias aka nickname +# options: USER DOMAIN ACCOUNT ALIAS +# +# The function add new email alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' +validate_format 'user' 'domain' 'account' 'malias' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +is_mail_new "$malias" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding exim alias +str="$malias@$domain:$account@$domain" +echo "$str" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding vesta alias +aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') +if [ -z "$aliases" ]; then + aliases="$malias" +else + aliases="$aliases,$malias" +fi +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" + +# Logging +log_history "added alias $malias to $account@$domain " +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-account-autoreply b/bin/v-add-mail-account-autoreply index 79deeb27..13f1e9f5 100755 --- a/bin/v-add-mail-account-autoreply +++ b/bin/v-add-mail-account-autoreply @@ -1,64 +1,64 @@ -#!/bin/bash -# info: add mail account autoreply message -# options: USER DOMAIN ACCOUNT MESSAGE -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -autoreply=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT MESSAGE' -validate_format 'user' 'domain' 'account' 'autoreply' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Add exim autoreply -echo -e "$autoreply" > $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 - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding vesta alias -echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg -chmod 660 $USER_DATA/mail/$account@$domain.msg -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes' - -# Logging -log_history "added autoreply message on $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail account autoreply message +# options: USER DOMAIN ACCOUNT MESSAGE +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +autoreply=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT MESSAGE' +validate_format 'user' 'domain' 'account' 'autoreply' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +# is_object_value_empty "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +# Add exim autoreply +echo -e "$autoreply" > $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 + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding vesta alias +echo -e "$autoreply" > $USER_DATA/mail/$account@$domain.msg +chmod 660 $USER_DATA/mail/$account@$domain.msg +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'yes' + +# Logging +log_history "added autoreply message on $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-account-forward b/bin/v-add-mail-account-forward index 979ccd55..8e6e8136 100755 --- a/bin/v-add-mail-account-forward +++ b/bin/v-add-mail-account-forward @@ -1,73 +1,73 @@ -#!/bin/bash -# info: add mail account forward address -# options: USER DOMAIN ACCOUNT FORWARD -# -# The function add new email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -forward=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' -validate_format 'user' 'domain' 'account' 'forward' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then - echo "Error: forward $forward exists" - log_event "$E_EXISTS $EVENT" - exit $E_EXISTS -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding forward to exim -if [ -z "$fwd" ]; then - fwd="$forward" -else - fwd="$fwd,$forward" -fi - -sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" - -# Logging -log_history "added forwarding from $account@$domain to $forward" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail account forward address +# options: USER DOMAIN ACCOUNT FORWARD +# +# The function add new email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +forward=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' +validate_format 'user' 'domain' 'account' 'forward' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') +if [ ! -z "$(echo $fwd | grep -w $forward)" ]; then + echo "Error: forward $forward exists" + log_event "$E_EXISTS $EVENT" + exit $E_EXISTS +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding forward to exim +if [ -z "$fwd" ]; then + fwd="$forward" +else + fwd="$fwd,$forward" +fi + +sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" + +# Logging +log_history "added forwarding from $account@$domain to $forward" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain b/bin/v-add-mail-domain index 8f72c2a1..9e8b799e 100755 --- a/bin/v-add-mail-domain +++ b/bin/v-add-mail-domain @@ -1,121 +1,121 @@ -#!/bin/bash -# info: add mail domain -# options: USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE] -# -# The function adds MAIL domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -antispam=${3-yes} -antivirus=${4-yes} -dkim=${5-yes} -dkim_size=${6-512} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]' -validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'mail' -is_package_full 'MAIL_DOMAINS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding domain directory -mkdir $HOMEDIR/$user/conf/mail/$domain -touch $HOMEDIR/$user/conf/mail/$domain/aliases -touch $HOMEDIR/$user/conf/mail/$domain/protection -touch $HOMEDIR/$user/conf/mail/$domain/passwd -chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain -chmod 770 $HOMEDIR/$user/conf/mail/$domain -chmod 660 $HOMEDIR/$user/conf/mail/$domain/* -mkdir $HOMEDIR/$user/mail/$domain -chown $user:mail $HOMEDIR/$user/mail/$domain -chmod 770 $HOMEDIR/$user/mail/$domain - -# Adding symlink -ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ - -# Adding antispam protection -if [ "$antispam" = 'yes' ]; then - echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - -# Adding antivirus protection -if [ "$antivirus" = 'yes' ]; then - echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - -# Adding dkim -if [ "$dkim" = 'yes' ]; then - openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null - openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ - -out $USER_DATA/mail/$domain.pub &>/dev/null - chmod 660 $USER_DATA/mail/$domain.* - - cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem - - # Adding dkim dns records - check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") - if [ "$?" -eq 0 ]; then - p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" - - record='mail._domainkey' - selector="\"k=rsa\; p=$p\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" - fi -fi - -# Adding domain to vesta db -s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" -s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' TIME='$TIME'" -s="$s DATE='$DATE'" - -echo $s >> $USER_DATA/mail.conf -touch $USER_DATA/mail/$domain.conf -chmod 660 $USER_DATA/mail.conf -chmod 660 $USER_DATA/mail/$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_MAIL_DOMAINS' -if [ "$dkim" = 'yes' ]; then - increase_user_value "$user" '$U_MAIL_DKMI' -fi - -# Logging -log_history "added mail domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain +# options: USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE] +# +# The function adds MAIL domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +antispam=${3-yes} +antivirus=${4-yes} +dkim=${5-yes} +dkim_size=${6-512} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [ANTISPAM] [ANTIVIRUS] [DKIM] [DKIM_SIZE]' +validate_format 'user' 'domain' 'antispam' 'antivirus' 'dkim' 'dkim_size' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_domain_new 'mail' +is_package_full 'MAIL_DOMAINS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding domain directory +mkdir $HOMEDIR/$user/conf/mail/$domain +touch $HOMEDIR/$user/conf/mail/$domain/aliases +touch $HOMEDIR/$user/conf/mail/$domain/protection +touch $HOMEDIR/$user/conf/mail/$domain/passwd +chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain +chmod 770 $HOMEDIR/$user/conf/mail/$domain +chmod 660 $HOMEDIR/$user/conf/mail/$domain/* +mkdir $HOMEDIR/$user/mail/$domain +chown $user:mail $HOMEDIR/$user/mail/$domain +chmod 770 $HOMEDIR/$user/mail/$domain + +# Adding symlink +ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ + +# Adding antispam protection +if [ "$antispam" = 'yes' ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + +# Adding antivirus protection +if [ "$antivirus" = 'yes' ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + +# Adding dkim +if [ "$dkim" = 'yes' ]; then + openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null + openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ + -out $USER_DATA/mail/$domain.pub &>/dev/null + chmod 660 $USER_DATA/mail/$domain.* + + cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem + + # Adding dkim dns records + check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") + if [ "$?" -eq 0 ]; then + p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') + record='_domainkey' + policy="\"t=y; o=~;\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" + + record='mail._domainkey' + selector="\"k=rsa\; p=$p\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" + fi +fi + +# Adding domain to vesta db +s="DOMAIN='$domain' ANTIVIRUS='$antivirus' ANTISPAM='$antispam' DKIM='$dkim'" +s="$s ACCOUNTS='0' U_DISK='0' CATCHALL='' SUSPENDED='no' TIME='$TIME'" +s="$s DATE='$DATE'" + +echo $s >> $USER_DATA/mail.conf +touch $USER_DATA/mail/$domain.conf +chmod 660 $USER_DATA/mail.conf +chmod 660 $USER_DATA/mail/$domain.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing domain value +increase_user_value "$user" '$U_MAIL_DOMAINS' +if [ "$dkim" = 'yes' ]; then + increase_user_value "$user" '$U_MAIL_DKMI' +fi + +# Logging +log_history "added mail domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-antispam b/bin/v-add-mail-domain-antispam index 6ee6c82b..c6035c41 100755 --- a/bin/v-add-mail-domain-antispam +++ b/bin/v-add-mail-domain-antispam @@ -1,58 +1,58 @@ -#!/bin/bash -# info: add mail domain antispam support -# options: USER DOMAIN -# -# The function enables spamassasin for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding antispam key to config -if [ -z "$(grep spam $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then - echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes' - -# Logging -log_history "enabled antispam on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain antispam support +# options: USER DOMAIN +# +# The function enables spamassasin for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTISPAM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding antispam key to config +if [ -z "$(grep spam $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding antispam in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'yes' + +# Logging +log_history "enabled antispam on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-antivirus b/bin/v-add-mail-domain-antivirus index 6e609010..7da3ea0f 100755 --- a/bin/v-add-mail-domain-antivirus +++ b/bin/v-add-mail-domain-antivirus @@ -1,59 +1,59 @@ -#!/bin/bash -# info: add mail domain antivirus support -# options: USER DOMAIN -# -# The function enables clamav scan for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding antivirus key to config -if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then - echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antivirus in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes' - -# Logging -log_history "enabled antivirus on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain antivirus support +# options: USER DOMAIN +# +# The function enables clamav scan for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding antivirus key to config +if [ -z "$(grep 'virus' $HOMEDIR/$user/conf/mail/$domain/protection)" ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding antivirus in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'yes' + +# Logging +log_history "enabled antivirus on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-catchall b/bin/v-add-mail-domain-catchall index e698f01b..fde47507 100755 --- a/bin/v-add-mail-domain-catchall +++ b/bin/v-add-mail-domain-catchall @@ -1,60 +1,60 @@ -#!/bin/bash -# info: add mail domain catchall account -# options: USER DOMAIN EMAIL -# -# The function enables catchall account for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -email="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN EMAIL' -validate_format 'user' 'domain' 'email' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding catchall alias -sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" - - -# Logging -log_history "added $email as catchall email for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain catchall account +# options: USER DOMAIN EMAIL +# +# The function enables catchall account for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +email="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN EMAIL' +validate_format 'user' 'domain' 'email' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$CATCHALL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding catchall alias +sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding antispam in config +update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" + + +# Logging +log_history "added $email as catchall email for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-mail-domain-dkim b/bin/v-add-mail-domain-dkim index 74a0d4b1..b94f4f68 100755 --- a/bin/v-add-mail-domain-dkim +++ b/bin/v-add-mail-domain-dkim @@ -1,81 +1,81 @@ -#!/bin/bash -# info: add mail domain dkim support -# options: USER DOMAIN [DKIM_SIZE] -# -# The function adds DKIM signature to outgoing domain emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -dkim_size=${3-512} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [DKIM_SIZE]' -validate_format 'user' 'domain' 'dkim_size' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating dkim -openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null -openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ - -out $USER_DATA/mail/$domain.pub &>/dev/null -chmod 660 $USER_DATA/mail/$domain.* - -# Adding dkim to config -cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem -chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem -chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem - -# Checking dns domain -check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") -if [ "$?" -eq 0 ]; then - # Adding dkim dns records - p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" - - record='mail._domainkey' - selector="\"k=rsa\; p=$p\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding dkim in config -update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes' -increase_user_value "$user" '$U_MAIL_DKMI' - -# Logging -log_history "enabled DKIM support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add mail domain dkim support +# options: USER DOMAIN [DKIM_SIZE] +# +# The function adds DKIM signature to outgoing domain emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +dkim_size=${3-512} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [DKIM_SIZE]' +validate_format 'user' 'domain' 'dkim_size' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_empty 'mail' 'DOMAIN' "$domain" '$DKIM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Generating dkim +openssl genrsa -out $USER_DATA/mail/$domain.pem $dkim_size &>/dev/null +openssl rsa -pubout -in $USER_DATA/mail/$domain.pem \ + -out $USER_DATA/mail/$domain.pub &>/dev/null +chmod 660 $USER_DATA/mail/$domain.* + +# Adding dkim to config +cp $USER_DATA/mail/$domain.pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem +chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem +chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem + +# Checking dns domain +check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") +if [ "$?" -eq 0 ]; then + # Adding dkim dns records + p=$(cat $USER_DATA/mail/$domain.pub|grep -v ' KEY---'|tr -d '\n') + record='_domainkey' + policy="\"t=y; o=~;\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" + + record='mail._domainkey' + selector="\"k=rsa\; p=$p\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$selector" +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding dkim in config +update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'yes' +increase_user_value "$user" '$U_MAIL_DKMI' + +# Logging +log_history "enabled DKIM support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-sys-ip b/bin/v-add-sys-ip index 808acf86..90315382 100755 --- a/bin/v-add-sys-ip +++ b/bin/v-add-sys-ip @@ -1,100 +1,100 @@ -#!/bin/bash -# info: add system ip address -# options: IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME] -# -# 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. -# 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 -# 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. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=${1// /} -mask=$2 -interface="${3-eth0}" -user="${4-admin}" -ip_status="${5-shared}" # can be dedicated as well -ip_name=$6 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]' -validate_format 'ip' 'mask' 'interface' 'user' 'ip_status' -is_ip_free -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ ! -z "$ip_name" ] ; then - validate_format 'ip_name' -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get full interface name -get_ip_iface - -# Defining config paths -conf='/etc/httpd/conf.d/vesta.conf' -nconf='/etc/nginx/conf.d/vesta_ip.conf' -iconf='/etc/sysconfig/network-scripts/ifcfg' -rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' - -# Adding ip -/sbin/ifconfig "$iface" "$ip" netmask "$mask" - -# Adding startup script -create_ip_startup - -# Adding vesta ip -create_vesta_ip - -# Namehosting support -namehost_ip_support - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user counters -increase_user_value "$user" '$IP_OWNED' -if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users); do - increase_user_value "$user" '$IP_AVAIL' - done - else - increase_user_value 'admin' '$IP_AVAIL' - fi -else - increase_user_value "$user" '$IP_AVAIL' - increase_user_value 'admin' '$IP_AVAIL' -fi - -# Restart web server -if [ "$web_restart" = 'yes' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "added system ip address $ip" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add system ip address +# options: IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME] +# +# 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. +# 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 +# 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. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=${1// /} +mask=$2 +interface="${3-eth0}" +user="${4-admin}" +ip_status="${5-shared}" # can be dedicated as well +ip_name=$6 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP MASK [INTERFACE] [USER] [IP_STATUS] [IP_NAME]' +validate_format 'ip' 'mask' 'interface' 'user' 'ip_status' +is_ip_free +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ ! -z "$ip_name" ] ; then + validate_format 'ip_name' +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get full interface name +get_ip_iface + +# Defining config paths +conf='/etc/httpd/conf.d/vesta.conf' +nconf='/etc/nginx/conf.d/vesta_ip.conf' +iconf='/etc/sysconfig/network-scripts/ifcfg' +rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' + +# Adding ip +/sbin/ifconfig "$iface" "$ip" netmask "$mask" + +# Adding startup script +create_ip_startup + +# Adding vesta ip +create_vesta_ip + +# Namehosting support +namehost_ip_support + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating user counters +increase_user_value "$user" '$IP_OWNED' +if [ "$user" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for user in $(ls $VESTA/data/users); do + increase_user_value "$user" '$IP_AVAIL' + done + else + increase_user_value 'admin' '$IP_AVAIL' + fi +else + increase_user_value "$user" '$IP_AVAIL' + increase_user_value 'admin' '$IP_AVAIL' +fi + +# Restart web server +if [ "$web_restart" = 'yes' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "added system ip address $ip" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-user b/bin/v-add-user index d88565c7..bc3cde65 100755 --- a/bin/v-add-user +++ b/bin/v-add-user @@ -1,218 +1,218 @@ -#!/bin/bash -# info: add system user -# options: USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME] -# -# The function creates new user account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -password=$2 -email=$3 -package=${4-default} -fname=$5 -lname=$6 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Hiding password -A2='******' -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'" - -is_user_free() { - check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) - if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then - echo "Error: user $user exist" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]' -validate_format 'user' 'password' 'email' 'package' -if [ ! -z "$fname" ]; then - validate_format 'fname' 'lname' -fi - -is_user_free "$user" -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing package data -pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE) - -# Checking shell -shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \') -shell=$(/usr/bin/chsh --list-shells | grep -w "$shell_conf" |head -n1) - -# Adding user -/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" - -# Adding password -echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null - -# Building directory tree -mkdir $HOMEDIR/$user/conf - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir $HOMEDIR/$user/conf/web - mkdir $HOMEDIR/$user/web - mkdir $HOMEDIR/$user/tmp - chmod 751 $HOMEDIR/$user/conf/web - chmod 751 $HOMEDIR/$user/web - chmod 771 $HOMEDIR/$user/tmp - chown $user:$user $HOMEDIR/$user/web - chown $user:$user $HOMEDIR/$user/tmp -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir $HOMEDIR/$user/conf/mail - mkdir $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/conf/mail -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir $HOMEDIR/$user/conf/dns - chmod 751 $HOMEDIR/$user/conf/dns -fi - - -# Set permissions -chmod a+x $HOMEDIR/$user - -# Checking quota -if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then - DISK_QUOTA=$(echo "$pkg_data" | grep 'DISK_QUOTA' | cut -f 2 -d \') - #$BIN/v-add-user_quota "$user" "$DISK_QUOTA" -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding user dir -mkdir $USER_DATA -chmod 770 $USER_DATA - -# Creating configuration files and pipes -touch $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf -touch $USER_DATA/history.log -chmod 660 $USER_DATA/history.log -touch $USER_DATA/stats.log -chmod 660 $USER_DATA/stats.log - -echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir $USER_DATA/ssl - chmod 770 $USER_DATA/ssl - touch $USER_DATA/web.conf - chmod 660 $USER_DATA/web.conf - echo "$BIN/v-update-web-domains-traff $user" \ - >> $VESTA/data/queue/traffic.pipe - echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir $USER_DATA/dns - chmod 770 $USER_DATA/dns - touch $USER_DATA/dns.conf - chmod 660 $USER_DATA/dns.conf -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir $USER_DATA/mail - chmod 770 $USER_DATA/mail - touch $USER_DATA/mail.conf - chmod 660 $USER_DATA/mail.conf - echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - touch $USER_DATA/db.conf - chmod 660 $USER_DATA/db.conf - echo "v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - touch $USER_DATA/cron.conf - chmod 660 $USER_DATA/cron.conf -fi - -# Filling user config -if [ "$user" != 'admin' ]; then - ip_avail=$($BIN/v-list-user-ips admin plain |grep -w shared|wc -l) - u_users=0 -else - ip_avail=0 - u_users=1 -fi - -echo "FNAME='$fname' -LNAME='$lname' -PACKAGE='$package' -$pkg_data -CONTACT='$email' -CRON_REPORTS='yes' -MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)' -RKEY='$(gen_password)' -SUSPENDED='no' -SUSPENDED_USERS='0' -SUSPENDED_WEB='0' -SUSPENDED_DNS='0' -SUSPENDED_MAIL='0' -SUSPENDED_DB='0' -SUSPENDED_CRON='0' -IP_AVAIL='$ip_avail' -IP_OWNED='0' -U_USERS='$u_users' -U_DISK='0' -U_DISK_DIRS='0' -U_DISK_WEB='0' -U_DISK_MAIL='0' -U_DISK_DB='0' -U_BANDWIDTH='0' -U_WEB_DOMAINS='0' -U_WEB_SSL='0' -U_WEB_ALIASES='0' -U_DNS_DOMAINS='0' -U_DNS_RECORDS='0' -U_MAIL_DOMAINS='0' -U_MAIL_DKIM='0' -U_MAIL_ACCOUNTS='0' -U_DATABASES='0' -U_CRON_JOBS='0' -U_BACKUPS='0' -TIME='$TIME' -DATE='$DATE'" > $USER_DATA/user.conf -chmod 660 $USER_DATA/user.conf - -# Updating admin counter -if [ "$user" != 'admin' ]; then - increase_user_value 'admin' '$U_USERS' -fi - -# Logging -log_history "added system user $user" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add system user +# options: USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME] +# +# The function creates new user account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +password=$2 +email=$3 +package=${4-default} +fname=$5 +lname=$6 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Hiding password +A2='******' +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'" + +is_user_free() { + check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" ) + if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then + echo "Error: user $user exist" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER PASSWORD EMAIL [PACKAGE] [FNAME] [LNAME]' +validate_format 'user' 'password' 'email' 'package' +if [ ! -z "$fname" ]; then + validate_format 'fname' 'lname' +fi + +is_user_free "$user" +is_package_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing package data +pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |grep -v DATE) + +# Checking shell +shell_conf=$(echo "$pkg_data" | grep 'SHELL' | cut -f 2 -d \') +shell=$(/usr/bin/chsh --list-shells | grep -w "$shell_conf" |head -n1) + +# Adding user +/usr/sbin/adduser "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user" + +# Adding password +echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null + +# Building directory tree +mkdir $HOMEDIR/$user/conf + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir $HOMEDIR/$user/conf/web + mkdir $HOMEDIR/$user/web + mkdir $HOMEDIR/$user/tmp + chmod 751 $HOMEDIR/$user/conf/web + chmod 751 $HOMEDIR/$user/web + chmod 771 $HOMEDIR/$user/tmp + chown $user:$user $HOMEDIR/$user/web + chown $user:$user $HOMEDIR/$user/tmp +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir $HOMEDIR/$user/conf/mail + mkdir $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/conf/mail +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir $HOMEDIR/$user/conf/dns + chmod 751 $HOMEDIR/$user/conf/dns +fi + + +# Set permissions +chmod a+x $HOMEDIR/$user + +# Checking quota +if [ ! -z "$DISK_QUOTA" ] && [ "$DISK_QUOTA" != 'no' ]; then + DISK_QUOTA=$(echo "$pkg_data" | grep 'DISK_QUOTA' | cut -f 2 -d \') + #$BIN/v-add-user_quota "$user" "$DISK_QUOTA" +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding user dir +mkdir $USER_DATA +chmod 770 $USER_DATA + +# Creating configuration files and pipes +touch $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf +touch $USER_DATA/history.log +chmod 660 $USER_DATA/history.log +touch $USER_DATA/stats.log +chmod 660 $USER_DATA/stats.log + +echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir $USER_DATA/ssl + chmod 770 $USER_DATA/ssl + touch $USER_DATA/web.conf + chmod 660 $USER_DATA/web.conf + echo "$BIN/v-update-web-domains-traff $user" \ + >> $VESTA/data/queue/traffic.pipe + echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir $USER_DATA/dns + chmod 770 $USER_DATA/dns + touch $USER_DATA/dns.conf + chmod 660 $USER_DATA/dns.conf +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir $USER_DATA/mail + chmod 770 $USER_DATA/mail + touch $USER_DATA/mail.conf + chmod 660 $USER_DATA/mail.conf + echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + touch $USER_DATA/db.conf + chmod 660 $USER_DATA/db.conf + echo "v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + touch $USER_DATA/cron.conf + chmod 660 $USER_DATA/cron.conf +fi + +# Filling user config +if [ "$user" != 'admin' ]; then + ip_avail=$($BIN/v-list-user-ips admin plain |grep -w shared|wc -l) + u_users=0 +else + ip_avail=0 + u_users=1 +fi + +echo "FNAME='$fname' +LNAME='$lname' +PACKAGE='$package' +$pkg_data +CONTACT='$email' +CRON_REPORTS='yes' +MD5='$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow)' +RKEY='$(gen_password)' +SUSPENDED='no' +SUSPENDED_USERS='0' +SUSPENDED_WEB='0' +SUSPENDED_DNS='0' +SUSPENDED_MAIL='0' +SUSPENDED_DB='0' +SUSPENDED_CRON='0' +IP_AVAIL='$ip_avail' +IP_OWNED='0' +U_USERS='$u_users' +U_DISK='0' +U_DISK_DIRS='0' +U_DISK_WEB='0' +U_DISK_MAIL='0' +U_DISK_DB='0' +U_BANDWIDTH='0' +U_WEB_DOMAINS='0' +U_WEB_SSL='0' +U_WEB_ALIASES='0' +U_DNS_DOMAINS='0' +U_DNS_RECORDS='0' +U_MAIL_DOMAINS='0' +U_MAIL_DKIM='0' +U_MAIL_ACCOUNTS='0' +U_DATABASES='0' +U_CRON_JOBS='0' +U_BACKUPS='0' +TIME='$TIME' +DATE='$DATE'" > $USER_DATA/user.conf +chmod 660 $USER_DATA/user.conf + +# Updating admin counter +if [ "$user" != 'admin' ]; then + increase_user_value 'admin' '$U_USERS' +fi + +# Logging +log_history "added system user $user" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-user-backup b/bin/v-add-user-backup index f76894ec..2e8ead08 100755 --- a/bin/v-add-user-backup +++ b/bin/v-add-user-backup @@ -1,46 +1,46 @@ -#!/bin/bash -# info: schedule user backup creation -# options: USER -# -# The function for scheduling user backup creation. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$BACKUP_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_backup_enabled - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding backup to pipe -echo "$user" >> $VESTA/data/queue/backup.pipe - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: schedule user backup creation +# options: USER +# +# The function for scheduling user backup creation. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$BACKUP_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_backup_enabled + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding backup to pipe +echo "$user" >> $VESTA/data/queue/backup.pipe + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-user-package b/bin/v-add-user-package index d75c886a..a2bd2467 100755 --- a/bin/v-add-user-package +++ b/bin/v-add-user-package @@ -1,79 +1,79 @@ -#!/bin/bash -# info: adding user package -# options: PKG_DIR PACKAGE [REWRITE] -# -# The function adds new user package to the system. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -pkg_dir=$1 -package=$2 -rewrite=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Functions -is_package_new() { - if [ -e "$VESTA/data/packages/$package.pkg" ]; then - echo "Error: package $package already exists." - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS - fi -} - -is_package_consistent() { - source $pkg_dir/$package.pkg - validate_format_int $WEB_DOMAINS - validate_format_int $WEB_ALIASES - validate_format_int $DNS_DOMAINS - validate_format_int $DNS_RECORDS - validate_format_int $MAIL_DOMAINS - validate_format_int $MAIL_ACCOUNTS - validate_format_int $DATABASES - validate_format_int $CRON_JOBS - validate_format_int $DISK_QUOTA - validate_format_int $BACKUPS - validate_format_shell $SHELL -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'PKG_DIR PACKAGE' 'rewrite' -validate_format 'pkg_dir' 'package' -if [ "$rewrite" != 'yes' ]; then - is_package_new -fi -is_package_valid "$pkg_dir" -is_package_consistent - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -cp -f $pkg_dir/$package.pkg $VESTA/data/packages/ -chmod 644 $VESTA/data/packages/$package.pkg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -if [ "$rewrite" != 'yes' ]; then - log_history "added user package $package" '' 'admin' -else - log_history "updated user package $package" '' 'admin' -fi -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: adding user package +# options: PKG_DIR PACKAGE [REWRITE] +# +# The function adds new user package to the system. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +pkg_dir=$1 +package=$2 +rewrite=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Functions +is_package_new() { + if [ -e "$VESTA/data/packages/$package.pkg" ]; then + echo "Error: package $package already exists." + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS + fi +} + +is_package_consistent() { + source $pkg_dir/$package.pkg + validate_format_int $WEB_DOMAINS + validate_format_int $WEB_ALIASES + validate_format_int $DNS_DOMAINS + validate_format_int $DNS_RECORDS + validate_format_int $MAIL_DOMAINS + validate_format_int $MAIL_ACCOUNTS + validate_format_int $DATABASES + validate_format_int $CRON_JOBS + validate_format_int $DISK_QUOTA + validate_format_int $BACKUPS + validate_format_shell $SHELL +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'PKG_DIR PACKAGE' 'rewrite' +validate_format 'pkg_dir' 'package' +if [ "$rewrite" != 'yes' ]; then + is_package_new +fi +is_package_valid "$pkg_dir" +is_package_consistent + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +cp -f $pkg_dir/$package.pkg $VESTA/data/packages/ +chmod 644 $VESTA/data/packages/$package.pkg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +if [ "$rewrite" != 'yes' ]; then + log_history "added user package $package" '' 'admin' +else + log_history "updated user package $package" '' 'admin' +fi +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain b/bin/v-add-web-domain index c07b6cf0..47397899 100755 --- a/bin/v-add-web-domain +++ b/bin/v-add-web-domain @@ -1,190 +1,190 @@ -#!/bin/bash -# info: add web domain -# options: USER DOMAIN IP [TEMPLATE] [RESTART] -# -# 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 -# 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. -# An alias with the ip name is useful during the site testing while dns isn't -# moved to a server yet. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -template=$4 -restart=$5 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [RESTART]' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_domain_new 'web' -is_ip_valid -is_ip_avalable -is_package_full 'WEB_DOMAINS' -if [ ! -z "$template" ]; then - validate_format 'template' - is_apache_template_valid -else - template=$(get_user_value '$TEMPLATE') - is_apache_template_valid -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain aliases -IP=$ip -ip_name=$(get_ip_name) -ip_name_idn=$(idn -t --quiet -a "$ip_name") -domain_alias="www.$domain" -domain_alias_idn="www.$domain_idn" -if [ ! -z "$ip_name" ]; then - domain_alias_dash="${domain//./-}.$ip_name" - domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" - aliases="$domain_alias,$domain_alias_dash" - aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" - alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn" -else - aliases="$domain_alias" - aliases_idn="$domain_alias_idn" - alias_string="ServerAlias $domain_alias_idn" -fi - -# Defining vars for add_config function -group="$user" -email="$user@$domain" -docroot="$HOMEDIR/$user/web/$domain/public_html" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -tpl_file="$WEBTPL/apache_$template.tpl" -elog='' -cgi='' -cgi_option='+ExecCGI' - -# Adding domain to the httpd.conf -add_web_config - -# Building directory tree -mkdir $HOMEDIR/$user/web/$domain \ - $HOMEDIR/$user/web/$domain/public_html \ - $HOMEDIR/$user/web/$domain/public_shtml \ - $HOMEDIR/$user/web/$domain/document_errors \ - $HOMEDIR/$user/web/$domain/cgi-bin \ - $HOMEDIR/$user/web/$domain/private \ - $HOMEDIR/$user/web/$domain/stats \ - $HOMEDIR/$user/web/$domain/logs - -# Adding domain logs -touch /var/log/httpd/domains/$domain.bytes \ - /var/log/httpd/domains/$domain.log \ - /var/log/httpd/domains/$domain.error.log - -# Adding symlink for logs -ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/ - -# Adding domain skeleton -if [ -e "$WEBTPL/skel/public_html/" ]; then - cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/ -fi -if [ -e "$WEBTPL/skel/public_shtml/" ]; then - cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/ -fi -if [ -e "$WEBTPL/skel/document_errors/" ]; then - cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ -fi -if [ -e "$WEBTPL/skel/cgi-bin/" ]; then - cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/ -fi - -# Changing tpl values -for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do - sed -i "s/%domain%/$domain/g" $file -done - -# Changing file owner -chown -R $user:$user $HOMEDIR/$user/web/$domain -chown root:$user /var/log/httpd/domains/$domain.* -chown root:apache $conf - -# Changing file permissions -chmod 660 $conf -chmod 551 $HOMEDIR/$user/web/$domain -chmod 771 $HOMEDIR/$user/web/$domain/private -chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin -chmod 771 $HOMEDIR/$user/web/$domain/public_html -chmod 771 $HOMEDIR/$user/web/$domain/public_shtml -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/public_html/* -chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/* -chmod 551 $HOMEDIR/$user/web/$domain/stats -chmod 551 $HOMEDIR/$user/web/$domain/logs -chmod 640 /var/log/httpd/domains/$domain.* - -# Running template trigger -if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot -fi - -# Checking main vesta httpd config -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing counters -increase_ip_value "$ip" -increase_user_value "$user" '$U_WEB_DOMAINS' -increase_user_value "$user" '$U_WEB_ALIASES' - -# Defining domain variables -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 FTP_MD5='' NGINX='' NGINX_EXT='' STATS='' STATS_USER=''" -str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'" -str="$str TIME='$TIME' DATE='$DATE'" - -# Registering domain -echo "$str" >> $USER_DATA/web.conf -chmod 660 $USER_DATA/web.conf - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "added web domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add web domain +# options: USER DOMAIN IP [TEMPLATE] [RESTART] +# +# 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 +# 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. +# An alias with the ip name is useful during the site testing while dns isn't +# moved to a server yet. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +template=$4 +restart=$5 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP [TEMPLATE] [RESTART]' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_domain_new 'web' +is_ip_valid +is_ip_avalable +is_package_full 'WEB_DOMAINS' +if [ ! -z "$template" ]; then + validate_format 'template' + is_apache_template_valid +else + template=$(get_user_value '$TEMPLATE') + is_apache_template_valid +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining domain aliases +IP=$ip +ip_name=$(get_ip_name) +ip_name_idn=$(idn -t --quiet -a "$ip_name") +domain_alias="www.$domain" +domain_alias_idn="www.$domain_idn" +if [ ! -z "$ip_name" ]; then + domain_alias_dash="${domain//./-}.$ip_name" + domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn" + aliases="$domain_alias,$domain_alias_dash" + aliases_idn="$domain_alias_idn,$domain_alias_dash_idn" + alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn" +else + aliases="$domain_alias" + aliases_idn="$domain_alias_idn" + alias_string="ServerAlias $domain_alias_idn" +fi + +# Defining vars for add_config function +group="$user" +email="$user@$domain" +docroot="$HOMEDIR/$user/web/$domain/public_html" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +tpl_file="$WEBTPL/apache_$template.tpl" +elog='' +cgi='' +cgi_option='+ExecCGI' + +# Adding domain to the httpd.conf +add_web_config + +# Building directory tree +mkdir $HOMEDIR/$user/web/$domain \ + $HOMEDIR/$user/web/$domain/public_html \ + $HOMEDIR/$user/web/$domain/public_shtml \ + $HOMEDIR/$user/web/$domain/document_errors \ + $HOMEDIR/$user/web/$domain/cgi-bin \ + $HOMEDIR/$user/web/$domain/private \ + $HOMEDIR/$user/web/$domain/stats \ + $HOMEDIR/$user/web/$domain/logs + +# Adding domain logs +touch /var/log/httpd/domains/$domain.bytes \ + /var/log/httpd/domains/$domain.log \ + /var/log/httpd/domains/$domain.error.log + +# Adding symlink for logs +ln -s /var/log/httpd/domains/$domain.*log $HOMEDIR/$user/web/$domain/logs/ + +# Adding domain skeleton +if [ -e "$WEBTPL/skel/public_html/" ]; then + cp -r $WEBTPL/skel/public_html/ $HOMEDIR/$user/web/$domain/ +fi +if [ -e "$WEBTPL/skel/public_shtml/" ]; then + cp -r $WEBTPL/skel/public_shtml/ $HOMEDIR/$user/web/$domain/ +fi +if [ -e "$WEBTPL/skel/document_errors/" ]; then + cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ +fi +if [ -e "$WEBTPL/skel/cgi-bin/" ]; then + cp -r $WEBTPL/skel/cgi-bin/ $HOMEDIR/$user/web/$domain/ +fi + +# Changing tpl values +for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do + sed -i "s/%domain%/$domain/g" $file +done + +# Changing file owner +chown -R $user:$user $HOMEDIR/$user/web/$domain +chown root:$user /var/log/httpd/domains/$domain.* +chown root:apache $conf + +# Changing file permissions +chmod 660 $conf +chmod 551 $HOMEDIR/$user/web/$domain +chmod 771 $HOMEDIR/$user/web/$domain/private +chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin +chmod 771 $HOMEDIR/$user/web/$domain/public_html +chmod 771 $HOMEDIR/$user/web/$domain/public_shtml +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/public_html/* +chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/* +chmod 551 $HOMEDIR/$user/web/$domain/stats +chmod 551 $HOMEDIR/$user/web/$domain/logs +chmod 640 /var/log/httpd/domains/$domain.* + +# Running template trigger +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot +fi + +# Checking main vesta httpd config +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing counters +increase_ip_value "$ip" +increase_user_value "$user" '$U_WEB_DOMAINS' +increase_user_value "$user" '$U_WEB_ALIASES' + +# Defining domain variables +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 FTP_MD5='' NGINX='' NGINX_EXT='' STATS='' STATS_USER=''" +str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'" +str="$str TIME='$TIME' DATE='$DATE'" + +# Registering domain +echo "$str" >> $USER_DATA/web.conf +chmod 660 $USER_DATA/web.conf + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "added web domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-alias b/bin/v-add-web-domain-alias index 4f493fda..a14ac8ae 100755 --- a/bin/v-add-web-domain-alias +++ b/bin/v-add-web-domain-alias @@ -1,109 +1,109 @@ -#!/bin/bash -# info: add web domain alias -# options: USER DOMAIN ALIAS [RESTART] -# -# The call is intended for adding aliases to a domain (it is also called -# "domain parking"). The function supports wildcards *.domain.tpl. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' -validate_format 'user' 'domain' 'dom_alias' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_domain_new 'web' "$dom_alias" -is_package_full 'WEB_ALIASES' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" - -# Parsing domain aliases -if [ -z "$ALIAS" ]; then - ALIAS="$dom_alias" -else - ALIAS="$ALIAS,$dom_alias" -fi - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding new alias -update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" - -# Update counters -increase_user_value "$user" '$U_WEB_ALIASES' - -# Adding task to the vesta pipe -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -log_history "added $dom_alias as alias for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add web domain alias +# options: USER DOMAIN ALIAS [RESTART] +# +# The call is intended for adding aliases to a domain (it is also called +# "domain parking"). The function supports wildcards *.domain.tpl. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' +validate_format 'user' 'domain' 'dom_alias' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_domain_new 'web' "$dom_alias" +is_package_full 'WEB_ALIASES' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" + +# Parsing domain aliases +if [ -z "$ALIAS" ]; then + ALIAS="$dom_alias" +else + ALIAS="$ALIAS,$dom_alias" +fi + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding new alias +update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" + +# Update counters +increase_user_value "$user" '$U_WEB_ALIASES' + +# Adding task to the vesta pipe +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +log_history "added $dom_alias as alias for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-cgi b/bin/v-add-web-domain-cgi index c06f0c90..fc2a9993 100755 --- a/bin/v-add-web-domain-cgi +++ b/bin/v-add-web-domain-cgi @@ -1,80 +1,80 @@ -#!/bin/bash -# info: add cgi support for domain -# options: USER DOMAIN -# -# The function switches on cgi support by adding +ExecCGI directive into -# webserver configuration file. The use of this function is provided for -# cases, when temporary cgi support is necessary, for other cases use of -# templates is recommended. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -CGI='yes' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config value -update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes' - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "enabled cgi support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add cgi support for domain +# options: USER DOMAIN +# +# The function switches on cgi support by adding +ExecCGI directive into +# webserver configuration file. The use of this function is provided for +# cases, when temporary cgi support is necessary, for other cases use of +# templates is recommended. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +CGI='yes' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config value +update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes' + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "enabled cgi support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-elog b/bin/v-add-web-domain-elog index b7d0be4e..31859b5b 100755 --- a/bin/v-add-web-domain-elog +++ b/bin/v-add-web-domain-elog @@ -1,99 +1,99 @@ -#!/bin/bash -# info: add error logging for domain -# options: USER DOMAIN [RESTART] -# -# The function enables a separate ErrorLog file for a domain, accessible for -# reading by users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -if [ $ELOG == 'yes' ]; then - exit 0 -fi - -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -ELOG='yes' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes' - -# Adding task to the vesta pipe -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "enabled error logging for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add error logging for domain +# options: USER DOMAIN [RESTART] +# +# The function enables a separate ErrorLog file for a domain, accessible for +# reading by users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +if [ $ELOG == 'yes' ]; then + exit 0 +fi + +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +ELOG='yes' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes' + +# Adding task to the vesta pipe +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "enabled error logging for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-ftp b/bin/v-add-web-domain-ftp index 4644f8df..5c273b22 100755 --- a/bin/v-add-web-domain-ftp +++ b/bin/v-add-web-domain-ftp @@ -1,77 +1,77 @@ -#!/bin/bash -# info: add ftp account for web domain. -# options: USER DOMAIN FTP_USER FTP_PASSWORD -# -# The function creates addutional ftp account for web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ftp_user=${1}_${3} -ftp_password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -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'" - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' -validate_format 'user' 'domain' 'ftp_user' 'ftp_password' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -check_ftp_user=$(grep "^$ftp_user:" /etc/passwd) -if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then - echo "Error: ftp user $ftp_user already exists" - log_event "$E_EXISTS $EVENT" - exit $E_EXISTS -fi - -if [ ! -z "$FTP_USER" ]; then - /usr/sbin/userdel $FTP_USER -fi - -# Adding user -/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -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)" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" - -# Logging -log_history "added ftp account $ftp_user for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add ftp account for web domain. +# options: USER DOMAIN FTP_USER FTP_PASSWORD +# +# The function creates addutional ftp account for web domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ftp_user=${1}_${3} +ftp_password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +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'" + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' +validate_format 'user' 'domain' 'ftp_user' 'ftp_password' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +get_domain_values 'web' +check_ftp_user=$(grep "^$ftp_user:" /etc/passwd) +if [ ! -z "$check_ftp_user" ] && [ "$FTP_USER" != "$ftp_user" ]; then + echo "Error: ftp user $ftp_user already exists" + log_event "$E_EXISTS $EVENT" + exit $E_EXISTS +fi + +if [ ! -z "$FTP_USER" ]; then + /usr/sbin/userdel $FTP_USER +fi + +# Adding user +/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 +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)" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" + +# Logging +log_history "added ftp account $ftp_user for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-nginx b/bin/v-add-web-domain-nginx index 6398069c..f1509862 100755 --- a/bin/v-add-web-domain-nginx +++ b/bin/v-add-web-domain-nginx @@ -1,111 +1,111 @@ -#!/bin/bash -# info: add webdomain nginx support -# options: USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART] -# -# The function enables nginx support for a domain. It can significantly improve -# website speed. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 -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" -extentions=${4-$default_extentions} -restart="$5" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]' -validate_format 'user' 'domain' 'extentions' -is_system_enabled "$PROXY_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX' -if [ ! -z "$template" ]; then - validate_format 'template' - is_nginx_template_valid -else - template=$(get_user_value '$TEMPLATE') - is_nginx_template_valid -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain parameters -get_domain_values 'web' -NGINX="$template" -NGINX_EXT="$extentions" -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" - -# Preparing domain values for the template substitution -upd_web_domain_values -add_web_config - -# Set permission and ownership -chown root:nginx $conf -chmod 640 $conf - -# Checking main vesta httpd config -main_conf='/etc/nginx/conf.d/vesta_users.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ -z "$main_conf_check" ]; then - echo "include $conf;" >>$main_conf -fi - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - add_web_config - - chown root:nginx $conf - chmod 640 $conf - - main_conf='/etc/nginx/conf.d/vesta_users.conf' - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "include $conf;" >>$main_conf - fi -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -log_history "enabled nginx support for $domain" -log_event "$OK" "$EVENT" - -exit - +#!/bin/bash +# info: add webdomain nginx support +# options: USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART] +# +# The function enables nginx support for a domain. It can significantly improve +# website speed. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 +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" +extentions=${4-$default_extentions} +restart="$5" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]' +validate_format 'user' 'domain' 'extentions' +is_system_enabled "$PROXY_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX' +if [ ! -z "$template" ]; then + validate_format 'template' + is_nginx_template_valid +else + template=$(get_user_value '$TEMPLATE') + is_nginx_template_valid +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining domain parameters +get_domain_values 'web' +NGINX="$template" +NGINX_EXT="$extentions" +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" + +# Preparing domain values for the template substitution +upd_web_domain_values +add_web_config + +# Set permission and ownership +chown root:nginx $conf +chmod 640 $conf + +# Checking main vesta httpd config +main_conf='/etc/nginx/conf.d/vesta_users.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ -z "$main_conf_check" ]; then + echo "include $conf;" >>$main_conf +fi + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + add_web_config + + chown root:nginx $conf + chmod 640 $conf + + main_conf='/etc/nginx/conf.d/vesta_users.conf' + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "include $conf;" >>$main_conf + fi +fi + + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +log_history "enabled nginx support for $domain" +log_event "$OK" "$EVENT" + +exit + diff --git a/bin/v-add-web-domain-ssl b/bin/v-add-web-domain-ssl index cc46432a..46245734 100755 --- a/bin/v-add-web-domain-ssl +++ b/bin/v-add-web-domain-ssl @@ -1,136 +1,136 @@ -#!/bin/bash -# info: adding ssl for domain -# options: USER DOMAIN SSL_DIR [SSL_HOME] [RESTART] -# -# 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 -# domain.tld.crt and its key domain.tld.key are mandatory. Certificate -# authority domain.tld.ca file is optional. If home directory parameter -# (ssl_home) is not set, https domain uses public_shtml as separate -# documentroot directory. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ssl_dir=$3 -ssl_home=${4-same} -restart="$5" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]' -validate_format 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL' -is_ip_owner -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi -chmod 660 $USER_DATA/ssl/$domain.* - -# Parsing domain values -get_domain_values 'web' -conf="$HOMEDIR/$user/conf/web/shttpd.conf" -tpl_file="$WEBTPL/apache_$TPL.stpl" -SSL_HOME="$ssl_home" - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Adding domain to the shttpd.conf -add_web_config - -chown root:apache $conf -chmod 640 $conf - -# Adding certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca -fi - -# Running template trigger -if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot -fi - -# Checking main vesta httpd config -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ -z "$main_conf_check" ]; then - echo "Include $conf" >> $main_conf -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - # Adding domain to the snginx.conf - conf="$HOMEDIR/$user/conf/web/snginx.conf" - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - add_web_config - - chown root:nginx $conf - chmod 640 $conf - - # Checking vesta nginx config - main_conf='/etc/nginx/conf.d/vesta_users.conf' - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "include $conf;" >>$main_conf - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Increasing domain value -increase_user_value "$user" '$U_WEB_SSL' - -# Adding ssl values -update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" -update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "enabled ssl support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: adding ssl for domain +# options: USER DOMAIN SSL_DIR [SSL_HOME] [RESTART] +# +# 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 +# domain.tld.crt and its key domain.tld.key are mandatory. Certificate +# authority domain.tld.ca file is optional. If home directory parameter +# (ssl_home) is not set, https domain uses public_shtml as separate +# documentroot directory. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ssl_dir=$3 +ssl_home=${4-same} +restart="$5" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]' +validate_format 'user' 'domain' 'ssl_dir' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL' +is_ip_owner +is_web_domain_cert_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding certificate to user data directory +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt +cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem +if [ -e "$ssl_dir/$domain.ca" ]; then + cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca + cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem +fi +chmod 660 $USER_DATA/ssl/$domain.* + +# Parsing domain values +get_domain_values 'web' +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" +SSL_HOME="$ssl_home" + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Adding domain to the shttpd.conf +add_web_config + +chown root:apache $conf +chmod 640 $conf + +# Adding certificate to user dir +cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt +cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key +cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca +fi + +# Running template trigger +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot +fi + +# Checking main vesta httpd config +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ -z "$main_conf_check" ]; then + echo "Include $conf" >> $main_conf +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + # Adding domain to the snginx.conf + conf="$HOMEDIR/$user/conf/web/snginx.conf" + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + add_web_config + + chown root:nginx $conf + chmod 640 $conf + + # Checking vesta nginx config + main_conf='/etc/nginx/conf.d/vesta_users.conf' + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "include $conf;" >>$main_conf + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Increasing domain value +increase_user_value "$user" '$U_WEB_SSL' + +# Adding ssl values +update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" +update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "enabled ssl support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-add-web-domain-stats b/bin/v-add-web-domain-stats index dceed005..a669f856 100755 --- a/bin/v-add-web-domain-stats +++ b/bin/v-add-web-domain-stats @@ -1,91 +1,91 @@ -#!/bin/bash -# info: add log analyzer to generate domain statitics -# options: USER DOMAIN TYPE -# -# 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 -# 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 -# should use v-add-web-domain_stat_auth script. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -type=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TYPE' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_type_valid "$STATS_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parse aliases -get_domain_values 'web' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Adding statistic config -cat $WEBTPL/$type.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$type.$domain.conf - -if [ "$type" == 'awstats' ]; then - ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf /etc/awstats/ -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Schedule statistic processing -echo "$BIN/v-update-web-domain-stat $user $domain" >> \ - $VESTA/data/queue/webstats.pipe - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" - -# Logging -log_history "enabled web log analyzer for $domain" -log_event "$OK" "$EVENT" - -# Build stats -exec $BIN/v-update-web-domain-stat $user $domain - -exit +#!/bin/bash +# info: add log analyzer to generate domain statitics +# options: USER DOMAIN TYPE +# +# 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 +# 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 +# should use v-add-web-domain_stat_auth script. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +type=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TYPE' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_type_valid "$STATS_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parse aliases +get_domain_values 'web' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Adding statistic config +cat $WEBTPL/$type.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$type.$domain.conf + +if [ "$type" == 'awstats' ]; then + ln -s $HOMEDIR/$user/conf/web/$type.$domain.conf /etc/awstats/ +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Schedule statistic processing +echo "$BIN/v-update-web-domain-stat $user $domain" >> \ + $VESTA/data/queue/webstats.pipe + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" + +# Logging +log_history "enabled web log analyzer for $domain" +log_event "$OK" "$EVENT" + +# Build stats +exec $BIN/v-update-web-domain-stat $user $domain + +exit diff --git a/bin/v-add-web-domain-stats-user b/bin/v-add-web-domain-stats-user index 2f8cc40b..fb670645 100755 --- a/bin/v-add-web-domain-stats-user +++ b/bin/v-add-web-domain-stats-user @@ -1,72 +1,72 @@ -#!/bin/bash -# info: add password protection to web domain statistics -# options: USER DOMAIN STATS_USER STATS_PASSWORD -# -# The call is used for securing the web statistics page. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -stats_user=$3 -stats_pass=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -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'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS' -validate_format 'user' 'domain' 'stats_user' 'stats_pass' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Definining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Adding htaccess file -echo "AuthUserFile $stats_dir/.htpasswd -AuthName \"Web Statistics\" -AuthType Basic -Require valid-user" > $stats_dir/.htaccess - -# Generating htaccess user and password -rm -f $stats_dir/.htpasswd -htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null -stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :) - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding stats user in config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt" - -# Logging -log_history "added password protection for web stats on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add password protection to web domain statistics +# options: USER DOMAIN STATS_USER STATS_PASSWORD +# +# The call is used for securing the web statistics page. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +stats_user=$3 +stats_pass=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +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'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN STATS_USER STATS_PASS' +validate_format 'user' 'domain' 'stats_user' 'stats_pass' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Definining statistic dir +stats_dir="$HOMEDIR/$user/web/$domain/stats" + +# Adding htaccess file +echo "AuthUserFile $stats_dir/.htpasswd +AuthName \"Web Statistics\" +AuthType Basic +Require valid-user" > $stats_dir/.htaccess + +# Generating htaccess user and password +rm -f $stats_dir/.htpasswd +htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null +stats_crypt=$(grep $stats_user: $stats_dir/.htpasswd |cut -f 2 -d :) + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding stats user in config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user" +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' "$stats_crypt" + +# Logging +log_history "added password protection for web stats on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-backup-user b/bin/v-backup-user index da6800d7..38908dd1 100755 --- a/bin/v-backup-user +++ b/bin/v-backup-user @@ -1,523 +1,523 @@ -#!/bin/bash -# info: backup system user with all its objects -# options: USER -# -# The call is used for backing up user with all its domains and databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$BACKUP_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_backup_enabled -la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') -i=0 -while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do - echo "$(date "+%F %T") Load Average $la" - echo - sleep 60 - if [ "$i" -ge "15" ]; then - echo "Error: LA is too high" - log_event "$E_LA" "$EVENT" - exit $E_LA - fi - (( ++i)) -done - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get current time -start_time=$(date '+%s') - -# Creating temporary random directory -tmpdir=$(mktemp -p $BACKUP -d) - -# Prinitng status -echo "$(date "+%F %T") System backup for user $user" -echo "TMPDIR is $tmpdir" -echo - -# Addding backup and vesta version -echo "1.0" > $tmpdir/backup_version -echo "$VERSION" > $tmpdir/vesta_version - -# Vesta -echo "-- VESTA --" -vst='yes' -mkdir $tmpdir/vesta - -# Backingup vesta configs -echo -e "$(date "+%F %T") user.conf" - -cp -r $USER_DATA/user.conf $tmpdir/vesta/ - -if [ -e "$USER_DATA/stats.log" ]; then - echo -e "$(date "+%F %T") stats.log" - cp -r $USER_DATA/stats.log $tmpdir/vesta/ -fi - -if [ -e "$USER_DATA/history.log" ]; then - echo -e "$(date "+%F %T") history.log" - cp -r $USER_DATA/history.log $tmpdir/vesta/ -fi - -if [ -e "$USER_DATA/backup.excludes" ]; then - echo -e "$(date "+%F %T") backup.excludes" - cp -r $USER_DATA/backup.excludes $tmpdir/vesta/ -fi - -echo - -# PAM -echo "-- PAM --" -mkdir $tmpdir/pam -echo -e "$(date "+%F %T") passwd / shadow /group" -grep "^$user:" /etc/passwd > $tmpdir/pam/passwd -grep "^$user:" /etc/shadow > $tmpdir/pam/shadow -grep "^$user:" /etc/group > $tmpdir/pam/group -echo - -# Checking excludes -OLD_IFS="$IFS" -IFS=$'\n' -if [ -e "$USER_DATA/backup.excludes" ]; then - echo "-- Excludes --" - - for exclude in $(cat $USER_DATA/backup.excludes); do - echo -e "$exclude" - # Indirect variable references (a bit of black magic) - eval ${exclude%%=*}=${exclude#*=} - done - echo -fi -IFS="$OLD_IFS" - -# WEB domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ] && [ "$WEB" != '*' ] -then - echo "-- WEB --" - mkdir $tmpdir/web/ - - # Parsing unsuspeneded domains - conf="$USER_DATA/web.conf" - for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$WEB"|grep -w $domain) - if [ -z "$check_exl" ]; then - web_list="$web_list $domain" - fi - done - web_list=$(echo "$web_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for domain in $web_list; do - echo -e "$(date "+%F %T") $domain" - mkdir -p $tmpdir/web/$domain/conf - mkdir -p $tmpdir/web/$domain/vesta - - # Defining domain variables - domain_idn=$(idn -t --quiet -a "$domain") - get_domain_values 'web' - - # Creating web.config - cd $tmpdir/web/$domain/ - conf="$USER_DATA/web.conf" - grep "DOMAIN='$domain'" $conf > vesta/web.conf - - # Apache config - if [ "$WEB_SYSTEM" = 'apache' ]; then - # Parsing httpd.conf - tpl_file="$WEBTPL/apache_$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/httpd.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf - - # SSL check - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf - fi - fi - - # Nginx config - if [ ! -z "$NGINX" ] ; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf - - # SSL check - if [ "$SSL" = 'yes' ] ; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - get_web_config_brds - sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf - fi - fi - - # Suplemental configs - for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do - cp $HOMEDIR/$user/conf/web/$sconfig conf/ - done - - # SSL Certificates - if [ "$SSL" = 'yes' ] ; then - cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/ - cp $USER_DATA/ssl/$domain.* vesta/ - fi - - # Packing data folders - cd $HOMEDIR/$user/web/$domain - domain_direcotries=$(ls |grep -v logs) - tar -cf $tmpdir/web/$domain/domain_data.tar $domain_direcotries - - if [ ! -z "$BACKUP_GZIP" ]; then - gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar - fi - done - echo -fi - -# DNS domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ] && [ "$DNS" != '*' ] -then - echo "-- DNS --" - mkdir $tmpdir/dns/ - - # Parsing unsuspeneded domains - for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$DNS"|grep -w $domain) - if [ -z "$check_exl" ]; then - dns_list="$dns_list $domain" - fi - done - dns_list=$(echo "$dns_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for domain in $dns_list; do - echo -e "$(date "+%F %T") $domain" - # Building directory tree - mkdir -p $tmpdir/dns/$domain/conf - mkdir -p $tmpdir/dns/$domain/vesta - - # Creating dns_domains config - cd $tmpdir/dns/$domain/ - conf="$USER_DATA/dns.conf" - grep "DOMAIN='$domain'" $conf > vesta/dns.conf - - # Backingup dns recods - cp $USER_DATA/dns/$domain.conf vesta/$domain.conf - cp $HOMEDIR/$user/conf/dns/$domain.db conf/$domain.db - done - echo -fi - - -# Mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ] && [ "$MAIL" != '*' ] -then - echo "-- MAIL --" - mkdir $tmpdir/mail/ - - # Parsing unsuspeneded domains - conf="$USER_DATA/mail.conf" - for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do - check_exl=$(echo "$MAIL"|grep -w $domain) - if [ -z "$check_exl" ]; then - mail_list="$mail_list $domain" - fi - done - mail_list=$(echo "$mail_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for domain in $mail_list; do - echo -e "$(date "+%F %T") $domain" - #mkdir -p $tmpdir/mail/$domain/accounts - mkdir -p $tmpdir/mail/$domain/conf - mkdir -p $tmpdir/mail/$domain/vesta - - # Creating exim config - cd $tmpdir/mail/$domain/ - cp $HOMEDIR/$user/conf/mail/$domain/* conf/ - - # Creating vesta config - conf="$USER_DATA/mail.conf" - grep "DOMAIN='$domain'" $conf > vesta/mail.conf - cp $USER_DATA/mail/$domain.* vesta/ - if [ ! -z "$(ls $USER_DATA/mail/|grep *@$domain)" ]; then - cp $USER_DATA/mail/*@$domain.* vesta/ - fi - - # Packing mailboxes - cd $HOMEDIR/$user/mail/$domain - accounts=$(ls) - if [ ! -z "$accounts" ]; then - tar -cf $tmpdir/mail/$domain/accounts.tar $accounts - fi - - if [ ! -z "$BACKUP_GZIP" ] && [ ! -z $accounts ]; then - gzip -$BACKUP_GZIP $tmpdir/mail/$domain/accounts.tar - fi - done - echo -fi - - -# DatbaBases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then - echo "-- DB --" - mkdir $tmpdir/db/ - - # Parsing unsuspeneded domains - for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do - check_exl=$(echo "$DB"|grep -w $database) - if [ -z "$check_exl" ]; then - db_list="$db_list $database" - fi - done - db_list=$(echo "$db_list" | sed -e "s/ */\ /g" -e "s/^ //") - - for database in $db_list; do - mkdir -p $tmpdir/db/$database/conf - mkdir -p $tmpdir/db/$database/vesta - cd $tmpdir/db/$database/ - - conf="$USER_DATA/db.conf" - grep "DB='$database'" $conf > vesta/db.conf - - get_database_values - dump="$tmpdir/db/$database/$database.$TYPE.sql" - grants="$tmpdir/db/$database/conf/$database.$TYPE.$DBUSER" - echo -e "$(date "+%F %T") $database $TYPE" - case $TYPE in - mysql) dump_mysql_database ;; - pgsql) dump_pgsql_database ;; - esac - if [ ! -z "$BACKUP_GZIP" ]; then - gzip -$BACKUP_GZIP $dump - fi - done - echo -fi - -# Cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ] && [ "$CRON" != '*' ] -then - echo "-- CRON --" - mkdir $tmpdir/cron/ - - # Backingup cron recods - echo -e "$(date "+%F %T") cron.conf" - cp $USER_DATA/cron.conf $tmpdir/cron/ - echo -e "$(date "+%F %T") system cron" - - if [ -e "/var/spool/cron/$user" ]; then - cron_list='yes' - cp /var/spool/cron/$user $tmpdir/cron/ - fi - echo -fi - -# Get backup size -size="$(du -shm $tmpdir | cut -f 1)" - -# Get current time -end_time=$(date '+%s') -DATE=$(date +%F) -TIME=$(date +%T) - - -# Defining local storage function -local_backup(){ - echo "-- STORAGE --" - echo -e "$(date "+%F %T") ARCHIVE $BACKUP/$user.$DATE.tar" - - # Removing dublicate for this day - if [ -e "$BACKUP/$user.$DATE.tar" ]; then - deprecated="$DATE" - echo -e "Deleting old backup for $DATE" - rm -f $BACKUP/$user.$DATE.tar - fi - - # Checking retention - backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.") - backups_count=$(echo "$backup_list" | wc -l) - if [ "$BACKUPS" -le "$backups_count" ]; then - backups_rm_number=$((backups_count - BACKUPS)) - (( ++backups_rm_number)) - - for backup in $(echo "$backup_list" | head -n $backups_rm_number); do - # Removing old backup - backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//") - deprecated="$deprecated $backup_date" - echo -e "\tDeleteing old backup for $backup_date" - rm -f $BACKUP/$backup - done - fi - - # Checking disk space - disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %) - - if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then - echo "Error: Not enough disk space" - log_event "$E_DISK" "$EVENT" - exit $E_DISK - fi - - # Creating final tarball - cd $tmpdir - tar -cf $BACKUP/$user.$DATE.tar . - chmod 640 $BACKUP/$user.$DATE.tar - chown admin:$user $BACKUP/$user.$DATE.tar - localbackup='yes' - echo - - U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) - update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" -} - - -# Defining ftp command function -ftpc() { - ftp -n $HOST $PORT <> $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: backup system user with all its objects +# options: USER +# +# The call is used for backing up user with all its domains and databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$BACKUP_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_backup_enabled +la=$(cat /proc/loadavg |cut -f 1 -d ' '|cut -f 1 -d '.') +i=0 +while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do + echo "$(date "+%F %T") Load Average $la" + echo + sleep 60 + if [ "$i" -ge "15" ]; then + echo "Error: LA is too high" + log_event "$E_LA" "$EVENT" + exit $E_LA + fi + (( ++i)) +done + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get current time +start_time=$(date '+%s') + +# Creating temporary random directory +tmpdir=$(mktemp -p $BACKUP -d) + +# Prinitng status +echo "$(date "+%F %T") System backup for user $user" +echo "TMPDIR is $tmpdir" +echo + +# Addding backup and vesta version +echo "1.0" > $tmpdir/backup_version +echo "$VERSION" > $tmpdir/vesta_version + +# Vesta +echo "-- VESTA --" +vst='yes' +mkdir $tmpdir/vesta + +# Backingup vesta configs +echo -e "$(date "+%F %T") user.conf" + +cp -r $USER_DATA/user.conf $tmpdir/vesta/ + +if [ -e "$USER_DATA/stats.log" ]; then + echo -e "$(date "+%F %T") stats.log" + cp -r $USER_DATA/stats.log $tmpdir/vesta/ +fi + +if [ -e "$USER_DATA/history.log" ]; then + echo -e "$(date "+%F %T") history.log" + cp -r $USER_DATA/history.log $tmpdir/vesta/ +fi + +if [ -e "$USER_DATA/backup.excludes" ]; then + echo -e "$(date "+%F %T") backup.excludes" + cp -r $USER_DATA/backup.excludes $tmpdir/vesta/ +fi + +echo + +# PAM +echo "-- PAM --" +mkdir $tmpdir/pam +echo -e "$(date "+%F %T") passwd / shadow /group" +grep "^$user:" /etc/passwd > $tmpdir/pam/passwd +grep "^$user:" /etc/shadow > $tmpdir/pam/shadow +grep "^$user:" /etc/group > $tmpdir/pam/group +echo + +# Checking excludes +OLD_IFS="$IFS" +IFS=$'\n' +if [ -e "$USER_DATA/backup.excludes" ]; then + echo "-- Excludes --" + + for exclude in $(cat $USER_DATA/backup.excludes); do + echo -e "$exclude" + # Indirect variable references (a bit of black magic) + eval ${exclude%%=*}=${exclude#*=} + done + echo +fi +IFS="$OLD_IFS" + +# WEB domains +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ] && [ "$WEB" != '*' ] +then + echo "-- WEB --" + mkdir $tmpdir/web/ + + # Parsing unsuspeneded domains + conf="$USER_DATA/web.conf" + for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do + check_exl=$(echo "$WEB"|grep -w $domain) + if [ -z "$check_exl" ]; then + web_list="$web_list $domain" + fi + done + web_list=$(echo "$web_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for domain in $web_list; do + echo -e "$(date "+%F %T") $domain" + mkdir -p $tmpdir/web/$domain/conf + mkdir -p $tmpdir/web/$domain/vesta + + # Defining domain variables + domain_idn=$(idn -t --quiet -a "$domain") + get_domain_values 'web' + + # Creating web.config + cd $tmpdir/web/$domain/ + conf="$USER_DATA/web.conf" + grep "DOMAIN='$domain'" $conf > vesta/web.conf + + # Apache config + if [ "$WEB_SYSTEM" = 'apache' ]; then + # Parsing httpd.conf + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/httpd.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf + + # SSL check + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf + fi + fi + + # Nginx config + if [ ! -z "$NGINX" ] ; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf + + # SSL check + if [ "$SSL" = 'yes' ] ; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + get_web_config_brds + sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf + fi + fi + + # Suplemental configs + for sconfig in $(ls $HOMEDIR/$user/conf/web/|grep ".$domain.conf"); do + cp $HOMEDIR/$user/conf/web/$sconfig conf/ + done + + # SSL Certificates + if [ "$SSL" = 'yes' ] ; then + cp $HOMEDIR/$user/conf/web/ssl.$domain.* conf/ + cp $USER_DATA/ssl/$domain.* vesta/ + fi + + # Packing data folders + cd $HOMEDIR/$user/web/$domain + domain_direcotries=$(ls |grep -v logs) + tar -cf $tmpdir/web/$domain/domain_data.tar $domain_direcotries + + if [ ! -z "$BACKUP_GZIP" ]; then + gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar + fi + done + echo +fi + +# DNS domains +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ] && [ "$DNS" != '*' ] +then + echo "-- DNS --" + mkdir $tmpdir/dns/ + + # Parsing unsuspeneded domains + for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do + check_exl=$(echo "$DNS"|grep -w $domain) + if [ -z "$check_exl" ]; then + dns_list="$dns_list $domain" + fi + done + dns_list=$(echo "$dns_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for domain in $dns_list; do + echo -e "$(date "+%F %T") $domain" + # Building directory tree + mkdir -p $tmpdir/dns/$domain/conf + mkdir -p $tmpdir/dns/$domain/vesta + + # Creating dns_domains config + cd $tmpdir/dns/$domain/ + conf="$USER_DATA/dns.conf" + grep "DOMAIN='$domain'" $conf > vesta/dns.conf + + # Backingup dns recods + cp $USER_DATA/dns/$domain.conf vesta/$domain.conf + cp $HOMEDIR/$user/conf/dns/$domain.db conf/$domain.db + done + echo +fi + + +# Mail domains +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ] && [ "$MAIL" != '*' ] +then + echo "-- MAIL --" + mkdir $tmpdir/mail/ + + # Parsing unsuspeneded domains + conf="$USER_DATA/mail.conf" + for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do + check_exl=$(echo "$MAIL"|grep -w $domain) + if [ -z "$check_exl" ]; then + mail_list="$mail_list $domain" + fi + done + mail_list=$(echo "$mail_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for domain in $mail_list; do + echo -e "$(date "+%F %T") $domain" + #mkdir -p $tmpdir/mail/$domain/accounts + mkdir -p $tmpdir/mail/$domain/conf + mkdir -p $tmpdir/mail/$domain/vesta + + # Creating exim config + cd $tmpdir/mail/$domain/ + cp $HOMEDIR/$user/conf/mail/$domain/* conf/ + + # Creating vesta config + conf="$USER_DATA/mail.conf" + grep "DOMAIN='$domain'" $conf > vesta/mail.conf + cp $USER_DATA/mail/$domain.* vesta/ + if [ ! -z "$(ls $USER_DATA/mail/|grep *@$domain)" ]; then + cp $USER_DATA/mail/*@$domain.* vesta/ + fi + + # Packing mailboxes + cd $HOMEDIR/$user/mail/$domain + accounts=$(ls) + if [ ! -z "$accounts" ]; then + tar -cf $tmpdir/mail/$domain/accounts.tar $accounts + fi + + if [ ! -z "$BACKUP_GZIP" ] && [ ! -z $accounts ]; then + gzip -$BACKUP_GZIP $tmpdir/mail/$domain/accounts.tar + fi + done + echo +fi + + +# DatbaBases +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ] && [ "$DB" != '*' ]; then + echo "-- DB --" + mkdir $tmpdir/db/ + + # Parsing unsuspeneded domains + for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do + check_exl=$(echo "$DB"|grep -w $database) + if [ -z "$check_exl" ]; then + db_list="$db_list $database" + fi + done + db_list=$(echo "$db_list" | sed -e "s/ */\ /g" -e "s/^ //") + + for database in $db_list; do + mkdir -p $tmpdir/db/$database/conf + mkdir -p $tmpdir/db/$database/vesta + cd $tmpdir/db/$database/ + + conf="$USER_DATA/db.conf" + grep "DB='$database'" $conf > vesta/db.conf + + get_database_values + dump="$tmpdir/db/$database/$database.$TYPE.sql" + grants="$tmpdir/db/$database/conf/$database.$TYPE.$DBUSER" + echo -e "$(date "+%F %T") $database $TYPE" + case $TYPE in + mysql) dump_mysql_database ;; + pgsql) dump_pgsql_database ;; + esac + if [ ! -z "$BACKUP_GZIP" ]; then + gzip -$BACKUP_GZIP $dump + fi + done + echo +fi + +# Cron jobs +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ] && [ "$CRON" != '*' ] +then + echo "-- CRON --" + mkdir $tmpdir/cron/ + + # Backingup cron recods + echo -e "$(date "+%F %T") cron.conf" + cp $USER_DATA/cron.conf $tmpdir/cron/ + echo -e "$(date "+%F %T") system cron" + + if [ -e "/var/spool/cron/$user" ]; then + cron_list='yes' + cp /var/spool/cron/$user $tmpdir/cron/ + fi + echo +fi + +# Get backup size +size="$(du -shm $tmpdir | cut -f 1)" + +# Get current time +end_time=$(date '+%s') +DATE=$(date +%F) +TIME=$(date +%T) + + +# Defining local storage function +local_backup(){ + echo "-- STORAGE --" + echo -e "$(date "+%F %T") ARCHIVE $BACKUP/$user.$DATE.tar" + + # Removing dublicate for this day + if [ -e "$BACKUP/$user.$DATE.tar" ]; then + deprecated="$DATE" + echo -e "Deleting old backup for $DATE" + rm -f $BACKUP/$user.$DATE.tar + fi + + # Checking retention + backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.") + backups_count=$(echo "$backup_list" | wc -l) + if [ "$BACKUPS" -le "$backups_count" ]; then + backups_rm_number=$((backups_count - BACKUPS)) + (( ++backups_rm_number)) + + for backup in $(echo "$backup_list" | head -n $backups_rm_number); do + # Removing old backup + backup_date=$(echo $backup | sed -e "s/$user.//" -e "s/.tar$//") + deprecated="$deprecated $backup_date" + echo -e "\tDeleteing old backup for $backup_date" + rm -f $BACKUP/$backup + done + fi + + # Checking disk space + disk_usage=$(df $BACKUP |tail -n1 |tr ' ' '\n' |grep % |cut -f 1 -d %) + + if [ "$disk_usage" -ge "$BACKUP_DISK_LIMIT" ]; then + echo "Error: Not enough disk space" + log_event "$E_DISK" "$EVENT" + exit $E_DISK + fi + + # Creating final tarball + cd $tmpdir + tar -cf $BACKUP/$user.$DATE.tar . + chmod 640 $BACKUP/$user.$DATE.tar + chown admin:$user $BACKUP/$user.$DATE.tar + localbackup='yes' + echo + + U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) + update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" +} + + +# Defining ftp command function +ftpc() { + ftp -n $HOST $PORT <> $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-backup-users b/bin/v-backup-users index 6dd88819..24b9819e 100755 --- a/bin/v-backup-users +++ b/bin/v-backup-users @@ -1,39 +1,39 @@ -#!/bin/bash -# info: backup all users -# options: NONE -# -# The function backups all system users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -for user in $(ls $VESTA/data/users); do - check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf) - if [ ! -z "$check_suspend" ]; then - $BIN/v-backup-user $user >> $VESTA/log/backup.log 2>&1 - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: backup all users +# options: NONE +# +# The function backups all system users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +for user in $(ls $VESTA/data/users); do + check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf) + if [ ! -z "$check_suspend" ]; then + $BIN/v-backup-user $user >> $VESTA/log/backup.log 2>&1 + fi +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-cron-job b/bin/v-change-cron-job index 6274aca7..1a930e50 100755 --- a/bin/v-change-cron-job +++ b/bin/v-change-cron-job @@ -1,73 +1,73 @@ -#!/bin/bash -# info: change cron job -# options: USER JOB MIN HOUR DAY MONTH WDAY COMMAND -# -# The function is used for changing existing job. It fully replace job -# parameters with new one but with same id. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -min=$3 -hour=$4 -day=$5 -month=$6 -wday=$7 -command=$8 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '7' "$#" 'USER JOB MIN HOUR DAY MONTH WDAY COMMAND' -validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' -is_system_enabled $CRON_SYSTEM -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Concatenating cron string -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="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" - -# Deleting old job -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Adding new -echo "$str" >> $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "changed cron job $job" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change cron job +# options: USER JOB MIN HOUR DAY MONTH WDAY COMMAND +# +# The function is used for changing existing job. It fully replace job +# parameters with new one but with same id. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +min=$3 +hour=$4 +day=$5 +month=$6 +wday=$7 +command=$8 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '7' "$#" 'USER JOB MIN HOUR DAY MONTH WDAY COMMAND' +validate_format 'user' 'job' 'min' 'hour' 'day' 'month' 'wday' 'command' +is_system_enabled $CRON_SYSTEM +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Concatenating cron string +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="$str CMD='$command' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" + +# Deleting old job +sed -i "/JOB='$job' /d" $USER_DATA/cron.conf + +# Adding new +echo "$str" >> $USER_DATA/cron.conf + +# Sorting jobs by id +sort_cron_jobs + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "changed cron job $job" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-database-password b/bin/v-change-database-password index 507c7e9a..ee283675 100755 --- a/bin/v-change-database-password +++ b/bin/v-change-database-password @@ -1,65 +1,65 @@ -#!/bin/bash -# info: change database password -# options: USER DATABASE DBPASS -# -# The function for changing database user password to a database. It uses the -# full name of database as argument. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 -dbpass=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - -# Hiding password -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'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DATABASE DBPASS' -validate_format 'user' 'database' 'dbpass' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Get database values -get_database_values - -case $TYPE in - mysql) change_mysql_password ;; - pgsql) change_pgsql_password ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config value -update_object_value 'db' 'DB' "$database" '$MD5' "$md5" - -# Logging -log_history "changed $database database password" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change database password +# options: USER DATABASE DBPASS +# +# The function for changing database user password to a database. It uses the +# full name of database as argument. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 +dbpass=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + +# Hiding password +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'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DATABASE DBPASS' +validate_format 'user' 'database' 'dbpass' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +# Get database values +get_database_values + +case $TYPE in + mysql) change_mysql_password ;; + pgsql) change_pgsql_password ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config value +update_object_value 'db' 'DB' "$database" '$MD5' "$md5" + +# Logging +log_history "changed $database database password" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-exp b/bin/v-change-dns-domain-exp index 7f7647b6..e491893b 100755 --- a/bin/v-change-dns-domain-exp +++ b/bin/v-change-dns-domain-exp @@ -1,53 +1,53 @@ -#!/bin/bash -# info: change dns domain expiriation date -# options: USER DOMAIN EXP -# -# The function of changing the term of expiration domain's registration. The -# serial number will be refreshed automatically during update. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -exp=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN EXP' -validate_format 'user' 'domain' 'exp' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing exp -update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed whois expiriation date for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain expiriation date +# options: USER DOMAIN EXP +# +# The function of changing the term of expiration domain's registration. The +# serial number will be refreshed automatically during update. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +exp=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN EXP' +validate_format 'user' 'domain' 'exp' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing exp +update_object_value 'dns' 'DOMAIN' "$domain" '$EXP' "$exp" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed whois expiriation date for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-ip b/bin/v-change-dns-domain-ip index 13ae9c7f..9a3fb050 100755 --- a/bin/v-change-dns-domain-ip +++ b/bin/v-change-dns-domain-ip @@ -1,69 +1,69 @@ -#!/bin/bash -# info: change dns domain ip address -# options: USER DOMAIN IP -# -# The function for changing the main ip of DNS zone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get old ip -get_domain_values 'dns' -old=$IP - -# Changing ip -update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" - -# Changing records -sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "changed dns ip for $domain to $ip" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain ip address +# options: USER DOMAIN IP +# +# The function for changing the main ip of DNS zone. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get old ip +get_domain_values 'dns' +old=$IP + +# Changing ip +update_object_value 'dns' 'DOMAIN' "$domain" '$IP' "$ip" + +# Changing records +sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "changed dns ip for $domain to $ip" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-record b/bin/v-change-dns-domain-record index 2134bfa7..d9a4310f 100755 --- a/bin/v-change-dns-domain-record +++ b/bin/v-change-dns-domain-record @@ -1,77 +1,77 @@ -#!/bin/bash -# info: change dns domain record -# options: USER DOMAIN ID VALUE [PRIORITY] -# -# The function for changing DNS record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 -dvalue=$(idn -t --quiet -u "$4" ) -dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]') -priority=$5 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY]' -validate_format 'user' 'domain' 'id' 'dvalue' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting old record -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then - priority='' -fi -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'" -dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_history "changed dns record on $domain to $dvalue" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain record +# options: USER DOMAIN ID VALUE [PRIORITY] +# +# The function for changing DNS record. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +dvalue=$(idn -t --quiet -u "$4" ) +dvalue=$(echo $dvalue | tr '[:upper:]' '[:lower:]') +priority=$5 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ID VALUE [PRIORITY]' +validate_format 'user' 'domain' 'id' 'dvalue' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting old record +line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) +eval $line +if [ "$TYPE" != 'MX' ] && [ "$TYPE" != 'SRV' ]; then + priority='' +fi +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Adding record +dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$priority'" +dns_rec="$dns_rec VALUE='$dvalue' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "changed dns record on $domain to $dvalue" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-soa b/bin/v-change-dns-domain-soa index f7b040ae..f12af4e7 100755 --- a/bin/v-change-dns-domain-soa +++ b/bin/v-change-dns-domain-soa @@ -1,63 +1,63 @@ -#!/bin/bash -# info: change dns domain soa record -# options: USER DOMAIN SOA -# -# The function for changing SOA record. This type of records can not be -# modified by v-change-dns-domain-record call. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SOA' -validate_format 'user' 'domain' 'soa' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing soa -update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa" - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "changed soa record for $domain to $soa" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain soa record +# options: USER DOMAIN SOA +# +# The function for changing SOA record. This type of records can not be +# modified by v-change-dns-domain-record call. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +soa=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SOA' +validate_format 'user' 'domain' 'soa' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing soa +update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa" + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "changed soa record for $domain to $soa" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-tpl b/bin/v-change-dns-domain-tpl index 770150c4..0d88be40 100755 --- a/bin/v-change-dns-domain-tpl +++ b/bin/v-change-dns-domain-tpl @@ -1,84 +1,84 @@ -#!/bin/bash -# info: change dns domain template -# options: USER DOMAIN -# -# The function for changing the template of records. By updating old records -# will be removed and new records will be generated in accordance with -# parameters of new template. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE' -validate_format 'user' 'domain' 'template' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_dns_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining variables -ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP') - -i=1 -ns=$(get_user_value '$NS') -for nameserver in ${ns//,/ };do - eval ns$i=$nameserver - (( ++i)) -done - -# Changing tpl -update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template" - -# Adding zone to dns dir -cat $DNSTPL/$template.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_history "changed dns template for $domain to $template" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain template +# options: USER DOMAIN +# +# The function for changing the template of records. By updating old records +# will be removed and new records will be generated in accordance with +# parameters of new template. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TEMPLATE' +validate_format 'user' 'domain' 'template' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_dns_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining variables +ip=$(get_object_value 'dns' 'DOMAIN' "$domain" '$IP') + +i=1 +ns=$(get_user_value '$NS') +for nameserver in ${ns//,/ };do + eval ns$i=$nameserver + (( ++i)) +done + +# Changing tpl +update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template" + +# Adding zone to dns dir +cat $DNSTPL/$template.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%ns1%/$ns1/g" \ + -e "s/%ns2%/$ns2/g" \ + -e "s/%ns3%/$ns3/g" \ + -e "s/%ns4%/$ns4/g" \ + -e "s/%time%/$TIME/g" \ + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "changed dns template for $domain to $template" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-dns-domain-ttl b/bin/v-change-dns-domain-ttl index 17656ce5..1112aa9b 100755 --- a/bin/v-change-dns-domain-ttl +++ b/bin/v-change-dns-domain-ttl @@ -1,62 +1,62 @@ -#!/bin/bash -# info: change dns domain ttl -# options: USER DOMAIN TTL -# -# The function for chaning the time to live TTL parameter for all records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ttl=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TTL' -validate_format 'user' 'domain' 'ttl' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ttl -update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl" - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_history "changed TTL for $domain to $ttl" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change dns domain ttl +# options: USER DOMAIN TTL +# +# The function for chaning the time to live TTL parameter for all records. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ttl=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TTL' +validate_format 'user' 'domain' 'ttl' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ttl +update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl" + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_history "changed TTL for $domain to $ttl" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-mail-account-password b/bin/v-change-mail-account-password index 55b85553..0c476374 100755 --- a/bin/v-change-mail-account-password +++ b/bin/v-change-mail-account-password @@ -1,72 +1,72 @@ -#!/bin/bash -# info: change mail account password -# options: USER DOMAIN ACCOUNT PASSWORD -# -# The function changes email account password. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Hiding password -A4='******' -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'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD' -validate_format 'user' 'domain' 'account' 'password' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x '/usr/bin/doveadm' ]; then - md5=$(/usr/bin/doveadm pw -s md5 -p "$password") -else - md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") -fi - -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update md5 -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" - -# Logging -log_history "changed password for $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change mail account password +# options: USER DOMAIN ACCOUNT PASSWORD +# +# The function changes email account password. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Hiding password +A4='******' +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'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT PASSWORD' +validate_format 'user' 'domain' 'account' 'password' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x '/usr/bin/doveadm' ]; then + md5=$(/usr/bin/doveadm pw -s md5 -p "$password") +else + md5=$(/usr/sbin/dovecotpw -s md5 -p "$password") +fi + +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update md5 +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5' "$md5" + +# Logging +log_history "changed password for $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-mail-account-quota b/bin/v-change-mail-account-quota index ce1e1e00..73135a36 100755 --- a/bin/v-change-mail-account-quota +++ b/bin/v-change-mail-account-quota @@ -1,62 +1,62 @@ -#!/bin/bash -# info: change mail account quota -# options: USER DOMAIN ACCOUNT QUOTA -# -# The function changes email account disk quota. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -quota=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA' -validate_format 'user' 'domain' 'account' 'quota' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update quota -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota" - -# Logging -log_history "changed mail quota for $account@$domain to $quota" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change mail account quota +# options: USER DOMAIN ACCOUNT QUOTA +# +# The function changes email account disk quota. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +quota=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT QUOTA' +validate_format 'user' 'domain' 'account' 'quota' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update quota +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA' "$quota" + +# Logging +log_history "changed mail quota for $account@$domain to $quota" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-mail-domain-catchall b/bin/v-change-mail-domain-catchall index 65528a4a..359f40b7 100755 --- a/bin/v-change-mail-domain-catchall +++ b/bin/v-change-mail-domain-catchall @@ -1,59 +1,59 @@ -#!/bin/bash -# info: change mail domain catchall email -# options: USER DOMAIN EMAIL -# -# The function changes mail domain cathcall. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -email="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN EMAIL' -validate_format 'user' 'domain' 'email' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Change cathcall alias -sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Change catchall in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" - - -# Logging -log_history "changed catchall email for $domain to $email" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change mail domain catchall email +# options: USER DOMAIN EMAIL +# +# The function changes mail domain cathcall. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +email="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN EMAIL' +validate_format 'user' 'domain' 'email' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Change cathcall alias +sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "*@$domain:$email" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Change catchall in config +update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' "$email" + + +# Logging +log_history "changed catchall email for $domain to $email" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-config-value b/bin/v-change-sys-config-value index c318da1d..d81d7735 100755 --- a/bin/v-change-sys-config-value +++ b/bin/v-change-sys-config-value @@ -1,51 +1,51 @@ -#!/bin/bash -# info: change sysconfig value -# options: KEY VALUE -# -# The function is for changing main config settings such as COMPANY_NAME or -# COMPANY_EMAIL and so on. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) -value=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'KEY VALUE' -validate_format 'key' -check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) -if [ -z "$check_ckey" ]; then - echo "Error: key $key not found" - log_event "$E_INVALID" "$EVENT" - exit $E_INVALID -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Updating conf -sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change sysconfig value +# options: KEY VALUE +# +# The function is for changing main config settings such as COMPANY_NAME or +# COMPANY_EMAIL and so on. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +key=$(echo "$1" | tr '[:lower:]' '[:upper:]' ) +value=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'KEY VALUE' +validate_format 'key' +check_ckey=$(grep "^$key='" $VESTA/conf/vesta.conf) +if [ -z "$check_ckey" ]; then + echo "Error: key $key not found" + log_event "$E_INVALID" "$EVENT" + exit $E_INVALID +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Updating conf +sed -i "s/$key=.*/$key='$value'/g" $VESTA/conf/vesta.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-ip-name b/bin/v-change-sys-ip-name index 4ecbffd7..eae3c7ee 100755 --- a/bin/v-change-sys-ip-name +++ b/bin/v-change-sys-ip-name @@ -1,47 +1,47 @@ -#!/bin/bash -# info: change ip name -# options: IP NAME -# -# The function for changing dns domain associated with ip. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -ip_name=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP IP_NAME' -validate_format 'ip' 'ip_name' -is_ip_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip name -update_ip_value '$NAME' "$ip_name" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed associated dns on $ip to $domain" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change ip name +# options: IP NAME +# +# The function for changing dns domain associated with ip. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +ip_name=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP IP_NAME' +validate_format 'ip' 'ip_name' +is_ip_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ip name +update_ip_value '$NAME' "$ip_name" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed associated dns on $ip to $domain" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-ip-owner b/bin/v-change-sys-ip-owner index 47c17138..ed8e447e 100755 --- a/bin/v-change-sys-ip-owner +++ b/bin/v-change-sys-ip-owner @@ -1,81 +1,81 @@ -#!/bin/bash -# info: change ip owner -# options: IP USER -# -# The function of changing ip address ownership. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -user=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP USER' -validate_format 'ip' 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_ip_valid -is_ip_key_empty '$U_WEB_DOMAINS' -is_ip_key_empty '$U_SYS_USERS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip owner -ip_owner=$(get_ip_value '$OWNER') -if [ "$ip_owner" != "$user" ]; then - ip_status="$(get_ip_value '$STATUS')" - update_ip_value '$OWNER' "$user" - decrease_user_value "$ip_owner" '$IP_OWNED' - if [ "$ip_owner" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for vesta_user in $(ls $VESTA/data/users); do - decrease_user_value "$vesta_user" '$IP_AVAIL' - done - else - decrease_user_value 'admin' '$IP_AVAIL' - fi - else - decrease_user_value "$ip_owner" '$IP_AVAIL' - decrease_user_value 'admin' '$IP_AVAIL' - fi - - increase_user_value "$user" '$IP_OWNED' - if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users); do - increase_user_value "$user" '$IP_AVAIL' - done - else - increase_user_value 'admin' '$IP_AVAIL' - fi - else - increase_user_value "$user" '$IP_AVAIL' - increase_user_value 'admin' '$IP_AVAIL' - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed owner of $ip to $user" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change ip owner +# options: IP USER +# +# The function of changing ip address ownership. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +user=$2 + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP USER' +validate_format 'ip' 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_ip_valid +is_ip_key_empty '$U_WEB_DOMAINS' +is_ip_key_empty '$U_SYS_USERS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ip owner +ip_owner=$(get_ip_value '$OWNER') +if [ "$ip_owner" != "$user" ]; then + ip_status="$(get_ip_value '$STATUS')" + update_ip_value '$OWNER' "$user" + decrease_user_value "$ip_owner" '$IP_OWNED' + if [ "$ip_owner" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for vesta_user in $(ls $VESTA/data/users); do + decrease_user_value "$vesta_user" '$IP_AVAIL' + done + else + decrease_user_value 'admin' '$IP_AVAIL' + fi + else + decrease_user_value "$ip_owner" '$IP_AVAIL' + decrease_user_value 'admin' '$IP_AVAIL' + fi + + increase_user_value "$user" '$IP_OWNED' + if [ "$user" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for user in $(ls $VESTA/data/users); do + increase_user_value "$user" '$IP_AVAIL' + done + else + increase_user_value 'admin' '$IP_AVAIL' + fi + else + increase_user_value "$user" '$IP_AVAIL' + increase_user_value 'admin' '$IP_AVAIL' + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed owner of $ip to $user" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-sys-ip-status b/bin/v-change-sys-ip-status index 40d5713a..761d6133 100755 --- a/bin/v-change-sys-ip-status +++ b/bin/v-change-sys-ip-status @@ -1,60 +1,60 @@ -#!/bin/bash -# info: change ip status -# options: IP IP_STATUS -# -# The function of changing an ip address's status. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -ip_status=$2 - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'IP IP_STATUS' -validate_format 'ip' 'ip_status' -is_ip_valid -if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then - echo "Error: status $ip_status is already set" - log_event "$E_EXISTS" "$EVENT" - exit $E_EXISTS -fi - -web_domains=$(get_ip_value '$U_WEB_DOMAINS') -sys_user=$(get_ip_value '$U_SYS_USERS') -ip_owner=$(get_ip_value '$OWNER') -if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then - echo "Error: ip $ip is used" - log_event "$E_INUSE" "$EVENT" - exit $E_INUSE -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing ip name -update_ip_value '$STATUS' "$ip_status" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $ip status to $ip_status" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change ip status +# options: IP IP_STATUS +# +# The function of changing an ip address's status. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +ip_status=$2 + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'IP IP_STATUS' +validate_format 'ip' 'ip_status' +is_ip_valid +if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then + echo "Error: status $ip_status is already set" + log_event "$E_EXISTS" "$EVENT" + exit $E_EXISTS +fi + +web_domains=$(get_ip_value '$U_WEB_DOMAINS') +sys_user=$(get_ip_value '$U_SYS_USERS') +ip_owner=$(get_ip_value '$OWNER') +if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then + echo "Error: ip $ip is used" + log_event "$E_INUSE" "$EVENT" + exit $E_INUSE +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing ip name +update_ip_value '$STATUS' "$ip_status" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed $ip status to $ip_status" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-contact b/bin/v-change-user-contact index 81da8e5b..7f21aece 100755 --- a/bin/v-change-user-contact +++ b/bin/v-change-user-contact @@ -1,51 +1,51 @@ -#!/bin/bash -# info: change user contact email -# options: USER EMAIL -# -# The function for changing of e-mail associated with a certain user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -email=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER EMAIL' -validate_format 'user' 'email' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user contact email -old_email=$(get_user_value '$CONTACT') -update_user_value "$user" '$CONTACT' "$email" -pw_str=$(grep -n "^$user:" /etc/passwd) -str=$(echo "$pw_str" | cut -f 1 -d :) -sed -i "$str s/$old_email/$email/g" /etc/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed contact email to $email" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user contact email +# options: USER EMAIL +# +# The function for changing of e-mail associated with a certain user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +email=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER EMAIL' +validate_format 'user' 'email' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user contact email +old_email=$(get_user_value '$CONTACT') +update_user_value "$user" '$CONTACT' "$email" +pw_str=$(grep -n "^$user:" /etc/passwd) +str=$(echo "$pw_str" | cut -f 1 -d :) +sed -i "$str s/$old_email/$email/g" /etc/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed contact email to $email" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-name b/bin/v-change-user-name index 8e32f2d8..26e90872 100755 --- a/bin/v-change-user-name +++ b/bin/v-change-user-name @@ -1,53 +1,53 @@ -#!/bin/bash -# info: change user full name -# options: USER FNAME LNAME -# -# The function allow to change user's full name. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -fname=$2 -lname=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER FNAME LNAME' -validate_format 'user' 'fname' 'lname' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get old values -old_fname=$(get_user_value '$FNAME') -old_lname=$(get_user_value '$LNAME') - -# Changing ns values -update_user_value "$user" '$FNAME' "$fname" -update_user_value "$user" '$LNAME' "$lname" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed user name to $fname $lname" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user full name +# options: USER FNAME LNAME +# +# The function allow to change user's full name. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +fname=$2 +lname=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER FNAME LNAME' +validate_format 'user' 'fname' 'lname' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get old values +old_fname=$(get_user_value '$FNAME') +old_lname=$(get_user_value '$LNAME') + +# Changing ns values +update_user_value "$user" '$FNAME' "$fname" +update_user_value "$user" '$LNAME' "$lname" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed user name to $fname $lname" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-ns b/bin/v-change-user-ns index 6d8af7ec..561eba7f 100755 --- a/bin/v-change-user-ns +++ b/bin/v-change-user-ns @@ -1,66 +1,66 @@ -#!/bin/bash -# info: change user nameservers -# options: USER NS1 NS2 [NS3] [NS4] -# -# The function for changing default nameservers for speciefic user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') -ns3=$4 -ns4=$5 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]' - -# Checking argument format -validate_format 'user' 'ns1' 'ns2' -if [ ! -z "$ns3" ]; then - ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns3' -fi -if [ ! -z "$ns4" ]; then - ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') - validate_format 'ns4' -fi - -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Merging values -ns="$ns1,$ns2,$ns3,$ns4" -ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//") - -# Changing ns values -update_user_value "$user" '$NS' "$ns" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed user nameservers to $ns1, $ns2" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user nameservers +# options: USER NS1 NS2 [NS3] [NS4] +# +# The function for changing default nameservers for speciefic user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g') +ns3=$4 +ns4=$5 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]' + +# Checking argument format +validate_format 'user' 'ns1' 'ns2' +if [ ! -z "$ns3" ]; then + ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns3' +fi +if [ ! -z "$ns4" ]; then + ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g') + validate_format 'ns4' +fi + +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Merging values +ns="$ns1,$ns2,$ns3,$ns4" +ns=$(echo "$ns"|sed -e "s/,,//g" -e "s/,$//") + +# Changing ns values +update_user_value "$user" '$NS' "$ns" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed user nameservers to $ns1, $ns2" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-package b/bin/v-change-user-package index 3480fc11..40761ba8 100755 --- a/bin/v-change-user-package +++ b/bin/v-change-user-package @@ -1,144 +1,144 @@ -#!/bin/bash -# info: change user package -# options: USER PACKAGE [FORCE] -# -# The function changes user's hosting package. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -package=$2 -force=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -is_package_avalable() { - # Parsing user data - usr_data=$(cat $USER_DATA/user.conf) - IFS=$'\n' - for key in $usr_data; do - eval ${key%%=*}=${key#*=} - done - - WEB_DOMAINS='0' - DATABASES='0' - MAIL_DOMAINS='0' - DNS_DOMAINS='0' - DISK_QUOTA='0' - BANDWIDTH='0' - - pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ - grep -v DATE) - eval $pkg_data - - # Comparing user data with package - if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\ - [[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\ - [[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\ - [[ "$DATABASES" -lt "$U_DATABASES" ]] ||\ - [[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\ - [[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\ - [[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then - echo "Error: Package not cover current usage" - log_event "$E_LIMIT" "$EVENT" - exit $E_LIMIT - fi -} - -change_user_package() { - usr_data=$(cat $USER_DATA/user.conf) - eval $usr_data - - pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ - grep -v DATE) - eval $pkg_data - - echo "FNAME='$FNAME' -LNAME='$LNAME' -PACKAGE='$package' -TEMPLATE='$TEMPLATE' -WEB_DOMAINS='$WEB_DOMAINS' -WEB_ALIASES='$WEB_ALIASES' -DNS_DOMAINS='$DNS_DOMAINS' -DNS_RECORDS='$DNS_RECORDS' -MAIL_DOMAINS='$MAIL_DOMAINS' -MAIL_ACCOUNTS='$MAIL_ACCOUNTS' -DATABASES='$DATABASES' -CRON_JOBS='$CRON_JOBS' -DISK_QUOTA='$DISK_QUOTA' -BANDWIDTH='$BANDWIDTH' -NS='$NS' -SHELL='$SHELL' -BACKUPS='$BACKUPS' -CONTACT='$CONTACT' -CRON_REPORTS='$CRON_REPORTS' -MD5='$MD5' -RKEY='$RKEY' -SUSPENDED='$SUSPENDED' -SUSPENDED_USERS='$SUSPENDED_USERS' -SUSPENDED_WEB='$SUSPENDED_WEB' -SUSPENDED_DNS='$SUSPENDED_DNS' -SUSPENDED_MAIL='$SUSPENDED_MAIL' -SUSPENDED_DB='$SUSPENDED_DB' -SUSPENDED_CRON='$SUSPENDED_CRON' -IP_AVAIL='$IP_AVAIL' -IP_OWNED='$IP_OWNED' -U_USERS='$U_USERS' -U_DISK='$U_DISK' -U_DISK_DIRS='$U_DISK_DIRS' -U_DISK_WEB='$U_DISK_WEB' -U_DISK_MAIL='$U_DISK_MAIL' -U_DISK_DB='$U_DISK_DB' -U_BANDWIDTH='$U_BANDWIDTH' -U_WEB_DOMAINS='$U_WEB_DOMAINS' -U_WEB_SSL='$U_WEB_SSL' -U_WEB_ALIASES='$U_WEB_ALIASES' -U_DNS_DOMAINS='$U_DNS_DOMAINS' -U_DNS_RECORDS='$U_DNS_RECORDS' -U_MAIL_DOMAINS='$U_MAIL_DOMAINS' -U_MAIL_DKIM='$U_MAIL_DKIM' -U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' -U_DATABASES='$U_DATABASES' -U_CRON_JOBS='$U_CRON_JOBS' -U_BACKUPS='$U_BACKUPS' -TIME='$TIME' -DATE='$DATE'" > $USER_DATA/user.conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER PACKAGE [FORCE]' -validate_format 'user' 'package' -is_object_valid 'user' 'USER' "$user" -is_package_valid -if [ "$force" != 'yes' ];then - is_package_avalable -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user package -change_user_package - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "changed $user package to $package" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user package +# options: USER PACKAGE [FORCE] +# +# The function changes user's hosting package. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +package=$2 +force=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +is_package_avalable() { + # Parsing user data + usr_data=$(cat $USER_DATA/user.conf) + IFS=$'\n' + for key in $usr_data; do + eval ${key%%=*}=${key#*=} + done + + WEB_DOMAINS='0' + DATABASES='0' + MAIL_DOMAINS='0' + DNS_DOMAINS='0' + DISK_QUOTA='0' + BANDWIDTH='0' + + pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ + grep -v DATE) + eval $pkg_data + + # Comparing user data with package + if [[ "$WEB_DOMAINS" -lt "$U_WEB_DOMAINS" ]] ||\ + [[ "$DNS_DOMAINS" -lt "$U_DNS_DOMAINS" ]] ||\ + [[ "$MAIL_DOMAINS" -lt "$U_MAIL_DOMAINS" ]] ||\ + [[ "$DATABASES" -lt "$U_DATABASES" ]] ||\ + [[ "$CRON_JOBS" -lt "$U_CRON_JOBS" ]] ||\ + [[ "$DISK_QUOTA" -lt "$U_DISK" ]] ||\ + [[ "$BANDWIDTH" -lt "$U_BANDWIDTH" ]]; then + echo "Error: Package not cover current usage" + log_event "$E_LIMIT" "$EVENT" + exit $E_LIMIT + fi +} + +change_user_package() { + usr_data=$(cat $USER_DATA/user.conf) + eval $usr_data + + pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\ + grep -v DATE) + eval $pkg_data + + echo "FNAME='$FNAME' +LNAME='$LNAME' +PACKAGE='$package' +TEMPLATE='$TEMPLATE' +WEB_DOMAINS='$WEB_DOMAINS' +WEB_ALIASES='$WEB_ALIASES' +DNS_DOMAINS='$DNS_DOMAINS' +DNS_RECORDS='$DNS_RECORDS' +MAIL_DOMAINS='$MAIL_DOMAINS' +MAIL_ACCOUNTS='$MAIL_ACCOUNTS' +DATABASES='$DATABASES' +CRON_JOBS='$CRON_JOBS' +DISK_QUOTA='$DISK_QUOTA' +BANDWIDTH='$BANDWIDTH' +NS='$NS' +SHELL='$SHELL' +BACKUPS='$BACKUPS' +CONTACT='$CONTACT' +CRON_REPORTS='$CRON_REPORTS' +MD5='$MD5' +RKEY='$RKEY' +SUSPENDED='$SUSPENDED' +SUSPENDED_USERS='$SUSPENDED_USERS' +SUSPENDED_WEB='$SUSPENDED_WEB' +SUSPENDED_DNS='$SUSPENDED_DNS' +SUSPENDED_MAIL='$SUSPENDED_MAIL' +SUSPENDED_DB='$SUSPENDED_DB' +SUSPENDED_CRON='$SUSPENDED_CRON' +IP_AVAIL='$IP_AVAIL' +IP_OWNED='$IP_OWNED' +U_USERS='$U_USERS' +U_DISK='$U_DISK' +U_DISK_DIRS='$U_DISK_DIRS' +U_DISK_WEB='$U_DISK_WEB' +U_DISK_MAIL='$U_DISK_MAIL' +U_DISK_DB='$U_DISK_DB' +U_BANDWIDTH='$U_BANDWIDTH' +U_WEB_DOMAINS='$U_WEB_DOMAINS' +U_WEB_SSL='$U_WEB_SSL' +U_WEB_ALIASES='$U_WEB_ALIASES' +U_DNS_DOMAINS='$U_DNS_DOMAINS' +U_DNS_RECORDS='$U_DNS_RECORDS' +U_MAIL_DOMAINS='$U_MAIL_DOMAINS' +U_MAIL_DKIM='$U_MAIL_DKIM' +U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' +U_DATABASES='$U_DATABASES' +U_CRON_JOBS='$U_CRON_JOBS' +U_BACKUPS='$U_BACKUPS' +TIME='$TIME' +DATE='$DATE'" > $USER_DATA/user.conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER PACKAGE [FORCE]' +validate_format 'user' 'package' +is_object_valid 'user' 'USER' "$user" +is_package_valid +if [ "$force" != 'yes' ];then + is_package_avalable +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user package +change_user_package + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "changed $user package to $package" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-password b/bin/v-change-user-password index f5443b96..10bbe570 100755 --- a/bin/v-change-user-password +++ b/bin/v-change-user-password @@ -1,57 +1,57 @@ -#!/bin/bash -# info: change user password -# options: USER PASSWORD -# -# The function changes user's password and updates RKEY value. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -password=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Hiding password -A2="******" -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'" - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER PASSWORD' -validate_format 'user' 'password' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user password -echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null -md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing RKEY value -update_user_value "$user" '$RKEY' "$(gen_password)" -update_user_value "$user" '$MD5' "$md5" - -# Logging -log_history "changed password" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user password +# options: USER PASSWORD +# +# The function changes user's password and updates RKEY value. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +password=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Hiding password +A2="******" +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'" + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER PASSWORD' +validate_format 'user' 'password' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user password +echo "$password" | /usr/bin/passwd "$user" --stdin &>/dev/null +md5=$(awk -v user=$user -F : 'user == $1 {print $2}' /etc/shadow) + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing RKEY value +update_user_value "$user" '$RKEY' "$(gen_password)" +update_user_value "$user" '$MD5' "$md5" + +# Logging +log_history "changed password" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-shell b/bin/v-change-user-shell index b55a1f86..71c0496f 100755 --- a/bin/v-change-user-shell +++ b/bin/v-change-user-shell @@ -1,54 +1,54 @@ -#!/bin/bash -# info: change user shell -# options: USER SHELL -# -# The function changes system shell of a user. Shell gives abilty to use ssh. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -shell=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER SHELL' -validate_format 'user' 'shell' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get shell full path -shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1) - -# Changing passwd file -/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null -shell=$(basename $shell_path) - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing user shell -update_user_value "$user" '$SHELL' "$shell" - -# Logging -log_history "changed $user shell to $shell" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user shell +# options: USER SHELL +# +# The function changes system shell of a user. Shell gives abilty to use ssh. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +shell=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER SHELL' +validate_format 'user' 'shell' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get shell full path +shell_path=$(/usr/bin/chsh --list-shells | grep -w "$shell" |head -n1) + +# Changing passwd file +/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null +shell=$(basename $shell_path) + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing user shell +update_user_value "$user" '$SHELL' "$shell" + +# Logging +log_history "changed $user shell to $shell" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-user-template b/bin/v-change-user-template index a7bb42e1..54382f12 100755 --- a/bin/v-change-user-template +++ b/bin/v-change-user-template @@ -1,49 +1,49 @@ -#!/bin/bash -# info: change user default template -# options: USER TEMPLATE -# -# The function changes default user web template. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -template=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER TEMPLATE' -validate_format 'user' 'template' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_apache_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing user shell -update_user_value "$user" '$TEMPLATE' "$template" - -# Logging -log_history "changed $user template to $template" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change user default template +# options: USER TEMPLATE +# +# The function changes default user web template. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +template=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER TEMPLATE' +validate_format 'user' 'template' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_apache_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing user shell +update_user_value "$user" '$TEMPLATE' "$template" + +# Logging +log_history "changed $user template to $template" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-ftp b/bin/v-change-web-domain-ftp index 82769879..1b94e85f 100755 --- a/bin/v-change-web-domain-ftp +++ b/bin/v-change-web-domain-ftp @@ -1,62 +1,62 @@ -#!/bin/bash -# info: add ftp account for web domain. -# options: USER DOMAIN FTP_USER FTP_PASSWORD -# -# The function creates addutional ftp account for web domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ftp_user=${1}_${3} -ftp_password=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' -validate_format 'user' 'domain' 'ftp_user' 'ftp_password' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_empty 'web' 'DOMAIN' "$domain" '$FTP_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding user -/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 -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)" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" - -# Logging -log_history "added ftp account $ftp_user for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: add ftp account for web domain. +# options: USER DOMAIN FTP_USER FTP_PASSWORD +# +# The function creates addutional ftp account for web domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ftp_user=${1}_${3} +ftp_password=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN FTP_USER FTP_PASSWORD' +validate_format 'user' 'domain' 'ftp_user' 'ftp_password' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_empty 'web' 'DOMAIN' "$domain" '$FTP_USER' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding user +/usr/sbin/adduser $ftp_user -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 +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)" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' "$ftp_user" +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' "$ftp_md5" + +# Logging +log_history "added ftp account $ftp_user for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-ip b/bin/v-change-web-domain-ip index 380d67f9..5032f3b2 100755 --- a/bin/v-change-web-domain-ip +++ b/bin/v-change-web-domain-ip @@ -1,96 +1,96 @@ -#!/bin/bash -# info: change web domain ip address -# options: USER DOMAIN IP [RESTART] -# -# 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. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ip=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN IP [RESTART]' -validate_format 'user' 'domain' 'ip' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_ip_valid -is_ip_avalable - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define variable for replace -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -old=$IP -new=$ip -replace_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - replace_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - replace_web_config -fi - -# Checking nginx -if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - replace_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counters -increase_ip_value "$new" -decrease_ip_value "$old" - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "changed web domain $domain ip to $ip" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change web domain ip address +# options: USER DOMAIN IP [RESTART] +# +# 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. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ip=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN IP [RESTART]' +validate_format 'user' 'domain' 'ip' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_ip_valid +is_ip_avalable + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Define variable for replace +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +old=$IP +new=$ip +replace_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + replace_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + replace_web_config +fi + +# Checking nginx +if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + replace_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update counters +increase_ip_value "$new" +decrease_ip_value "$old" + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "changed web domain $domain ip to $ip" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-nginx-tpl b/bin/v-change-web-domain-nginx-tpl index 957e8264..61bd2bca 100755 --- a/bin/v-change-web-domain-nginx-tpl +++ b/bin/v-change-web-domain-nginx-tpl @@ -1,101 +1,101 @@ -#!/bin/bash -# info: change web domain nginx template -# options: USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART] -# -# The function changes template of nginx.conf configuration file. The content -# of webdomain directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 -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" -extentions=${4-$default_extentions} -restart="$5" - - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]' -validate_format 'user' 'domain' 'template' -is_system_enabled "$PROXY_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' -is_nginx_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" - -# Delete old vhost -del_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config -fi - -# Add new vhost -NGINX="$template" -NGINX_EXT="$extentions" -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" -upd_web_domain_values -add_web_config -chown root:nginx $conf -chmod 640 $conf - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" - -# Restart web -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "changed nginx template for $domain to $template" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change web domain nginx template +# options: USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART] +# +# The function changes template of nginx.conf configuration file. The content +# of webdomain directories remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 +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" +extentions=${4-$default_extentions} +restart="$5" + + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]' +validate_format 'user' 'domain' 'template' +is_system_enabled "$PROXY_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' +is_nginx_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" + +# Delete old vhost +del_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config +fi + +# Add new vhost +NGINX="$template" +NGINX_EXT="$extentions" +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" +upd_web_domain_values +add_web_config +chown root:nginx $conf +chmod 640 $conf + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX" +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions" + +# Restart web +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "changed nginx template for $domain to $template" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-sslcert b/bin/v-change-web-domain-sslcert index 244a683c..dc7edaf8 100755 --- a/bin/v-change-web-domain-sslcert +++ b/bin/v-change-web-domain-sslcert @@ -1,79 +1,79 @@ -#!/bin/bash -# info: change domain ssl certificate -# options: USER DOMAIN SSL_DIR -# -# The function changes SSL domain certificate and the key. If ca file present -# it will be replaced as well. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ssl_dir=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_DIR' -validate_format 'user' 'domain' 'ssl_dir' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' -is_web_domain_cert_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting old certificate -tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) -rm -f $HOMEDIR/$user/conf/ssl.$domain.* -mv $USER_DATA/ssl/$domain.* $tmpdir -chown -R $user:$user $tmpdir - -# Adding new certificate to user data directory -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt -cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key -cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem -if [ -e "$ssl_dir/$domain.ca" ]; then - cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca - cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem -fi - -# Adding new certificate to user dir -cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt -cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/ssl.$domain.key -cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "changed ssl certificate for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change domain ssl certificate +# options: USER DOMAIN SSL_DIR +# +# The function changes SSL domain certificate and the key. If ca file present +# it will be replaced as well. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ssl_dir=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SSL_DIR' +validate_format 'user' 'domain' 'ssl_dir' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' +is_web_domain_cert_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting old certificate +tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) +rm -f $HOMEDIR/$user/conf/ssl.$domain.* +mv $USER_DATA/ssl/$domain.* $tmpdir +chown -R $user:$user $tmpdir + +# Adding new certificate to user data directory +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt +cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key +cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem +if [ -e "$ssl_dir/$domain.ca" ]; then + cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca + cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem +fi + +# Adding new certificate to user dir +cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/ssl.$domain.crt +cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/ssl.$domain.key +cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/ssl.$domain.pem +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/ssl.$domain.ca +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "changed ssl certificate for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-sslhome b/bin/v-change-web-domain-sslhome index defa40de..03a0ea38 100755 --- a/bin/v-change-web-domain-sslhome +++ b/bin/v-change-web-domain-sslhome @@ -1,79 +1,79 @@ -#!/bin/bash -# info: changing domain ssl home - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -ssl_home=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN SSL_HOME' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'web' -old_ssl_home=$SSL_HOME -SSL_HOME=$ssl_home -tpl_file="$WEBTPL/apache_$TPL.stpl" -conf="$HOMEDIR/$user/conf/web/shttpd.conf" - -# Parsing tpl_option -case $SSL_HOME in - single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; - old="$HOMEDIR/$user/web/$domain/public_html" ;; - same) new="$HOMEDIR/$user/web/$domain/public_html" ; - old="$HOMEDIR/$user/web/$domain/public_shtml" ;; - *) check_args '3' "2" 'USER DOMAIN SSLHOME' -esac - -# Changing sslhome directory -replace_web_config - -# Checking nginx config -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web//snginx.conf" - replace_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "changed ssl home for $domain to $ssl_home" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: changing domain ssl home + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +ssl_home=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN SSL_HOME' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get domain values +get_domain_values 'web' +old_ssl_home=$SSL_HOME +SSL_HOME=$ssl_home +tpl_file="$WEBTPL/apache_$TPL.stpl" +conf="$HOMEDIR/$user/conf/web/shttpd.conf" + +# Parsing tpl_option +case $SSL_HOME in + single) new="$HOMEDIR/$user/web/$domain/public_shtml" ; + old="$HOMEDIR/$user/web/$domain/public_html" ;; + same) new="$HOMEDIR/$user/web/$domain/public_html" ; + old="$HOMEDIR/$user/web/$domain/public_shtml" ;; + *) check_args '3' "2" 'USER DOMAIN SSLHOME' +esac + +# Changing sslhome directory +replace_web_config + +# Checking nginx config +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web//snginx.conf" + replace_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME" + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "changed ssl home for $domain to $ssl_home" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-change-web-domain-stats b/bin/v-change-web-domain-stats index 05ee2b61..f4497440 100755 --- a/bin/v-change-web-domain-stats +++ b/bin/v-change-web-domain-stats @@ -1,95 +1,95 @@ -#!/bin/bash -# info: change web domain statistics -# options: USER DOMAIN TYPE -# -# The function of deleting site's system of statistics. Its type is -# automatically chooses from client's configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -type=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TYPE' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_type_valid "$STATS_SYSTEM" "$type" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic type -get_domain_values 'web' - -# Comparing stats types -if [ "$STATS" == $type ]; then - log_event "$OK" "$EVENT" - exit 0 -fi - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Deleting dir content -rm -rf $stats_dir/* - -# Deleting config -rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Adding statistic config -cat $WEBTPL/$type.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$type.$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" - -# Logging -log_history "changed web log stats for $domain to $type" -log_event "$OK" "$EVENT" - -# Build stats -exec $BIN/v-update-web-domain-stat $user $domain - -exit +#!/bin/bash +# info: change web domain statistics +# options: USER DOMAIN TYPE +# +# The function of deleting site's system of statistics. Its type is +# automatically chooses from client's configuration file. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +type=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TYPE' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_type_valid "$STATS_SYSTEM" "$type" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining statistic type +get_domain_values 'web' + +# Comparing stats types +if [ "$STATS" == $type ]; then + log_event "$OK" "$EVENT" + exit 0 +fi + +# Defining statistic dir +stats_dir="$HOMEDIR/$user/web/$domain/stats" + +# Deleting dir content +rm -rf $stats_dir/* + +# Deleting config +rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Adding statistic config +cat $WEBTPL/$type.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$type.$domain.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type" + +# Logging +log_history "changed web log stats for $domain to $type" +log_event "$OK" "$EVENT" + +# Build stats +exec $BIN/v-update-web-domain-stat $user $domain + +exit diff --git a/bin/v-change-web-domain-tpl b/bin/v-change-web-domain-tpl index 19b41152..b812910a 100755 --- a/bin/v-change-web-domain-tpl +++ b/bin/v-change-web-domain-tpl @@ -1,110 +1,110 @@ -#!/bin/bash -# info: change web domain template -# options: USER DOMAIN TEMPLATE [RESTART] -# -# The function changes template of httpd.conf configuration file. The content -# of webdomain directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -template=$3 -restart=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]' -validate_format 'user' 'domain' 'template' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_apache_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Deleting domain -tpl_file="$WEBTPL/apache_$TPL.tpl" -old_tpl=$TPL -conf="$HOMEDIR/$user/conf/web/httpd.conf" -del_web_config - -# Deleting ssl vhost -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config -fi - -# Defining variables for new vhost config -upd_web_domain_values -tpl_file="$WEBTPL/apache_$template.tpl" - -# Checking error log -if [ "$ELOG" = 'no' ]; then - elog='#' -else - elog='' -fi - -# Adding domain to the httpd.conf -add_web_config - -# Running template trigger -if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot -fi - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - tpl_file="$WEBTPL/apache_$template.stpl" - - add_web_config - - # Running template trigger - if [ -x $WEBTPL/apache_$template.sh ]; then - $WEBTPL/apache_$template.sh \ - "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot" - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing tpl in config -update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template" - -# Restart web -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "changed web domain template for $domain to $template" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: change web domain template +# options: USER DOMAIN TEMPLATE [RESTART] +# +# The function changes template of httpd.conf configuration file. The content +# of webdomain directories remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +template=$3 +restart=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]' +validate_format 'user' 'domain' 'template' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_apache_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Deleting domain +tpl_file="$WEBTPL/apache_$TPL.tpl" +old_tpl=$TPL +conf="$HOMEDIR/$user/conf/web/httpd.conf" +del_web_config + +# Deleting ssl vhost +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config +fi + +# Defining variables for new vhost config +upd_web_domain_values +tpl_file="$WEBTPL/apache_$template.tpl" + +# Checking error log +if [ "$ELOG" = 'no' ]; then + elog='#' +else + elog='' +fi + +# Adding domain to the httpd.conf +add_web_config + +# Running template trigger +if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot +fi + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + tpl_file="$WEBTPL/apache_$template.stpl" + + add_web_config + + # Running template trigger + if [ -x $WEBTPL/apache_$template.sh ]; then + $WEBTPL/apache_$template.sh \ + "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot" + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing tpl in config +update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template" + +# Restart web +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "changed web domain template for $domain to $template" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-cron-job b/bin/v-delete-cron-job index 82a46365..13527d0a 100755 --- a/bin/v-delete-cron-job +++ b/bin/v-delete-cron-job @@ -1,62 +1,62 @@ -#!/bin/bash -# info: delete cron job -# options: USER JOB -# -# The function deletes cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB' -validate_format 'user' 'job' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting job -sed -i "/JOB='$job' /d" $USER_DATA/cron.conf - -# Sorting jobs by id -sort_cron_jobs - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Decreasing cron value -decrease_user_value "$user" '$U_CRON_JOBS' - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "deleted cron job $job" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete cron job +# options: USER JOB +# +# The function deletes cron job. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB' +validate_format 'user' 'job' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_unsuspended 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting job +sed -i "/JOB='$job' /d" $USER_DATA/cron.conf + +# Sorting jobs by id +sort_cron_jobs + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Decreasing cron value +decrease_user_value "$user" '$U_CRON_JOBS' + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "deleted cron job $job" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-cron-reports b/bin/v-delete-cron-reports index 0dc28ee4..10fd121f 100755 --- a/bin/v-delete-cron-reports +++ b/bin/v-delete-cron-reports @@ -1,54 +1,54 @@ -#!/bin/bash -# info: delete cron reports -# options: USER -# -# The script for disabling reports on cron tasks and administrative -# notifications. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Changing user report value -update_user_value "$user" '$CRON_REPORTS' 'no' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -$BIN/v-restart-cron "$EVENT" - -# Logging -log_history "disabled cron reporting" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete cron reports +# options: USER +# +# The script for disabling reports on cron tasks and administrative +# notifications. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Changing user report value +update_user_value "$user" '$CRON_REPORTS' 'no' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +$BIN/v-restart-cron "$EVENT" + +# Logging +log_history "disabled cron reporting" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-database b/bin/v-delete-database index 438aada6..47860c9f 100755 --- a/bin/v-delete-database +++ b/bin/v-delete-database @@ -1,65 +1,65 @@ -#!/bin/bash -# info: delete database -# options: USER DATABASE -# -# The function for deleting the database. If database user have access to -# another database, he will not be deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) delete_mysql_database ;; - pgsql) delete_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting database -sed -i "/DB='$database' /d" $USER_DATA/db.conf - -# Decreasing counters -decrease_dbhost_values -decrease_user_value "$user" '$U_DATABASES' - -# Logging -log_history "deleted $database database" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete database +# options: USER DATABASE +# +# The function for deleting the database. If database user have access to +# another database, he will not be deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) delete_mysql_database ;; + pgsql) delete_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting database +sed -i "/DB='$database' /d" $USER_DATA/db.conf + +# Decreasing counters +decrease_dbhost_values +decrease_user_value "$user" '$U_DATABASES' + +# Logging +log_history "deleted $database database" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-database-server b/bin/v-delete-database-server index 5bd03a5f..3fd5f43d 100755 --- a/bin/v-delete-database-server +++ b/bin/v-delete-database-server @@ -1,50 +1,50 @@ -#!/bin/bash -# info: delete database server -# options: TYPE HOST -# -# The function for deleting the database host from vesta configuration. It will -# be deleted if there are no databases created on it only. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST' -validate_format 'type' 'host' -is_system_enabled "$DB_SYSTEM" -is_type_valid "$DB_SYSTEM" "$type" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_dbhost_free - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -# Deleting server -sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted $type database server $host" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete database server +# options: TYPE HOST +# +# The function for deleting the database host from vesta configuration. It will +# be deleted if there are no databases created on it only. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST' +validate_format 'type' 'host' +is_system_enabled "$DB_SYSTEM" +is_type_valid "$DB_SYSTEM" "$type" +is_object_valid "../../conf/$type" 'HOST' "$host" +is_dbhost_free + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +# Deleting server +sed -i "/HOST='$host' /d" $VESTA/conf/$type.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "deleted $type database server $host" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-databases b/bin/v-delete-databases index 5394afa4..fa3772a7 100755 --- a/bin/v-delete-databases +++ b/bin/v-delete-databases @@ -1,48 +1,48 @@ -#!/bin/bash -# info: delete user databases -# options: USER -# -# The function deletes all user databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-delete-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user databases +# options: USER +# +# The function deletes all user databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + $BIN/v-delete-database "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-domain b/bin/v-delete-dns-domain index 88aaa98b..fa674d3d 100755 --- a/bin/v-delete-dns-domain +++ b/bin/v-delete-dns-domain @@ -1,70 +1,70 @@ -#!/bin/bash -# info: delete dns domain -# options: USER DOMAIN -# -# The function for deleting DNS domain. By deleting it all records will also be -# deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') - -# Deleting domain in named.conf -sed -i "/\/$domain.db\"/d" /etc/named.conf -rm -f $HOMEDIR/$user/conf/dns/$domain.db - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting domain -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf -rm -f $USER_DATA/dns/$domain.conf - -# Decreasing domain value -decrease_user_value "$user" '$U_DNS_DOMAINS' -decrease_user_value "$user" '$U_DNS_RECORDS' "$records" - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - - -# Logging -log_history "deleted dns domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns domain +# options: USER DOMAIN +# +# The function for deleting DNS domain. By deleting it all records will also be +# deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') + +# Deleting domain in named.conf +sed -i "/\/$domain.db\"/d" /etc/named.conf +rm -f $HOMEDIR/$user/conf/dns/$domain.db + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting domain +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/dns.conf +rm -f $USER_DATA/dns/$domain.conf + +# Decreasing domain value +decrease_user_value "$user" '$U_DNS_DOMAINS' +decrease_user_value "$user" '$U_DNS_RECORDS' "$records" + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + + +# Logging +log_history "deleted dns domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-domain-record b/bin/v-delete-dns-domain-record index 5f5ae64e..c2b1491b 100755 --- a/bin/v-delete-dns-domain-record +++ b/bin/v-delete-dns-domain-record @@ -1,64 +1,64 @@ -#!/bin/bash -# info: delete dns record -# options: USER DOMAIN ID -# -# The function for deleting a certain record of DNS zone. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID' -validate_format 'user' 'domain' 'id' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting record -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Upddate counters -records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" -update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -decrease_user_value "$user" '$U_DNS_RECORDS' - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_history "deleted dns record $id on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns record +# options: USER DOMAIN ID +# +# The function for deleting a certain record of DNS zone. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ID' +validate_format 'user' 'domain' 'id' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting record +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Upddate counters +records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')" +update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +decrease_user_value "$user" '$U_DNS_RECORDS' + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_history "deleted dns record $id on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-domains b/bin/v-delete-dns-domains index 2523cc49..1d65dccd 100755 --- a/bin/v-delete-dns-domains +++ b/bin/v-delete-dns-domains @@ -1,50 +1,50 @@ -#!/bin/bash -# info: delete dns domains -# options: USER -# -# The function for deleting all users DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -$BIN/v-restart-dns "$EVENT" - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns domains +# options: USER +# +# The function for deleting all users DNS domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-delete-dns-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +$BIN/v-restart-dns "$EVENT" + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-dns-on-web-alias b/bin/v-delete-dns-on-web-alias index cd30be8c..50c1e1d7 100755 --- a/bin/v-delete-dns-on-web-alias +++ b/bin/v-delete-dns-on-web-alias @@ -1,79 +1,79 @@ -#!/bin/bash -# info: delete dns domain or dns record based on web domain alias -# options: USER DOMAIN -# -# The function deletes dns domain or dns record based on web domain alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') -domain_idn=$(idn -t --quiet -a "$domain") -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') -dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ALIAS' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' - -# Check if it a simple domain -if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then - if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then - $BIN/v-delete-dns-domain $user $dom_alias $IP $restart - fi -else - # Check subdomain - sub=$(echo "$dom_alias" | cut -f1 -d . -s) - root=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) - if [ -e "$USER_DATA/dns/$root.conf" ]; then - if [ "$sub" == '*' ]; then - rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf) - else - rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf) - fi - if [ ! -z "$rec" ]; then - eval "$rec" - $BIN/v-delete-dns-domain-record $user "$root" "$ID" - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete dns domain or dns record based on web domain alias +# options: USER DOMAIN +# +# The function deletes dns domain or dns record based on web domain alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g') +domain_idn=$(idn -t --quiet -a "$domain") +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g') +dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]') +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ALIAS' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' + +# Check if it a simple domain +if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then + if [ -e "$USER_DATA/dns/$dom_alias.conf" ]; then + $BIN/v-delete-dns-domain $user $dom_alias $IP $restart + fi +else + # Check subdomain + sub=$(echo "$dom_alias" | cut -f1 -d . -s) + root=$(echo "$dom_alias" | sed -e "s/^$sub.//" ) + if [ -e "$USER_DATA/dns/$root.conf" ]; then + if [ "$sub" == '*' ]; then + rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$root.conf) + else + rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$root.conf) + fi + if [ ! -z "$rec" ]; then + eval "$rec" + $BIN/v-delete-dns-domain-record $user "$root" "$ID" + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account b/bin/v-delete-mail-account index 840aa9f4..8fb45684 100755 --- a/bin/v-delete-mail-account +++ b/bin/v-delete-mail-account @@ -1,70 +1,70 @@ -#!/bin/bash -# info: delete mail account -# options: USER DOMAIN ACCOUNT -# -# The function deletes email account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -for al in ${aliases//,/ }; do - sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases -done - -sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -rm -rf $HOMEDIR/$user/mail/$domain/$account - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf - -# Decrease mail accounts counter -accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') -decrease_user_value "$user" '$U_MAIL_ACCOUNTS' -update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" - - -# Logging -log_history "deleted $account@$domain mail account" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail account +# options: USER DOMAIN ACCOUNT +# +# The function deletes email account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') +for al in ${aliases//,/ }; do + sed -i "/^$al@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases +done + +sed -i "/^$account@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +rm -rf $HOMEDIR/$user/mail/$domain/$account + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +sed -i "/ACCOUNT='$account'/d" $USER_DATA/mail/$domain.conf + +# Decrease mail accounts counter +accounts=$(wc -l $USER_DATA/mail/$domain.conf | cut -f 1 -d ' ') +decrease_user_value "$user" '$U_MAIL_ACCOUNTS' +update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accounts" + + +# Logging +log_history "deleted $account@$domain mail account" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account-alias b/bin/v-delete-mail-account-alias index eb628ea3..e6904654 100755 --- a/bin/v-delete-mail-account-alias +++ b/bin/v-delete-mail-account-alias @@ -1,70 +1,70 @@ -#!/bin/bash -# info: delete mail account alias aka nickname -# options: USER DOMAIN ACCOUNT ALIAS -# -# The function deletes email account alias. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -malias=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' -validate_format 'user' 'domain' 'account' 'malias' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') -if [ -z "$(echo $aliases | grep -w $malias)" ]; then - echo "Error: alias $malias is not exist" - log_event "$E_NOTEXIST $EVENT" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases -aliases=$(echo "$aliases" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$malias$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" - -# Logging -log_history "deleted alias $malias on $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail account alias aka nickname +# options: USER DOMAIN ACCOUNT ALIAS +# +# The function deletes email account alias. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT ALIAS' +validate_format 'user' 'domain' 'account' 'malias' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +aliases=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS') +if [ -z "$(echo $aliases | grep -w $malias)" ]; then + echo "Error: alias $malias is not exist" + log_event "$E_NOTEXIST $EVENT" + exit $E_NOTEXIST +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +sed -i "/^$malias@$domain:$account/d" $HOMEDIR/$user/conf/mail/$domain/aliases +aliases=$(echo "$aliases" |\ + sed -e "s/,/\n/g"|\ + sed -e "s/^$malias$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$ALIAS' "$aliases" + +# Logging +log_history "deleted alias $malias on $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account-autoreply b/bin/v-delete-mail-account-autoreply index 05c8d15c..37996e2c 100755 --- a/bin/v-delete-mail-account-autoreply +++ b/bin/v-delete-mail-account-autoreply @@ -1,61 +1,61 @@ -#!/bin/bash -# info: delete mail account autoreply message -# options: USER DOMAIN ACCOUNT ALIAS -# -# The function delete email account autoreply. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -malias=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg -rm -f $USER_DATA/mail/$domain/$account@$domain.msg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no' - -# Logging -log_history "$EVENT" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail account autoreply message +# options: USER DOMAIN ACCOUNT ALIAS +# +# The function delete email account autoreply. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +malias=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +is_object_value_exist "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +rm -f $HOMEDIR/$user/conf/mail/$domain/autoreply.$account.msg +rm -f $USER_DATA/mail/$domain/$account@$domain.msg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$AUTOREPLY' 'no' + +# Logging +log_history "$EVENT" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-account-forward b/bin/v-delete-mail-account-forward index 083ca531..007adb13 100755 --- a/bin/v-delete-mail-account-forward +++ b/bin/v-delete-mail-account-forward @@ -1,72 +1,72 @@ -#!/bin/bash -# info: delte mail account forward -# options: USER DOMAIN ACCOUNT EMAIL -# -# The function add delete email account forward address. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 -forward=$4 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' -validate_format 'user' 'domain' 'account' 'forward' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" -fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') -if [ -z "$(echo $fwd | grep -w $forward)" ]; then - echo "Error: forward $forward is not exist" - log_event "$E_NOTEXIST $EVENT" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -fwd=$(echo "$fwd" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$forward$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') - -sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases -echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" - -# Logging -log_history "deleted $forward forward on $account@$domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delte mail account forward +# options: USER DOMAIN ACCOUNT EMAIL +# +# The function add delete email account forward address. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 +forward=$4 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '4' "$#" 'USER DOMAIN ACCOUNT FORWARD' +validate_format 'user' 'domain' 'account' 'forward' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" +fwd=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD') +if [ -z "$(echo $fwd | grep -w $forward)" ]; then + echo "Error: forward $forward is not exist" + log_event "$E_NOTEXIST $EVENT" + exit $E_NOTEXIST +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +fwd=$(echo "$fwd" |\ + sed -e "s/,/\n/g"|\ + sed -e "s/^$forward$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') + +sed -i "/^$account@$domain:/ d" $HOMEDIR/$user/conf/mail/$domain/aliases +echo "$account@$domain:$fwd" >> $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$FWD' "$fwd" + +# Logging +log_history "deleted $forward forward on $account@$domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain b/bin/v-delete-mail-domain index 9d940a3c..f610cdf5 100755 --- a/bin/v-delete-mail-domain +++ b/bin/v-delete-mail-domain @@ -1,72 +1,72 @@ -#!/bin/bash -# info: delete mail domain -# options: USER DOMAIN -# -# The function for deleting MAIL domain. By deleting it all accounts will -# also be deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get domain values -get_domain_values 'mail' -accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') - -rm -f /etc/exim/domains/$domain -rm -rf $HOMEDIR/$user/conf/$domain -rm -rf $HOMEDIR/$user/mail/$domain - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete domain config -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf -rm -f $USER_DATA/mail/$domain.conf -rm -f $USER_DATA/mail/$domain.pem -rm -f $USER_DATA/mail/$domain.pub -rm -f $USER_DATA/mail/*@$domain.msg - -# Decreasing domain value -decrease_user_value "$user" '$U_MAIL_DOMAINS' -if [ "$DKIM" = 'yes' ]; then - decrease_user_value "$user" '$U_MAIL_DKMI' -fi -decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" - - -# Logging -log_history "deleted mail domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain +# options: USER DOMAIN +# +# The function for deleting MAIL domain. By deleting it all accounts will +# also be deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get domain values +get_domain_values 'mail' +accounts=$(wc -l $USER_DATA/mail/$domain.conf|cut -f 1 -d ' ') + +rm -f /etc/exim/domains/$domain +rm -rf $HOMEDIR/$user/conf/$domain +rm -rf $HOMEDIR/$user/mail/$domain + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete domain config +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/mail.conf +rm -f $USER_DATA/mail/$domain.conf +rm -f $USER_DATA/mail/$domain.pem +rm -f $USER_DATA/mail/$domain.pub +rm -f $USER_DATA/mail/*@$domain.msg + +# Decreasing domain value +decrease_user_value "$user" '$U_MAIL_DOMAINS' +if [ "$DKIM" = 'yes' ]; then + decrease_user_value "$user" '$U_MAIL_DKMI' +fi +decrease_user_value "$user" '$U_MAIL_ACCOUNTS' "$accounts" + + +# Logging +log_history "deleted mail domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-antispam b/bin/v-delete-mail-domain-antispam index f19631e1..7eb31701 100755 --- a/bin/v-delete-mail-domain-antispam +++ b/bin/v-delete-mail-domain-antispam @@ -1,57 +1,57 @@ -#!/bin/bash -# info: delete mail domain antispam support -# options: USER DOMAIN -# -# The function disable spamassasin for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete antispam key -sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete antispam in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no' - -# Logging -log_history "disabled antispam support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain antispam support +# options: USER DOMAIN +# +# The function disable spamassasin for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTISPAM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Delete antispam key +sed -i "/antispam/d" $HOMEDIR/$user/conf/mail/$domain/protection + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete antispam in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTISPAM' 'no' + +# Logging +log_history "disabled antispam support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-antivirus b/bin/v-delete-mail-domain-antivirus index c09ac61d..6ddeae4d 100755 --- a/bin/v-delete-mail-domain-antivirus +++ b/bin/v-delete-mail-domain-antivirus @@ -1,57 +1,57 @@ -#!/bin/bash -# info: delete mail domain antivirus support -# options: USER DOMAIN -# -# The function disables clamav scan for incomming emails. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete antivirus key -sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete antivirus in config -update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no' - -# Logging -log_history "disabled antivirus support on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain antivirus support +# options: USER DOMAIN +# +# The function disables clamav scan for incomming emails. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Delete antivirus key +sed -i "/antivirus/d" $HOMEDIR/$user/conf/mail/$domain/protection + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete antivirus in config +update_object_value 'mail' 'DOMAIN' "$domain" '$ANTIVIRUS' 'no' + +# Logging +log_history "disabled antivirus support on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-catchall b/bin/v-delete-mail-domain-catchall index 4ec0fc0d..a984b400 100755 --- a/bin/v-delete-mail-domain-catchall +++ b/bin/v-delete-mail-domain-catchall @@ -1,57 +1,57 @@ -#!/bin/bash -# info: delete mail domain catchall email -# options: USER DOMAIN -# -# The function disables mail domain cathcall. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Delete cathcall alias -sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Delete catchall in config -update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' '' - -# Logging -log_history "delted catchall email on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain catchall email +# options: USER DOMAIN +# +# The function disables mail domain cathcall. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$CATCHALL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Delete cathcall alias +sed -i "/*@$domain:/d" $HOMEDIR/$user/conf/mail/$domain/aliases + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Delete catchall in config +update_object_value 'mail' 'DOMAIN' "$domain" '$CATCHALL' '' + +# Logging +log_history "delted catchall email on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domain-dkim b/bin/v-delete-mail-domain-dkim index 16c4943b..88028331 100755 --- a/bin/v-delete-mail-domain-dkim +++ b/bin/v-delete-mail-domain-dkim @@ -1,69 +1,69 @@ -#!/bin/bash -# info: delete mail domain dkim support -# options: USER DOMAIN [DKIM_SIZE] -# -# The function delete DKIM domain pem. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Generating dkim -rm -f $USER_DATA/mail/$domain.pem -rm -f $USER_DATA/mail/$domain.pub -rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem - -# Checking dns domain -check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") -if [ "$?" -eq 0 ]; then - records=$($BIN/v-list-dns-domain-records $user $domain plain) - dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ') - for id in $dkim_records; do - $BIN/v-delete-dns-domain-record $user $domain $id - done -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updatoing config -update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no' -decrease_user_value "$user" '$U_MAIL_DKMI' - -# Logging -log_history "disabled DKIM support on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domain dkim support +# options: USER DOMAIN [DKIM_SIZE] +# +# The function delete DKIM domain pem. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_value_exist 'mail' 'DOMAIN' "$domain" '$DKIM' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Generating dkim +rm -f $USER_DATA/mail/$domain.pem +rm -f $USER_DATA/mail/$domain.pub +rm -f $HOMEDIR/$user/conf/mail/$domain/dkim.pem + +# Checking dns domain +check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") +if [ "$?" -eq 0 ]; then + records=$($BIN/v-list-dns-domain-records $user $domain plain) + dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ') + for id in $dkim_records; do + $BIN/v-delete-dns-domain-record $user $domain $id + done +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updatoing config +update_object_value 'mail' 'DOMAIN' "$domain" '$DKIM' 'no' +decrease_user_value "$user" '$U_MAIL_DKMI' + +# Logging +log_history "disabled DKIM support on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-mail-domains b/bin/v-delete-mail-domains index 051eab84..d3f5cc2a 100755 --- a/bin/v-delete-mail-domains +++ b/bin/v-delete-mail-domains @@ -1,47 +1,47 @@ -#!/bin/bash -# info: delete mail domains -# options: USER -# -# The function for deleting all users mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete mail domains +# options: USER +# +# The function for deleting all users mail domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-delete-mail-domain "$user" "$domain" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-sys-ip b/bin/v-delete-sys-ip index a2fa6f2e..f6951e59 100755 --- a/bin/v-delete-sys-ip +++ b/bin/v-delete-sys-ip @@ -1,94 +1,94 @@ -#!/bin/bash -# info: delete system ip -# options: 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. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'IP' -validate_format 'ip' -is_ip_valid "$ip" -is_ip_key_empty '$U_WEB_DOMAINS' -is_ip_key_empty '$U_SYS_USERS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config paths -conf='/etc/httpd/conf.d/vesta.conf' -nconf='/etc/nginx/conf.d/vesta_ip.conf' -iconf='/etc/sysconfig/network-scripts/ifcfg' -rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' - -# Get ip owner -user="$(get_ip_value '$OWNER')" -ip_status="$(get_ip_value '$STATUS')" - -# Deleting interface -get_current_interface -/sbin/ifconfig "$interface" down - -# Deleting startup script -rm -f $iconf-$interface - -# Deleting vesta ip -rm -f $VESTA/data/ips/$ip - -# Deleting namehosting support -namehost_ip_disable - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user conf -if [ ! -z "$user" ]; then - decrease_user_value "$user" '$IP_OWNED' -fi - -if [ "$user" = 'admin' ]; then - if [ "$ip_status" = 'shared' ]; then - for user in $(ls $VESTA/data/users/); do - decrease_user_value "$user" '$IP_AVAIL' - done - else - decrease_user_value 'admin' '$IP_AVAIL' - fi -else - decrease_user_value "$user" '$IP_AVAIL' - decrease_user_value 'admin' '$IP_AVAIL' -fi - - -# Adding task to the vesta pipe -if [ "$web_restart" = 'yes' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "delted system ip address $ip" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete system ip +# options: 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. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'IP' +validate_format 'ip' +is_ip_valid "$ip" +is_ip_key_empty '$U_WEB_DOMAINS' +is_ip_key_empty '$U_SYS_USERS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config paths +conf='/etc/httpd/conf.d/vesta.conf' +nconf='/etc/nginx/conf.d/vesta_ip.conf' +iconf='/etc/sysconfig/network-scripts/ifcfg' +rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' + +# Get ip owner +user="$(get_ip_value '$OWNER')" +ip_status="$(get_ip_value '$STATUS')" + +# Deleting interface +get_current_interface +/sbin/ifconfig "$interface" down + +# Deleting startup script +rm -f $iconf-$interface + +# Deleting vesta ip +rm -f $VESTA/data/ips/$ip + +# Deleting namehosting support +namehost_ip_disable + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating user conf +if [ ! -z "$user" ]; then + decrease_user_value "$user" '$IP_OWNED' +fi + +if [ "$user" = 'admin' ]; then + if [ "$ip_status" = 'shared' ]; then + for user in $(ls $VESTA/data/users/); do + decrease_user_value "$user" '$IP_AVAIL' + done + else + decrease_user_value 'admin' '$IP_AVAIL' + fi +else + decrease_user_value "$user" '$IP_AVAIL' + decrease_user_value 'admin' '$IP_AVAIL' +fi + + +# Adding task to the vesta pipe +if [ "$web_restart" = 'yes' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "delted system ip address $ip" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user b/bin/v-delete-user index 8007b099..ad84fe94 100755 --- a/bin/v-delete-user +++ b/bin/v-delete-user @@ -1,113 +1,113 @@ -#!/bin/bash -# info: delete user -# options: USER -# -# This function deletes a certain user and all his resourses such as domains, -# databases, cron jobs, etc. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking web system is enabled -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-web-domains $user $restart - $BIN/v-delete-web-domains $user $restart - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking dns system is enabled -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-dns-domains $user $restart - $BIN/v-delete-dns-domains $user $restart - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking mail system is enabled -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-mail-domains $user - $BIN/v-delete-mail-domains $user - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking db system is enabled -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-databases $user - $BIN/v-delete-databases $user - rv="$?" - if [ "$rv" -ne '0' ]; then - exit $rv - fi -fi - -# Checking ip -$BIN/v-delete-user-ips "$user" -rv="$?" -if [ "$rv" -ne '0' ]; then - exit $rv -fi - -# Deleteing user pipes -sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe -sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe - -# Removing system user -/usr/sbin/userdel -f $user -rm -rf $HOMEDIR/$user -rm -f /var/spool/mail/$user -rm -f /var/spool/cron/$user -rm -rf $USER_DATA - -# Updating admin counter -if [ "$user" != 'admin' ]; then - decrease_user_value 'admin' '$U_USERS' -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_history "deleted system user $user" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user +# options: USER +# +# This function deletes a certain user and all his resourses such as domains, +# databases, cron jobs, etc. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking web system is enabled +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-web-domains $user $restart + $BIN/v-delete-web-domains $user $restart + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking dns system is enabled +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-dns-domains $user $restart + $BIN/v-delete-dns-domains $user $restart + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking mail system is enabled +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-mail-domains $user + $BIN/v-delete-mail-domains $user + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking db system is enabled +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-databases $user + $BIN/v-delete-databases $user + rv="$?" + if [ "$rv" -ne '0' ]; then + exit $rv + fi +fi + +# Checking ip +$BIN/v-delete-user-ips "$user" +rv="$?" +if [ "$rv" -ne '0' ]; then + exit $rv +fi + +# Deleteing user pipes +sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe +sed -i "/ $user$/d" $VESTA/data/queue/traffic.pipe + +# Removing system user +/usr/sbin/userdel -f $user +rm -rf $HOMEDIR/$user +rm -f /var/spool/mail/$user +rm -f /var/spool/cron/$user +rm -rf $USER_DATA + +# Updating admin counter +if [ "$user" != 'admin' ]; then + decrease_user_value 'admin' '$U_USERS' +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_history "deleted system user $user" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user-backup b/bin/v-delete-user-backup index 89aad3b3..863b39b5 100755 --- a/bin/v-delete-user-backup +++ b/bin/v-delete-user-backup @@ -1,53 +1,53 @@ -#!/bin/bash -# info: delete user backup -# options: USER NACKUP -# -# The function deletes user backup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -backup=$(echo $2| cut -f 2 -d \.) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER BACKUP' -validate_format 'user' 'backup' -is_system_enabled "$BACKUP_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'backup' 'BACKUP' "$2" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting backup -rm -f $BACKUP/$2 -sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update counter -U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) -update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" - -# Logging -log_history "deleted backup archive $backup" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user backup +# options: USER NACKUP +# +# The function deletes user backup. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +backup=$(echo $2| cut -f 2 -d \.) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER BACKUP' +validate_format 'user' 'backup' +is_system_enabled "$BACKUP_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'backup' 'BACKUP' "$2" + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting backup +rm -f $BACKUP/$2 +sed -i "/BACKUP='$2' /d" $USER_DATA/backup.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update counter +U_BACKUPS=$(ls $BACKUP/|grep "^$user."|wc -l) +update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" + +# Logging +log_history "deleted backup archive $backup" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user-ips b/bin/v-delete-user-ips index 42def91a..bf7b0640 100755 --- a/bin/v-delete-user-ips +++ b/bin/v-delete-user-ips @@ -1,63 +1,63 @@ -#!/bin/bash -# info: delete user ips -# options: USER -# -# The function deletes all user's ip addresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing user ips -ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) - -for ip in $ip_list; do - ip=$(basename $ip) - - # Checking webdomains and users - is_ip_key_empty '$U_WEB_DOMAINS' - is_ip_key_empty '$U_SYS_USERS' - - # Assig ip to main account - update_ip_value '$OWNER' 'admin' - update_ip_value '$STATUS' 'dedicated' - increase_user_value 'admin' '$IP_OWNED' - increase_user_value 'admin' '$IP_AVAIL' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user ips +# options: USER +# +# The function deletes all user's ip addresses. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing user ips +ip_list=$(grep -H "OWNER='$user'" $VESTA/data/ips/* | cut -f 1 -d:) + +for ip in $ip_list; do + ip=$(basename $ip) + + # Checking webdomains and users + is_ip_key_empty '$U_WEB_DOMAINS' + is_ip_key_empty '$U_SYS_USERS' + + # Assig ip to main account + update_ip_value '$OWNER' 'admin' + update_ip_value '$STATUS' 'dedicated' + increase_user_value 'admin' '$IP_OWNED' + increase_user_value 'admin' '$IP_AVAIL' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-user-package b/bin/v-delete-user-package index d6157eed..d9862acd 100755 --- a/bin/v-delete-user-package +++ b/bin/v-delete-user-package @@ -1,55 +1,55 @@ -#!/bin/bash -# info: delete user package -# options: PACKAGE -# -# The function for deleting user package. It does not allow to delete pacakge -# if it is in use. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -package=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Functions -is_package_in_use() { - check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf) - if [ ! -z "$check_package" ]; then - echo "Error: package $package is in use" - log_event "$E_INUSE" "$EVENT" - exit $E_INUSE - fi -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'PACKAGE' -validate_format 'package' -is_package_valid -is_package_in_use - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting user package -rm -f $VESTA/data/packages/$package.pkg - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -log_history "deleted user package $package" '' 'admin' -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete user package +# options: PACKAGE +# +# The function for deleting user package. It does not allow to delete pacakge +# if it is in use. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +package=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Functions +is_package_in_use() { + check_package=$(grep "PACKAGE='$package'" $USER_DATA/*/user.conf) + if [ ! -z "$check_package" ]; then + echo "Error: package $package is in use" + log_event "$E_INUSE" "$EVENT" + exit $E_INUSE + fi +} + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'PACKAGE' +validate_format 'package' +is_package_valid +is_package_in_use + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting user package +rm -f $VESTA/data/packages/$package.pkg + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +log_history "deleted user package $package" '' 'admin' +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain b/bin/v-delete-web-domain index 6c54a7cd..eed4d1dc 100755 --- a/bin/v-delete-web-domain +++ b/bin/v-delete-web-domain @@ -1,165 +1,165 @@ -#!/bin/bash -# info: delete web domain -# options: USER DOMAIN -# -# The call of function leads to the removal of domain and all its components -# (statistics, folders contents, ssl certificates, etc.). This operation is -# not fully supported by "undo" function, so the data recovery is possible -# only with a help of reserve copy. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get template name -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" - -# Deleting domain -del_web_config - -# Checking aliases -if [ ! -z "$ALIAS" ]; then - aliases=$(echo $ALIAS | tr ',' '\n' | wc -l ) -else - aliases=0 -fi - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - - # Deleting certificates - rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* - rm -f $USER_DATA/ssl/$domain.* -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - fi -fi - -# Checking stats -if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then - sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe - rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - rm -f /etc/awstats/$STATS.$domain.conf -fi - -# Deleting ftp account -if [ ! -z "$FTP_USER" ]; then - /usr/sbin/userdel $FTP_USER -fi - -# Deleting directory -rm -rf $HOMEDIR/$user/web/$domain - -# Deleting logs -rm -f /var/log/httpd/domains/$domain.log* -rm -f /var/log/httpd/domains/$domain.bytes -rm -f /var/log/httpd/domains/$domain.error* - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting domain -sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf - -# Checking last ssl domain -ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) -if [ "$ssl_dom" -eq '0' ]; then - sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf -fi - -# Checking last domain -domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') -if [ "$domains" -eq '0' ]; then - conf='/etc/httpd/conf.d/vesta.conf' - line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) - if [ ! -z "$line" ]; then - sed -i "$line d" $conf - fi -fi - -# Checking last nginx domain -conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) -last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") -if [ -z "$last_snginx" ]; then - sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) - if [ ! -z "$sline" ]; then - sed -i "$sline d" $conf - fi - rm -f $HOMEDIR/$user/conf/web/snginx.conf -fi - -if [ -z "$last_nginx" ]; then - line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) - if [ ! -z "$line" ]; then - sed -i "$line d" $conf - fi - rm -f $HOMEDIR/$user/conf/web/nginx.conf -fi - -# Decrease counters -decrease_ip_value "$IP" -decrease_user_value "$user" '$U_WEB_DOMAINS' -decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases" -if [ "$SSL" = 'yes' ]; then - decrease_user_value "$user" '$U_WEB_SSL' -fi - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "deleted web domain $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain +# options: USER DOMAIN +# +# The call of function leads to the removal of domain and all its components +# (statistics, folders contents, ssl certificates, etc.). This operation is +# not fully supported by "undo" function, so the data recovery is possible +# only with a help of reserve copy. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get template name +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" + +# Deleting domain +del_web_config + +# Checking aliases +if [ ! -z "$ALIAS" ]; then + aliases=$(echo $ALIAS | tr ',' '\n' | wc -l ) +else + aliases=0 +fi + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + + # Deleting certificates + rm -f $HOMEDIR/$user/conf/web/ssl.$domain.* + rm -f $USER_DATA/ssl/$domain.* +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + fi +fi + +# Checking stats +if [ ! -z "$STATS" ] && [ "$STATS" != 'no' ]; then + sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe + rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf + rm -f /etc/awstats/$STATS.$domain.conf +fi + +# Deleting ftp account +if [ ! -z "$FTP_USER" ]; then + /usr/sbin/userdel $FTP_USER +fi + +# Deleting directory +rm -rf $HOMEDIR/$user/web/$domain + +# Deleting logs +rm -f /var/log/httpd/domains/$domain.log* +rm -f /var/log/httpd/domains/$domain.bytes +rm -f /var/log/httpd/domains/$domain.error* + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting domain +sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf + +# Checking last ssl domain +ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l) +if [ "$ssl_dom" -eq '0' ]; then + sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf +fi + +# Checking last domain +domains=$(wc -l $USER_DATA/web.conf|cut -f 1 -d ' ') +if [ "$domains" -eq '0' ]; then + conf='/etc/httpd/conf.d/vesta.conf' + line=$(grep -n "$HOMEDIR/$user/conf/web/httpd.conf" $conf | cut -f 1 -d : ) + if [ ! -z "$line" ]; then + sed -i "$line d" $conf + fi +fi + +# Checking last nginx domain +conf='/etc/nginx/conf.d/vesta_users.conf' +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) +last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") +if [ -z "$last_snginx" ]; then + sline=$(grep -n "$HOMEDIR/$user/conf/web/snginx.conf" $conf |cut -f 1 -d :) + if [ ! -z "$sline" ]; then + sed -i "$sline d" $conf + fi + rm -f $HOMEDIR/$user/conf/web/snginx.conf +fi + +if [ -z "$last_nginx" ]; then + line=$(grep -n "$HOMEDIR/$user/conf/web/nginx.conf" $conf | cut -f 1 -d : ) + if [ ! -z "$line" ]; then + sed -i "$line d" $conf + fi + rm -f $HOMEDIR/$user/conf/web/nginx.conf +fi + +# Decrease counters +decrease_ip_value "$IP" +decrease_user_value "$user" '$U_WEB_DOMAINS' +decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases" +if [ "$SSL" = 'yes' ]; then + decrease_user_value "$user" '$U_WEB_SSL' +fi + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "deleted web domain $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-alias b/bin/v-delete-web-domain-alias index 5a901d96..55b94ef1 100755 --- a/bin/v-delete-web-domain-alias +++ b/bin/v-delete-web-domain-alias @@ -1,108 +1,108 @@ -#!/bin/bash -# info: delete web domain alias -# options: USER DOMAIN ALIAS [RESTART] -# -# The function of deleting the alias domain (parked domain). By this call -# default www aliase can be removed as well. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain" ) -dom_alias=$(idn -t --quiet -u "$3" ) -dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' -validate_format 'user' 'domain' 'dom_alias' -is_system_enabled 'WEB_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -get_domain_values 'web' -if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then - echo "Error: alias $dom_alias not exist" - log_event "$E_NOTEXIST" "$EVENT" - exit $E_NOTEXIST -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining new alias string -ALIAS=$(echo "$ALIAS" |\ - sed -e "s/,/\n/g"|\ - sed -e "s/^$dom_alias$//g"|\ - sed -e "/^$/d"|\ - sed -e ':a;N;$!ba;s/\n/,/g') -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" - -# Update counters -decrease_user_value "$user" '$U_WEB_ALIASES' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "deleted alias $dom_alias on $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain alias +# options: USER DOMAIN ALIAS [RESTART] +# +# The function of deleting the alias domain (parked domain). By this call +# default www aliase can be removed as well. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain" ) +dom_alias=$(idn -t --quiet -u "$3" ) +dom_alias_idn=$(idn -t --quiet -a "$dom_alias" ) +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]' +validate_format 'user' 'domain' 'dom_alias' +is_system_enabled 'WEB_SYSTEM' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +get_domain_values 'web' +if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then + echo "Error: alias $dom_alias not exist" + log_event "$E_NOTEXIST" "$EVENT" + exit $E_NOTEXIST +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining new alias string +ALIAS=$(echo "$ALIAS" |\ + sed -e "s/,/\n/g"|\ + sed -e "s/^$dom_alias$//g"|\ + sed -e "/^$/d"|\ + sed -e ':a;N;$!ba;s/\n/,/g') +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS" + +# Update counters +decrease_user_value "$user" '$U_WEB_ALIASES' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "deleted alias $dom_alias on $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-cgi b/bin/v-delete-web-domain-cgi index dea6e773..847fb2a8 100755 --- a/bin/v-delete-web-domain-cgi +++ b/bin/v-delete-web-domain-cgi @@ -1,79 +1,79 @@ -#!/bin/bash -# info: delete web domain cgi support -# options: USER DOMAIN -# -# The function for deleting cgi support (adds -ExecCGI directive into -# configuration file). It is recommended to apply this function only for a -# temporary use (for lightening the consequences of DDoS, for example); -# otherwise it is preferable to use templates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -CGI='no' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no' - -# Restart web server -$BIN/v-restart-web "$EVENT" - -# Logging -log_history "disabled cgi support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain cgi support +# options: USER DOMAIN +# +# The function for deleting cgi support (adds -ExecCGI directive into +# configuration file). It is recommended to apply this function only for a +# temporary use (for lightening the consequences of DDoS, for example); +# otherwise it is preferable to use templates. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +CGI='no' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no' + +# Restart web server +$BIN/v-restart-web "$EVENT" + +# Logging +log_history "disabled cgi support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-elog b/bin/v-delete-web-domain-elog index 9ca171c3..9eeda488 100755 --- a/bin/v-delete-web-domain-elog +++ b/bin/v-delete-web-domain-elog @@ -1,97 +1,97 @@ -#!/bin/bash -# info: delete web domain error loggin support -# options: USER DOMAIN [RESTART] -# -# The function of disabling error logging feature. It comments ErrorLog -# direcitve in apache or/and nginx configuration. The data already collected -# remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -ELOG='no' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "disabled error logging for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain error loggin support +# options: USER DOMAIN [RESTART] +# +# The function of disabling error logging feature. It comments ErrorLog +# direcitve in apache or/and nginx configuration. The data already collected +# remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +ELOG='no' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "disabled error logging for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-ftp b/bin/v-delete-web-domain-ftp index 78183f10..ca71d31d 100755 --- a/bin/v-delete-web-domain-ftp +++ b/bin/v-delete-web-domain-ftp @@ -1,58 +1,58 @@ -#!/bin/bash -# info: delete webdomain ftp account. -# options: USER DOMAIN -# -# The function deletes additional ftp account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$FTP_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding user -get_domain_values 'web' -/usr/sbin/userdel $FTP_USER - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' '' -update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' '' - -# Logging -log_history "deleted ftp account $FTP_USER for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete webdomain ftp account. +# options: USER DOMAIN +# +# The function deletes additional ftp account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$FTP_USER' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding user +get_domain_values 'web' +/usr/sbin/userdel $FTP_USER + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_USER' '' +update_object_value 'web' 'DOMAIN' "$domain" '$FTP_MD5' '' + +# Logging +log_history "deleted ftp account $FTP_USER for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-nginx b/bin/v-delete-web-domain-nginx index 23c8c0f5..4c4c4b03 100755 --- a/bin/v-delete-web-domain-nginx +++ b/bin/v-delete-web-domain-nginx @@ -1,87 +1,87 @@ -#!/bin/bash -# info: deleting web domain nginx configuration -# options: USER DOMAIN -# -# The function of deleting the virtualhost nginx configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining domain parameters -get_domain_values 'web' -tpl_file="$WEBTPL/nginx_$NGINX.tpl" -conf="$HOMEDIR/$user/conf/web/nginx.conf" -del_web_config - -# Checking ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' '' -update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' '' - -# Checking last nginx domain -conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) -last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") -if [ -z "$last_snginx" ]; then - sed -i "/$user\/conf\/web\/snginx.conf/d" $conf - rm -f $HOMEDIR/$user/conf/web/snginx.conf -fi - -if [ -z "$last_nginx" ]; then - sed -i "/$user\/conf\/web\/nginx.conf/d" $conf - rm -f $HOMEDIR/$user/conf/web/nginx.conf -fi - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "disabled nginx support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: deleting web domain nginx configuration +# options: USER DOMAIN +# +# The function of deleting the virtualhost nginx configuration. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining domain parameters +get_domain_values 'web' +tpl_file="$WEBTPL/nginx_$NGINX.tpl" +conf="$HOMEDIR/$user/conf/web/nginx.conf" +del_web_config + +# Checking ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' '' +update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' '' + +# Checking last nginx domain +conf='/etc/nginx/conf.d/vesta_users.conf' +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) +last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") +if [ -z "$last_snginx" ]; then + sed -i "/$user\/conf\/web\/snginx.conf/d" $conf + rm -f $HOMEDIR/$user/conf/web/snginx.conf +fi + +if [ -z "$last_nginx" ]; then + sed -i "/$user\/conf\/web\/nginx.conf/d" $conf + rm -f $HOMEDIR/$user/conf/web/nginx.conf +fi + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "disabled nginx support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-ssl b/bin/v-delete-web-domain-ssl index 99252e42..36743408 100755 --- a/bin/v-delete-web-domain-ssl +++ b/bin/v-delete-web-domain-ssl @@ -1,101 +1,101 @@ -#!/bin/bash -# info: delete web domain ssl support -# options: USER DOMAIN -# -# The function disable https support and deletes SSL certificates. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -conf="$HOMEDIR/$user/conf/web/shttpd.conf" -tpl_file="$WEBTPL/apache_$TPL.stpl" - -# Deleting domain -del_web_config - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config -fi - -# Deleting old certificate -tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) -rm -f $HOMEDIR/$user/conf/ssl.$domain.* -mv $USER_DATA/ssl/$domain.* $tmpdir -chown -R $user:$user $tmpdir - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no' - -# Checking last ssl domain -ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) -main_conf='/etc/httpd/conf.d/vesta.conf' -conf="$HOMEDIR/$user/conf/web/shttpd.conf" -if [ -z "$ssl_dom" ]; then - sed -i "/Include ${conf////\/}/d" $main_conf - rm -f $conf -fi - -# Checking last nginx domain -conf='/etc/nginx/conf.d/vesta_users.conf' -last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) -last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") -if [ -z "$last_snginx" ]; then - sed -i "/$user\/conf\/web\/snginx.conf/d" $conf - rm -f $HOMEDIR/$user/conf/web/snginx.conf -fi - -# Decreasing domain value -decrease_user_value "$user" '$U_WEB_SSL' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_history "disabled ssl support for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain ssl support +# options: USER DOMAIN +# +# The function disable https support and deletes SSL certificates. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +tpl_file="$WEBTPL/apache_$TPL.stpl" + +# Deleting domain +del_web_config + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config +fi + +# Deleting old certificate +tmpdir=$(mktemp -p $HOMEDIR/$user/web/$domain/private -d) +rm -f $HOMEDIR/$user/conf/ssl.$domain.* +mv $USER_DATA/ssl/$domain.* $tmpdir +chown -R $user:$user $tmpdir + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no' + +# Checking last ssl domain +ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf) +main_conf='/etc/httpd/conf.d/vesta.conf' +conf="$HOMEDIR/$user/conf/web/shttpd.conf" +if [ -z "$ssl_dom" ]; then + sed -i "/Include ${conf////\/}/d" $main_conf + rm -f $conf +fi + +# Checking last nginx domain +conf='/etc/nginx/conf.d/vesta_users.conf' +last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf) +last_snginx=$(echo "$last_nginx" | grep "SSL='yes'") +if [ -z "$last_snginx" ]; then + sed -i "/$user\/conf\/web\/snginx.conf/d" $conf + rm -f $HOMEDIR/$user/conf/web/snginx.conf +fi + +# Decreasing domain value +decrease_user_value "$user" '$U_WEB_SSL' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_history "disabled ssl support for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-stats b/bin/v-delete-web-domain-stats index 8974752b..a6913099 100755 --- a/bin/v-delete-web-domain-stats +++ b/bin/v-delete-web-domain-stats @@ -1,69 +1,69 @@ -#!/bin/bash -# info: delete web domain statistics -# options: USER DOMAIN -# -# The function of deleting site's system of statistics. Its type is -# automatically chooses from client's configuration file. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining statistic type -get_domain_values 'web' - -# Defining statistic dir -stats_dir="$HOMEDIR/$user/web/$domain/stats" - -# Deleting dir content -rm -rf $stats_dir/* - -# Deleting config -rm -f /etc/awstats/$STATS.$domain.conf -rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Deleting pipe command -sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS' '' - -# Logging -log_history "disabled web log analyzer for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domain statistics +# options: USER DOMAIN +# +# The function of deleting site's system of statistics. Its type is +# automatically chooses from client's configuration file. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining statistic type +get_domain_values 'web' + +# Defining statistic dir +stats_dir="$HOMEDIR/$user/web/$domain/stats" + +# Deleting dir content +rm -rf $stats_dir/* + +# Deleting config +rm -f /etc/awstats/$STATS.$domain.conf +rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Deleting pipe command +sed -i "/ $domain$/d" $VESTA/data/queue/webstats.pipe + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS' '' + +# Logging +log_history "disabled web log analyzer for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domain-stats-user b/bin/v-delete-web-domain-stats-user index 84e043b0..dc63a3eb 100755 --- a/bin/v-delete-web-domain-stats-user +++ b/bin/v-delete-web-domain-stats-user @@ -1,61 +1,61 @@ -#!/bin/bash -# info: disable webdomain stats authentication support -# options: USER DOMAIN -# -# The function removes authentication of statistics system. If the script is -# called without naming a certain user, all users will be removed. After -# deleting all of them statistics will be accessible for view without an -# authentication. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Definining statistic dir -rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd -rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' '' -update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' '' - - -# Logging -log_history "disabled web stats password protection for $domain" -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: disable webdomain stats authentication support +# options: USER DOMAIN +# +# The function removes authentication of statistics system. If the script is +# called without naming a certain user, all users will be removed. After +# deleting all of them statistics will be accessible for view without an +# authentication. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" +is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Definining statistic dir +rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd +rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' '' +update_object_value 'web' 'DOMAIN' "$domain" '$STATS_CRYPT' '' + + +# Logging +log_history "disabled web stats password protection for $domain" +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-delete-web-domains b/bin/v-delete-web-domains index fa87e67c..2824433f 100755 --- a/bin/v-delete-web-domains +++ b/bin/v-delete-web-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: delete web domains -# options: USER [RESTART] -# -# The function deteles all user's webdomains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting delete loop -for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-delete-web-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: delete web domains +# options: USER [RESTART] +# +# The function deteles all user's webdomains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting delete loop +for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-delete-web-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-get-dns-domain-value b/bin/v-get-dns-domain-value index 90bdcbfe..b5b88d77 100755 --- a/bin/v-get-dns-domain-value +++ b/bin/v-get-dns-domain-value @@ -1,47 +1,47 @@ -#!/bin/bash -# info: get dns domain value -# options: USER DOMAIN KEY -# -# The function for getting a certain DNS 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 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Print -get_object_value 'dns' 'DOMAIN' "$domain" "$key" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: get dns domain value +# options: USER DOMAIN KEY +# +# The function for getting a certain DNS 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 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Print +get_object_value 'dns' 'DOMAIN' "$domain" "$key" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-get-mail-account-value b/bin/v-get-mail-account-value index d53a71ae..c920e2fa 100755 --- a/bin/v-get-mail-account-value +++ b/bin/v-get-mail-account-value @@ -1,49 +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 +#!/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 diff --git a/bin/v-get-mail-domain-value b/bin/v-get-mail-domain-value index 65ca0492..1fab391f 100755 --- a/bin/v-get-mail-domain-value +++ b/bin/v-get-mail-domain-value @@ -1,47 +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 +#!/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 diff --git a/bin/v-get-user-value b/bin/v-get-user-value index d7a4c8ae..f5eeb99d 100755 --- a/bin/v-get-user-value +++ b/bin/v-get-user-value @@ -1,45 +1,45 @@ -#!/bin/bash -# info: get user value -# options: USER KEY -# -# The function for obtaining certain user's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER KEY' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking key -value=$(get_user_value "$key") - -# Printing value -echo "$value" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: get user value +# options: USER KEY +# +# The function for obtaining certain user's parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +key=$(echo "$2"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER KEY' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking key +value=$(get_user_value "$key") + +# Printing value +echo "$value" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-get-web-domain-value b/bin/v-get-web-domain-value index b05b6237..f1529da6 100755 --- a/bin/v-get-web-domain-value +++ b/bin/v-get-web-domain-value @@ -1,49 +1,49 @@ -#!/bin/bash -# info: get web domain value -# options: USER DOMAIN KEY -# -# 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 -# raw form; output formats aren't supported. - - -#----------------------------------------------------------# -# 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/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN KEY' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' -eval echo $key - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: get web domain value +# options: USER DOMAIN KEY +# +# 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 +# raw form; output formats aren't supported. + + +#----------------------------------------------------------# +# 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/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN KEY' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +get_domain_values 'web' +eval echo $key + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-cron-job b/bin/v-list-cron-job index 95068ab2..166525ea 100755 --- a/bin/v-list-cron-job +++ b/bin/v-list-cron-job @@ -1,91 +1,91 @@ -#!/bin/bash -# info: list cron job -# options: USER JOB [FORMAT] -# -# The function of obtaining cron job settings. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_job() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "JOB='$job'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_job() { - line=$(grep "JOB='$job'" $conf) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key=NULL - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB [FORMAT]' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields to select -conf=$USER_DATA/cron.conf -fields="\$JOB \$MIN \$HOUR \$DAY \$MONTH \$WDAY \$CMD \$SUSPENDED" -fields="$fields \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list_job ;; - plain) nohead=1; shell_list_job ;; - shell) shell_list_job |column -t ;; - *) check_args '2' '0' 'USER JOB [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list cron job +# options: USER JOB [FORMAT] +# +# The function of obtaining cron job settings. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_job() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "JOB='$job'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_job() { + line=$(grep "JOB='$job'" $conf) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key=NULL + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB [FORMAT]' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields to select +conf=$USER_DATA/cron.conf +fields="\$JOB \$MIN \$HOUR \$DAY \$MONTH \$WDAY \$CMD \$SUSPENDED" +fields="$fields \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_job ;; + plain) nohead=1; shell_list_job ;; + shell) shell_list_job |column -t ;; + *) check_args '2' '0' 'USER JOB [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-cron-jobs b/bin/v-list-cron-jobs index 1d2c3ce7..1fc327fd 100755 --- a/bin/v-list-cron-jobs +++ b/bin/v-list-cron-jobs @@ -1,106 +1,106 @@ -#!/bin/bash -# info: list user cron jobs -# options: USER [FORMAT] -# -# The function for obtaining the list of all users cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json list function -json_list_cron() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_cron() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/cron.conf - -# Defining fileds to select -fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $JOB $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_cron ;; - plain) nohead=1; - fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\"" - fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" "; - fields="$fields \"\$TIME\" \"\$DATE\"" - shell_list_cron ;; - shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD'; - shell_list_cron |column -t -s '~';; - *) check_args '1' '0' 'USER [FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user cron jobs +# options: USER [FORMAT] +# +# The function for obtaining the list of all users cron jobs. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json list function +json_list_cron() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell list function +shell_list_cron() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/cron.conf + +# Defining fileds to select +fields='$JOB $MIN $HOUR $DAY $MONTH $WDAY $CMD $JOB $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_cron ;; + plain) nohead=1; + fields="\"\$JOB\" \"\$SUSPENDED\" \"\$MIN\" \"\$HOUR\" \"\$DAY\"" + fields="$fields \"\$MONTH\" \"\$WDAY\" \"\$CMD\" "; + fields="$fields \"\$TIME\" \"\$DATE\"" + shell_list_cron ;; + shell) fields='$JOB~$SUSPENDED~$MIN~$HOUR~$DAY~$MONTH~$WDAY~$CMD'; + shell_list_cron |column -t -s '~';; + *) check_args '1' '0' 'USER [FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database b/bin/v-list-database index 8a3e4807..d9136aee 100755 --- a/bin/v-list-database +++ b/bin/v-list-database @@ -1,89 +1,89 @@ -#!/bin/bash -# info: list database -# options: USER DATABASE [FORMAT] -# -# The function for obtaining of all database's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_db() { - i=1 - last_word=$(echo "$fields" | wc -w) - line=$(grep "DB='$database'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$last_word" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e "\t}" - fi - echo -e '}' -} - -# Shell list for single database -shell_list_db() { - line=$(grep "DB='$database'" $conf) - eval $line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE [FORMAT]' -validate_format 'user' 'database' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -# Defining fileds to select -conf=$USER_DATA/db.conf -fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' - -# Listing database -case $format in - json) json_list_db ;; - plain) shell_list_db ;; - shell) shell_list_db | column -t ;; - *) check_args '2' '0' 'USER DATABASE [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list database +# options: USER DATABASE [FORMAT] +# +# The function for obtaining of all database's parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_db() { + i=1 + last_word=$(echo "$fields" | wc -w) + line=$(grep "DB='$database'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$last_word" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e "\t}" + fi + echo -e '}' +} + +# Shell list for single database +shell_list_db() { + line=$(grep "DB='$database'" $conf) + eval $line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE [FORMAT]' +validate_format 'user' 'database' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + + +# Defining fileds to select +conf=$USER_DATA/db.conf +fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' + +# Listing database +case $format in + json) json_list_db ;; + plain) shell_list_db ;; + shell) shell_list_db | column -t ;; + *) check_args '2' '0' 'USER DATABASE [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database-server b/bin/v-list-database-server index 36693310..f459c7d0 100755 --- a/bin/v-list-database-server +++ b/bin/v-list-database-server @@ -1,88 +1,88 @@ -#!/bin/bash -# info: list database server -# options: TYPE HOST [FORMAT] -# -# The function for obtaining database server parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_dbhost() { - i=1 - fields_count=$(echo "$fields" | wc -w) - line=$(grep "HOST='$host'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fields_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e "\t}" - fi - echo -e "}" -} - -# Shell function -shell_list_dbhost() { - line=$(grep "HOST='$host'" $conf) - eval $line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST [FORMAT]' -validate_format 'host' -is_object_valid "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$VESTA/conf/$type.conf -fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' -fields="$fields \$TIME \$DATE" - -# Listing database -case $format in - json) json_list_dbhost ;; - plain) nohead=1; shell_list_dbhost ;; - shell) shell_list_dbhost | column -t;; - *) check_args '2' '0' 'TYPE HOST [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list database server +# options: TYPE HOST [FORMAT] +# +# The function for obtaining database server parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_dbhost() { + i=1 + fields_count=$(echo "$fields" | wc -w) + line=$(grep "HOST='$host'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fields_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e "\t}" + fi + echo -e "}" +} + +# Shell function +shell_list_dbhost() { + line=$(grep "HOST='$host'" $conf) + eval $line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key" + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST [FORMAT]' +validate_format 'host' +is_object_valid "../../conf/$type" 'HOST' "$host" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$VESTA/conf/$type.conf +fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' +fields="$fields \$TIME \$DATE" + +# Listing database +case $format in + json) json_list_dbhost ;; + plain) nohead=1; shell_list_dbhost ;; + shell) shell_list_dbhost | column -t;; + *) check_args '2' '0' 'TYPE HOST [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database-servers b/bin/v-list-database-servers index a83a43a2..3a436f76 100755 --- a/bin/v-list-database-servers +++ b/bin/v-list-database-servers @@ -1,51 +1,51 @@ -#!/bin/bash -# info: list database servers -# options: TYPE [FORMAT] -# -# The function for obtaining the list of all hosts of the same databases' type. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'TYPE [FORMAT]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$VESTA/conf/$type.conf -fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' -fields="$fields \$TIME \$DATE" - -# Listing database -case $format in - json) json_list ;; - plain) nohead=1; shell_list;; - shell) fields='$HOST $PORT $MAX_DB $U_DB_BASES $SUSPENDED $DATE'; - shell_list | column -t ;; - *) check_args '2' '0' 'TYPE [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list database servers +# options: TYPE [FORMAT] +# +# The function for obtaining the list of all hosts of the same databases' type. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '1' "$#" 'TYPE [FORMAT]' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$VESTA/conf/$type.conf +fields='$HOST $PORT $CHARSETS $MAX_DB $U_SYS_USERS $U_DB_BASES $TPL $SUSPENDED' +fields="$fields \$TIME \$DATE" + +# Listing database +case $format in + json) json_list ;; + plain) nohead=1; shell_list;; + shell) fields='$HOST $PORT $MAX_DB $U_DB_BASES $SUSPENDED $DATE'; + shell_list | column -t ;; + *) check_args '2' '0' 'TYPE [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-database-types b/bin/v-list-database-types index 757644a4..8a08a25b 100755 --- a/bin/v-list-database-types +++ b/bin/v-list-database-types @@ -1,66 +1,66 @@ -#!/bin/bash -# info: list supported database types -# options: [FORMAT] -# -# The function for obtaining the list of database types. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Json function -json_list_dbtypes() { - types=$(echo "${DB_SYSTEM//,/ }") - t_counter=$(echo "$types" | wc -w) - i=1 - echo '[' - for type in $types; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$type\"," - else - echo -e "\t\"$type\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_dbtypes() { - types=$(echo "${DB_SYSTEM//,/ }") - if [ -z "$nohead" ]; then - echo "TYPES" - echo "----------" - fi - for type in $types; do - echo "$type" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_dbtypes ;; - plain) nohead=1; shell_list_dbtypes ;; - shell) shell_list_dbtypes ;; - *) check_args '1' '0' '[FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list supported database types +# options: [FORMAT] +# +# The function for obtaining the list of database types. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/conf/vesta.conf + +# Json function +json_list_dbtypes() { + types=$(echo "${DB_SYSTEM//,/ }") + t_counter=$(echo "$types" | wc -w) + i=1 + echo '[' + for type in $types; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$type\"," + else + echo -e "\t\"$type\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_dbtypes() { + types=$(echo "${DB_SYSTEM//,/ }") + if [ -z "$nohead" ]; then + echo "TYPES" + echo "----------" + fi + for type in $types; do + echo "$type" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_dbtypes ;; + plain) nohead=1; shell_list_dbtypes ;; + shell) shell_list_dbtypes ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-databases b/bin/v-list-databases index c5d4b6db..282fb52c 100755 --- a/bin/v-list-databases +++ b/bin/v-list-databases @@ -1,51 +1,51 @@ -#!/bin/bash -# info: listing databases -# options: USER [FORMAT] -# -# The function for obtaining the list of all user's databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/db.conf -fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' - -# Listing databases -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DB $DBUSER $HOST $TYPE $U_DISK $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: listing databases +# options: USER [FORMAT] +# +# The function for obtaining the list of all user's databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/db.conf +fields='$DB $DBUSER $HOST $TYPE $CHARSET $U_DISK $SUSPENDED $TIME $DATE' + +# Listing databases +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DB $DBUSER $HOST $TYPE $U_DISK $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-domain b/bin/v-list-dns-domain index b46a0cd4..8f24a37c 100755 --- a/bin/v-list-dns-domain +++ b/bin/v-list-dns-domain @@ -1,105 +1,105 @@ -#!/bin/bash -# info: list dns domain -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of domain parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_domain() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "DOMAIN='$domain'" $conf) - - # Print top bracket - echo '{' - - # Assing key=value - eval $line - - # Starting output loop - for field in $fields; do - # Parsing key=value - eval value=$field - - # Checking first field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - # Updating iterator - (( ++i)) - done - - # If there was any output - if [ -n "$value" ]; then - echo -e ' }' - fi - # Printing bottom json bracket - echo -e "}" -} - -# Shell function -shell_list_domain() { - line=$(grep "DOMAIN='$domain'" $conf) - - # Parsing key=value - eval $line - - # Print result line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields to select -conf=$USER_DATA/dns.conf -fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_domain ;; - plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t ;; - *) check_args '2' '0' 'USER DOMAIN [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns domain +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of domain parameters. This call, just as +# all v_list_* calls, supports 3 formats - json, shell and plain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_domain() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "DOMAIN='$domain'" $conf) + + # Print top bracket + echo '{' + + # Assing key=value + eval $line + + # Starting output loop + for field in $fields; do + # Parsing key=value + eval value=$field + + # Checking first field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + # Updating iterator + (( ++i)) + done + + # If there was any output + if [ -n "$value" ]; then + echo -e ' }' + fi + # Printing bottom json bracket + echo -e "}" +} + +# Shell function +shell_list_domain() { + line=$(grep "DOMAIN='$domain'" $conf) + + # Parsing key=value + eval $line + + # Print result line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields to select +conf=$USER_DATA/dns.conf +fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_domain ;; + plain) nohead=1; shell_list_domain ;; + shell) shell_list_domain |column -t ;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-domain-records b/bin/v-list-dns-domain-records index 58c53bf9..56ed5fb9 100755 --- a/bin/v-list-dns-domain-records +++ b/bin/v-list-dns-domain-records @@ -1,105 +1,105 @@ -#!/bin/bash -# info: list dns domain records -# options: USER DOMAIN [FORMAT] -# -# The function for getting all DNS domain records. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json func -json_list_dns() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - IFS=$'\n' - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_dns() { - - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - IFS=$'\n' - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields -conf=$USER_DATA/dns/$domain.conf -fields='$ID $RECORD $TYPE $PRIORITY $VALUE $ID $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_dns ;; - plain) nohead=1; shell_list_dns ;; - shell) fields='$ID $RECORD $TYPE $VALUE'; - shell_list_dns | column -t ;; - *) check_args '2' '0' 'USER DOMAIN [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns domain records +# options: USER DOMAIN [FORMAT] +# +# The function for getting all DNS domain records. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json func +json_list_dns() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_dns() { + + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + IFS=$'\n' + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields +conf=$USER_DATA/dns/$domain.conf +fields='$ID $RECORD $TYPE $PRIORITY $VALUE $ID $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_dns ;; + plain) nohead=1; shell_list_dns ;; + shell) fields='$ID $RECORD $TYPE $VALUE'; + shell_list_dns | column -t ;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-domains b/bin/v-list-dns-domains index ebad1232..10ccafa5 100755 --- a/bin/v-list-dns-domains +++ b/bin/v-list-dns-domains @@ -1,51 +1,51 @@ -#!/bin/bash -# info: list dns domains -# options: USER [FORMAT] -# -# The function for obtaining all DNS domains of a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields -conf=$USER_DATA/dns.conf -fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DOMAIN $IP $TPL $TTL $EXP $DATE'; - shell_list| column -t ;; - *) check_args '1' '0' 'USER [FORMAT]';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns domains +# options: USER [FORMAT] +# +# The function for obtaining all DNS domains of a user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields +conf=$USER_DATA/dns.conf +fields='$DOMAIN $IP $TPL $TTL $EXP $SOA $RECORDS $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DOMAIN $IP $TPL $TTL $EXP $DATE'; + shell_list| column -t ;; + *) check_args '1' '0' 'USER [FORMAT]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-template b/bin/v-list-dns-template index 5faa9dc2..5ff2b337 100755 --- a/bin/v-list-dns-template +++ b/bin/v-list-dns-template @@ -1,102 +1,102 @@ -#!/bin/bash -# info: list dns template -# options: TEMPLATE [FORMAT] -# -# The function for obtaining the DNS template parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -template=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - -# Json func -json_list_dns() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - IFS=$'\n' - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_dns() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'TEMPLATE [FORMAT]' -validate_format 'template' -is_dns_template_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields -conf=$DNSTPL/$template.tpl -fields='$RECORD $TYPE $PRIORITY $VALUE' - -# Listing templates -case $format in - json) json_list_dns ;; - plain) nohead=1; shell_list_dns ;; - shell) shell_list_dns | column -t ;; - *) check_args '1' '0' 'TEMPLATE [FORMAT]';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns template +# options: TEMPLATE [FORMAT] +# +# The function for obtaining the DNS template parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +template=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + +# Json func +json_list_dns() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_dns() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'TEMPLATE [FORMAT]' +validate_format 'template' +is_dns_template_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields +conf=$DNSTPL/$template.tpl +fields='$RECORD $TYPE $PRIORITY $VALUE' + +# Listing templates +case $format in + json) json_list_dns ;; + plain) nohead=1; shell_list_dns ;; + shell) shell_list_dns | column -t ;; + *) check_args '1' '0' 'TEMPLATE [FORMAT]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-dns-templates b/bin/v-list-dns-templates index 42409db7..18090b52 100755 --- a/bin/v-list-dns-templates +++ b/bin/v-list-dns-templates @@ -1,65 +1,65 @@ -#!/bin/bash -# info: list dns templates -# options: [FORMAT] -# -# The function for obtaining the list of all DNS templates available. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_dnstpl() { - templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') - t_counter=$(echo "$templates" | wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_dnstpl() { - templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') - if [ -z "$nohead" ]; then - echo "Templates" - echo "----------" - fi - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_dnstpl;; - plain) nohead=1; shell_list_dnstpl ;; - shell) shell_list_dnstpl ;; - *) check_args '1' '0' '[FORMAT] [LIMIT] [OFFSET]';; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list dns templates +# options: [FORMAT] +# +# The function for obtaining the list of all DNS templates available. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_dnstpl() { + templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') + t_counter=$(echo "$templates" | wc -w) + i=1 + echo '[' + for template in $templates; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$template\"," + else + echo -e "\t\"$template\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_dnstpl() { + templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.') + if [ -z "$nohead" ]; then + echo "Templates" + echo "----------" + fi + for template in $templates; do + echo "$template" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_dnstpl;; + plain) nohead=1; shell_list_dnstpl ;; + shell) shell_list_dnstpl ;; + *) check_args '1' '0' '[FORMAT] [LIMIT] [OFFSET]';; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-account b/bin/v-list-mail-account index e3524e45..eb18c6a2 100755 --- a/bin/v-list-mail-account +++ b/bin/v-list-mail-account @@ -1,94 +1,94 @@ -#!/bin/bash -# info: list mail domain account -# options: USER DOMAIN ACCOUNT [FORMAT] -# -# The function of obtaining the list of account parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -account=$3 -format=${4-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_account() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "ACCOUNT='$account'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_account() { - line=$(grep "ACCOUNT='$account'" $conf) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key=NULL - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config and fields to select -conf=$USER_DATA/mail/$domain.conf -fields="\$ACCOUNT \$ALIAS \$FWD \$QUOTA \$AUTOREPLY \$U_DISK \$SUSPENDED" -fields="$fields \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list_account ;; - plain) nohead=1; shell_list_account ;; - shell) shell_list_account |column -t ;; - *) check_args '2' '0' 'USER DOMAIN ACCOUNT [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domain account +# options: USER DOMAIN ACCOUNT [FORMAT] +# +# The function of obtaining the list of account parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +account=$3 +format=${4-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_account() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "ACCOUNT='$account'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_account() { + line=$(grep "ACCOUNT='$account'" $conf) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key=NULL + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config and fields to select +conf=$USER_DATA/mail/$domain.conf +fields="\$ACCOUNT \$ALIAS \$FWD \$QUOTA \$AUTOREPLY \$U_DISK \$SUSPENDED" +fields="$fields \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_account ;; + plain) nohead=1; shell_list_account ;; + shell) shell_list_account |column -t ;; + *) check_args '2' '0' 'USER DOMAIN ACCOUNT [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-account-autoreply b/bin/v-list-mail-account-autoreply index b8351f07..c5ba6020 100755 --- a/bin/v-list-mail-account-autoreply +++ b/bin/v-list-mail-account-autoreply @@ -1,72 +1,72 @@ -#!/bin/bash -# info: list mail account autoreply -# options: USER DOMAIN ACCOUNT [FORMAT] -# -# The function of obtainin mail account autoreply message. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -account=$3 -format=${4-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_msg() { - i='1' # iterator - echo '{' - echo -e "\t\"$account\": {" - echo " \"MSG\": \"$msg\"" - echo -e "\t}\n}" -} - -# Shell function -shell_list_msg() { - if [ ! -z "$msg" ]; then - echo -e "$msg" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then - msg=$(cat $USER_DATA/mail/$account@$domain.msg |\ - sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -# Listing domains -case $format in - json) json_list_msg ;; - plain) nohead=1; shell_list_msg ;; - shell) shell_list_msg ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail account autoreply +# options: USER DOMAIN ACCOUNT [FORMAT] +# +# The function of obtainin mail account autoreply message. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +account=$3 +format=${4-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_msg() { + i='1' # iterator + echo '{' + echo -e "\t\"$account\": {" + echo " \"MSG\": \"$msg\"" + echo -e "\t}\n}" +} + +# Shell function +shell_list_msg() { + if [ ! -z "$msg" ]; then + echo -e "$msg" + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -e "$USER_DATA/mail/$account@$domain.msg" ]; then + msg=$(cat $USER_DATA/mail/$account@$domain.msg |\ + sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +# Listing domains +case $format in + json) json_list_msg ;; + plain) nohead=1; shell_list_msg ;; + shell) shell_list_msg ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-accounts b/bin/v-list-mail-accounts index 2dc97dac..15a07187 100755 --- a/bin/v-list-mail-accounts +++ b/bin/v-list-mail-accounts @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list mail domain accounts -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -validate_format 'user' 'domain' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/mail/$domain.conf -fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$QUOTA \$U_DISK \$SUSPENDED" -fields="$fields \$TIME \$DATE" - -# Listing domain accounts -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$ACCOUNT $AUTOREPLY $QUOTA $U_DISK $SUSPENDED $TIME $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domain accounts +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +validate_format 'user' 'domain' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/mail/$domain.conf +fields="\$ACCOUNT \$ALIAS \$FWD \$AUTOREPLY \$QUOTA \$U_DISK \$SUSPENDED" +fields="$fields \$TIME \$DATE" + +# Listing domain accounts +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$ACCOUNT $AUTOREPLY $QUOTA $U_DISK $SUSPENDED $TIME $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-domain b/bin/v-list-mail-domain index 289ed713..fae89527 100755 --- a/bin/v-list-mail-domain +++ b/bin/v-list-mail-domain @@ -1,90 +1,90 @@ -#!/bin/bash -# info: list web domain -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of domain parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_domain() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "DOMAIN='$domain'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_domain() { - line=$(grep "DOMAIN='$domain'" $conf) - eval $line - for field in $fields; do - eval key="$field" - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/mail.conf -fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL -$SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_domain ;; - plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t ;; - *) check_args '2' '0' 'USER DOMAIN [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domain +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of domain parameters. This call, just as +# all v_list_* calls, supports 3 formats - json, shell and plain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_domain() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "DOMAIN='$domain'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_domain() { + line=$(grep "DOMAIN='$domain'" $conf) + eval $line + for field in $fields; do + eval key="$field" + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/mail.conf +fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $CATCHALL +$SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_domain ;; + plain) nohead=1; shell_list_domain ;; + shell) shell_list_domain |column -t ;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-domain-dkim b/bin/v-list-mail-domain-dkim index f3b70f7f..37b8917e 100755 --- a/bin/v-list-mail-domain-dkim +++ b/bin/v-list-mail-domain-dkim @@ -1,73 +1,73 @@ -#!/bin/bash -# info: list mail domain dkim -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining domain dkim files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ssl() { - echo '{' - echo -e "\t\"$domain\": {" - echo " \"PEM\": \"$pem\"," - echo " \"PUB\": \"$pub\"," - echo -e "\t}\n}" -} - -# Shell function -shell_list_ssl() { - if [ ! -z "$pem" ]; then - echo -e "$pem" - fi - if [ ! -z "$pub" ]; then - echo -e "\n$pub" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -if [ -e "$USER_DATA/mail/$domain.pem" ]; then - pem=$(cat $USER_DATA/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g') -fi - -if [ -e "$USER_DATA/mail/$domain.pub" ]; then - pub=$(cat $USER_DATA/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g') -fi - -# Listing domains -case $format in - json) json_list_ssl ;; - plain) nohead=1; shell_list_ssl ;; - shell) shell_list_ssl ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domain dkim +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining domain dkim files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ssl() { + echo '{' + echo -e "\t\"$domain\": {" + echo " \"PEM\": \"$pem\"," + echo " \"PUB\": \"$pub\"," + echo -e "\t}\n}" +} + +# Shell function +shell_list_ssl() { + if [ ! -z "$pem" ]; then + echo -e "$pem" + fi + if [ ! -z "$pub" ]; then + echo -e "\n$pub" + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +if [ -e "$USER_DATA/mail/$domain.pem" ]; then + pem=$(cat $USER_DATA/mail/$domain.pem |sed -e ':a;N;$!ba;s/\n/\\n/g') +fi + +if [ -e "$USER_DATA/mail/$domain.pub" ]; then + pub=$(cat $USER_DATA/mail/$domain.pub |sed -e ':a;N;$!ba;s/\n/\\n/g') +fi + +# Listing domains +case $format in + json) json_list_ssl ;; + plain) nohead=1; shell_list_ssl ;; + shell) shell_list_ssl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-mail-domains b/bin/v-list-mail-domains index ae92318d..e9daa34d 100755 --- a/bin/v-list-mail-domains +++ b/bin/v-list-mail-domains @@ -1,52 +1,52 @@ -#!/bin/bash -# info: list mail domains -# options: USER [FORMAT] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$USER_DATA/mail.conf -fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL" -fields="$fields \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list mail domains +# options: USER [FORMAT] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$USER_DATA/mail.conf +fields="\$DOMAIN \$ANTIVIRUS \$ANTISPAM \$DKIM \$ACCOUNTS \$U_DISK \$CATCHALL" +fields="$fields \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DOMAIN $ANTIVIRUS $ANTISPAM $DKIM $ACCOUNTS $U_DISK $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-config b/bin/v-list-sys-config index 61f8063e..74029029 100755 --- a/bin/v-list-sys-config +++ b/bin/v-list-sys-config @@ -1,61 +1,61 @@ -#!/bin/bash -# info: list system config -# options: [FORMAT] -# -# The function for obtaining the list of system parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Json function -json_list_conf() { - lines=$(wc -l $VESTA/conf/vesta.conf | cut -f 1 -d ' ') - i='0' - IFS=$'\n' - echo -e "{\n\t\"config\": {" - for str in $(cat $VESTA/conf/vesta.conf); do - (( ++i)) - key=${str%%=*} - value=${str#*=} - if [ "$i" -lt "$lines" ]; then - echo -e "\t\t\"$key\": \"${value//\'/}\"," - else - echo -e "\t\t\"$key\": \"${value//\'/}\"" - fi - done - echo -e "\t}\n}" -} - -# Shell function -shell_list_conf() { - IFS=$'\n' - for str in $(cat $VESTA/conf/vesta.conf); do - key=${str%%=*} - value=${str#*=} - echo "$key: ${value//\'/}" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing system config -case $format in - json) json_list_conf ;; - plain) shell_list_conf ;; - shell) shell_list_conf | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system config +# options: [FORMAT] +# +# The function for obtaining the list of system parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Json function +json_list_conf() { + lines=$(wc -l $VESTA/conf/vesta.conf | cut -f 1 -d ' ') + i='0' + IFS=$'\n' + echo -e "{\n\t\"config\": {" + for str in $(cat $VESTA/conf/vesta.conf); do + (( ++i)) + key=${str%%=*} + value=${str#*=} + if [ "$i" -lt "$lines" ]; then + echo -e "\t\t\"$key\": \"${value//\'/}\"," + else + echo -e "\t\t\"$key\": \"${value//\'/}\"" + fi + done + echo -e "\t}\n}" +} + +# Shell function +shell_list_conf() { + IFS=$'\n' + for str in $(cat $VESTA/conf/vesta.conf); do + key=${str%%=*} + value=${str#*=} + echo "$key: ${value//\'/}" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing system config +case $format in + json) json_list_conf ;; + plain) shell_list_conf ;; + shell) shell_list_conf | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-interfaces b/bin/v-list-sys-interfaces index 23fdf6c2..3bc8be1e 100755 --- a/bin/v-list-sys-interfaces +++ b/bin/v-list-sys-interfaces @@ -1,65 +1,65 @@ -#!/bin/bash -# info: list system interfaces -# options: [FORMAT] -# -# The function for obtaining the list of network interfaces. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_iface() { - dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) - int_counter=$(echo "$dev" | wc -l) - i=1 - echo '[' - for interface in $dev; do - if [ "$i" -lt "$int_counter" ]; then - echo -e "\t\"$interface\"," - else - echo -e "\t\"$interface\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_iface() { - dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) - if [ -z "$nohead" ]; then - echo "INTERFACES" - echo "----------" - fi - for interface in $dev; do - echo "$interface" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_iface ;; - plain) nohead=1; shell_list_iface ;; - shell) shell_list_iface ;; - *) check_args '1' '0' '[FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system interfaces +# options: [FORMAT] +# +# The function for obtaining the list of network interfaces. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_iface() { + dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) + int_counter=$(echo "$dev" | wc -l) + i=1 + echo '[' + for interface in $dev; do + if [ "$i" -lt "$int_counter" ]; then + echo -e "\t\"$interface\"," + else + echo -e "\t\"$interface\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_iface() { + dev=$(cat /proc/net/dev |grep : |cut -f 1 -d : |tr -d ' ' |grep -v lo) + if [ -z "$nohead" ]; then + echo "INTERFACES" + echo "----------" + fi + for interface in $dev; do + echo "$interface" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_iface ;; + plain) nohead=1; shell_list_iface ;; + shell) shell_list_iface ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-ip b/bin/v-list-sys-ip index 8f609933..0ba7f7c0 100755 --- a/bin/v-list-sys-ip +++ b/bin/v-list-sys-ip @@ -1,92 +1,92 @@ -#!/bin/bash -# info: list system ip -# options: IP [FORMAT] -# -# The function for getting the list of system ip parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -ip=$1 -IP=$ip -format=${2-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/func/ip.sh - -# Json function -json_list_ip() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - ip_data=$(cat $VESTA/data/ips/$IP) - echo '{' - eval $ip_data - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ $fileds_count -eq $i ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_ip() { - line=$(cat $VESTA/data/ips/$IP) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'IP [FORMAT]' -validate_format 'ip' -is_ip_valid - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -conf=$VESTA/data/ips/$IP - -# Defining fileds to select -fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS $INTERFACE - $NETMASK $TIME $DATE' - -# Listing ip -case $format in - json) json_list_ip ;; - plain) shell_list_ip ;; - shell) shell_list_ip | column -t ;; - *) check_args '1' '0' 'IP [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system ip +# options: IP [FORMAT] +# +# The function for getting the list of system ip parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +ip=$1 +IP=$ip +format=${2-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/func/ip.sh + +# Json function +json_list_ip() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + ip_data=$(cat $VESTA/data/ips/$IP) + echo '{' + eval $ip_data + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ $fileds_count -eq $i ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_ip() { + line=$(cat $VESTA/data/ips/$IP) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '1' "$#" 'IP [FORMAT]' +validate_format 'ip' +is_ip_valid + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +conf=$VESTA/data/ips/$IP + +# Defining fileds to select +fields='$IP $OWNER $STATUS $NAME $U_SYS_USERS $U_WEB_DOMAINS $INTERFACE + $NETMASK $TIME $DATE' + +# Listing ip +case $format in + json) json_list_ip ;; + plain) shell_list_ip ;; + shell) shell_list_ip | column -t ;; + *) check_args '1' '0' 'IP [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-ips b/bin/v-list-sys-ips index 7cee61ee..a757019c 100755 --- a/bin/v-list-sys-ips +++ b/bin/v-list-sys-ips @@ -1,94 +1,94 @@ -#!/bin/bash -# info: list system ips -# options: [FORMAT] -# -# The function for obtaining the list of system ip's. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ips() { - echo '{' - ip_list=$(ls $VESTA/data/ips/) - fileds_count=$(echo "$fields" | wc -w) - for IP in $ip_list; do - ip_data=$(cat $VESTA/data/ips/$IP) - eval $ip_data - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"$value\"," - else - echo -e "\t\t\"${field//$/}\": \"$value\"" - data=1 - fi - fi - done - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_ips() { - ip_list=$(ls $VESTA/data/ips/) - if [ -z "$nohead" ]; then - echo "${fields//$/}" - for a in $fields; do - echo -e "--------- \c" - done - echo - fi - - for IP in $ip_list; do - ip_data=$(cat $VESTA/data/ips/$IP) - eval $ip_data - eval echo "$fields" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -conf=$VESTA/data/ips/* -fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS" -fields="$fields \$INTERFACE \$NETMASK \$TIME \$DATE" - -# Listing ip addresses -case $format in - json) json_list_ips ;; - plain) nohead=1; shell_list_ips ;; - shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS'; - shell_list_ips | column -t ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system ips +# options: [FORMAT] +# +# The function for obtaining the list of system ip's. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ips() { + echo '{' + ip_list=$(ls $VESTA/data/ips/) + fileds_count=$(echo "$fields" | wc -w) + for IP in $ip_list; do + ip_data=$(cat $VESTA/data/ips/$IP) + eval $ip_data + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"$value\"," + else + echo -e "\t\t\"${field//$/}\": \"$value\"" + data=1 + fi + fi + done + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_ips() { + ip_list=$(ls $VESTA/data/ips/) + if [ -z "$nohead" ]; then + echo "${fields//$/}" + for a in $fields; do + echo -e "--------- \c" + done + echo + fi + + for IP in $ip_list; do + ip_data=$(cat $VESTA/data/ips/$IP) + eval $ip_data + eval echo "$fields" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +conf=$VESTA/data/ips/* +fields="\$IP \$OWNER \$STATUS \$NAME \$U_SYS_USERS \$U_WEB_DOMAINS" +fields="$fields \$INTERFACE \$NETMASK \$TIME \$DATE" + +# Listing ip addresses +case $format in + json) json_list_ips ;; + plain) nohead=1; shell_list_ips ;; + shell) fields='$IP $NETMASK $OWNER $STATUS $U_WEB_DOMAINS'; + shell_list_ips | column -t ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-rrd b/bin/v-list-sys-rrd index b5cd7ff6..68eb4a8c 100755 --- a/bin/v-list-sys-rrd +++ b/bin/v-list-sys-rrd @@ -1,114 +1,114 @@ -#!/bin/bash -# info: list system rrd charts -# options: [FORMAT] -# -# List available rrd graphics, its titles and paths. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Define json function -json_list_rrd() { - i=1 - echo "{" - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - if [ "$i" -ne 1 ]; then - echo -e "\t}," - fi - if [ "$type" = 'la' ]; then - title="Load Average" - fi - if [ "$type" = 'mem' ]; then - title="Memory Usage" - fi - if [ "$type" = 'net' ]; then - title="Bandwidth Usage $rrd" - fi - if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\ - [ "$type" = 'ssh' ]; then - title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage" - fi - if [ "$type" = 'db' ]; then - db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \ - -e 's/pgsql/PostgreSQL/g' ) - db_host=$(echo $rrd|cut -f 2 -d _ ) - title="$db_type Usage on $db_host" - fi - echo -e "\t\"$i\": {" - echo -e "\t\t\"TYPE\": \"$type\"", - echo -e "\t\t\"RRD\": \"$rrd\"", - echo -e "\t\t\"TITLE\": \"$title\"," - echo -e "\t\t\"TIME\": \"$TIME\"," - echo -e "\t\t\"DATE\": \"$DATE\"" - (( ++i)) - done - done - if [ "$i" -gt 1 ]; then - echo -e "\t}" - fi - echo "}" -} - -# Define jshell function -shell_list_rrd() { - if [ -z "$nohead" ]; then - echo "PATH" - echo "---------" - fi - for type in $rrd_types; do - for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do - echo "$RRD/$type/$rrd.rrd" - done - done -} - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking enabled systems -rrd_types="la mem net" - -if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types web" -fi - -if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types db" -fi - -if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types mail" -fi - -if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then - rrd_types="$rrd_types ftp" -fi - -rrd_types="$rrd_types ssh" - - -# Listing domains -case $format in - json) json_list_rrd ;; - plain) nohead=1; shell_list_rrd ;; - shell) shell_list_rrd | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system rrd charts +# options: [FORMAT] +# +# List available rrd graphics, its titles and paths. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +format=${1-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/conf/vesta.conf + +# Define json function +json_list_rrd() { + i=1 + echo "{" + for type in $rrd_types; do + for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do + if [ "$i" -ne 1 ]; then + echo -e "\t}," + fi + if [ "$type" = 'la' ]; then + title="Load Average" + fi + if [ "$type" = 'mem' ]; then + title="Memory Usage" + fi + if [ "$type" = 'net' ]; then + title="Bandwidth Usage $rrd" + fi + if [ "$type" = 'web' ] || [ "$type" = 'ftp' ] ||\ + [ "$type" = 'ssh' ]; then + title="$(echo $rrd| tr '[:lower:]' '[:upper:]') Usage" + fi + if [ "$type" = 'db' ]; then + db_type=$(echo $rrd|cut -f 1 -d _ |sed -e 's/mysql/MySQL/g' \ + -e 's/pgsql/PostgreSQL/g' ) + db_host=$(echo $rrd|cut -f 2 -d _ ) + title="$db_type Usage on $db_host" + fi + echo -e "\t\"$i\": {" + echo -e "\t\t\"TYPE\": \"$type\"", + echo -e "\t\t\"RRD\": \"$rrd\"", + echo -e "\t\t\"TITLE\": \"$title\"," + echo -e "\t\t\"TIME\": \"$TIME\"," + echo -e "\t\t\"DATE\": \"$DATE\"" + (( ++i)) + done + done + if [ "$i" -gt 1 ]; then + echo -e "\t}" + fi + echo "}" +} + +# Define jshell function +shell_list_rrd() { + if [ -z "$nohead" ]; then + echo "PATH" + echo "---------" + fi + for type in $rrd_types; do + for rrd in $(ls $RRD/$type |grep rrd$ |sed "s/\.rrd$//g"); do + echo "$RRD/$type/$rrd.rrd" + done + done +} + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking enabled systems +rrd_types="la mem net" + +if [ -n "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types web" +fi + +if [ -n "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types db" +fi + +if [ -n "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types mail" +fi + +if [ -n "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then + rrd_types="$rrd_types ftp" +fi + +rrd_types="$rrd_types ssh" + + +# Listing domains +case $format in + json) json_list_rrd ;; + plain) nohead=1; shell_list_rrd ;; + shell) shell_list_rrd | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-shells b/bin/v-list-sys-shells index 19a25738..227db0d0 100755 --- a/bin/v-list-sys-shells +++ b/bin/v-list-sys-shells @@ -1,67 +1,67 @@ -#!/bin/bash -# info: list system shells -# options: [FORMAT] -# -# The function for obtaining the list of system shells. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_sh() { - shells=$(cat /etc/shells) - sh_counter=$(echo "$shells" | wc -l) - i=1 - echo '[' - for shell in $shells; do - shell=$(basename $shell) - if [ "$i" -lt "$sh_counter" ]; then - echo -e "\t\"$shell\"," - else - echo -e "\t\"$shell\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_sh() { - shells=$(cat /etc/shells) - if [ -z "$nohead" ]; then - echo "SHELLS" - echo "----------" - fi - for shell in $shells; do - shell=$(basename $shell) - echo "$shell" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_sh ;; - plain) nohead=1; shell_list_sh ;; - shell) shell_list_sh ;; - *) check_args '1' '0' '[FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system shells +# options: [FORMAT] +# +# The function for obtaining the list of system shells. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_sh() { + shells=$(cat /etc/shells) + sh_counter=$(echo "$shells" | wc -l) + i=1 + echo '[' + for shell in $shells; do + shell=$(basename $shell) + if [ "$i" -lt "$sh_counter" ]; then + echo -e "\t\"$shell\"," + else + echo -e "\t\"$shell\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_sh() { + shells=$(cat /etc/shells) + if [ -z "$nohead" ]; then + echo "SHELLS" + echo "----------" + fi + for shell in $shells; do + shell=$(basename $shell) + echo "$shell" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_sh ;; + plain) nohead=1; shell_list_sh ;; + shell) shell_list_sh ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-sys-users b/bin/v-list-sys-users index 988ad1f3..3bae7418 100755 --- a/bin/v-list-sys-users +++ b/bin/v-list-sys-users @@ -1,65 +1,65 @@ -#!/bin/bash -# info: list system users -# options: [FORMAT] -# -# The function for obtaining the list of system users without -# detailed information. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_users() { - users=$(grep @ /etc/passwd|cut -f 1 -d :) - int_counter=$(echo "$users" | wc -l) - i=1 - echo '[' - for user in $users; do - if [ "$i" -lt "$int_counter" ]; then - echo -e "\t\"$user\"," - else - echo -e "\t\"$user\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_users() { - if [ -z "$nohead" ]; then - echo "USERS" - echo "----------" - fi - for user in $(grep @ /etc/passwd|cut -f 1 -d :); do - echo "$user" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_users ;; - plain) nohead=1; shell_list_users ;; - shell) shell_list_users ;; - *) check_args '1' '0' '[FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system users +# options: [FORMAT] +# +# The function for obtaining the list of system users without +# detailed information. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_users() { + users=$(grep @ /etc/passwd|cut -f 1 -d :) + int_counter=$(echo "$users" | wc -l) + i=1 + echo '[' + for user in $users; do + if [ "$i" -lt "$int_counter" ]; then + echo -e "\t\"$user\"," + else + echo -e "\t\"$user\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_users() { + if [ -z "$nohead" ]; then + echo "USERS" + echo "----------" + fi + for user in $(grep @ /etc/passwd|cut -f 1 -d :); do + echo "$user" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_users ;; + plain) nohead=1; shell_list_users ;; + shell) shell_list_users ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user b/bin/v-list-user index a0af9694..d4d798d6 100755 --- a/bin/v-list-user +++ b/bin/v-list-user @@ -1,97 +1,97 @@ -#!/bin/bash -# info: list system user -# options: USER [FORMAT] -# -# The function for obtainig the list of all user's parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/func/main.sh - -# Argument defenition -user=$1 -USER="$user" -format=${2-shell} - -# Json function -json_list_user() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - source $VESTA/data/users/$user/user.conf - echo '{' - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_user() { - source $VESTA/data/users/$user/user.conf - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/user.conf - -# Defining fileds to select -fields='$USER $FNAME $LNAME $PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES - $DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES - $CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT - $CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB - $SUSPENDED_DNS $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL - $IP_OWNED $U_USERS $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB - $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS - $U_DNS_RECORDS $U_MAIL_DOMAINS $U_MAIL_DKIM $U_MAIL_ACCOUNTS $U_DATABASES - $U_CRON_JOBS $U_BACKUPS $TIME $DATE' - -# Listing user -case $format in - json) json_list_user ;; - plain) nohead=1; shell_list_user ;; - shell) shell_list_user | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system user +# options: USER [FORMAT] +# +# The function for obtainig the list of all user's parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/func/main.sh + +# Argument defenition +user=$1 +USER="$user" +format=${2-shell} + +# Json function +json_list_user() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + source $VESTA/data/users/$user/user.conf + echo '{' + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_user() { + source $VESTA/data/users/$user/user.conf + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/user.conf + +# Defining fileds to select +fields='$USER $FNAME $LNAME $PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES + $DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES + $CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT + $CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB + $SUSPENDED_DNS $SUSPENDED_MAIL $SUSPENDED_DB $SUSPENDED_CRON $IP_AVAIL + $IP_OWNED $U_USERS $U_DISK $U_DISK_DIRS $U_DISK_WEB $U_DISK_MAIL $U_DISK_DB + $U_BANDWIDTH $U_WEB_DOMAINS $U_WEB_SSL $U_WEB_ALIASES $U_DNS_DOMAINS + $U_DNS_RECORDS $U_MAIL_DOMAINS $U_MAIL_DKIM $U_MAIL_ACCOUNTS $U_DATABASES + $U_CRON_JOBS $U_BACKUPS $TIME $DATE' + +# Listing user +case $format in + json) json_list_user ;; + plain) nohead=1; shell_list_user ;; + shell) shell_list_user | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-backups b/bin/v-list-user-backups index 9a04c7f0..c08c79f5 100755 --- a/bin/v-list-user-backups +++ b/bin/v-list-user-backups @@ -1,56 +1,56 @@ -#!/bin/bash -# info: list user backups -# options: USER [FORMAT] -# -# The function for obtainig the list of available user backups. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking config -conf=$USER_DATA/backup.conf -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Defining fileds to select -fields="\$BACKUP \$TYPE \$SIZE \$VESTA \$PAM \$WEB \$DNS \$DB" -fields="$fields \$MAIL \$CRON \$RUNTIME \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$BACKUP $TYPE $SIZE $RUNTIME $TIME $DATE'; - shell_list |column -t;; - *) check_args '1' '0' '[FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user backups +# options: USER [FORMAT] +# +# The function for obtainig the list of available user backups. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking config +conf=$USER_DATA/backup.conf +if [ ! -e "$conf" ]; then + touch $conf +fi + +# Defining fileds to select +fields="\$BACKUP \$TYPE \$SIZE \$VESTA \$PAM \$WEB \$DNS \$DB" +fields="$fields \$MAIL \$CRON \$RUNTIME \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$BACKUP $TYPE $SIZE $RUNTIME $TIME $DATE'; + shell_list |column -t;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-ips b/bin/v-list-user-ips index 7bc0dd3c..945556a8 100755 --- a/bin/v-list-user-ips +++ b/bin/v-list-user-ips @@ -1,121 +1,121 @@ -#!/bin/bash -# info: list user ips -# options: USER [FORMAT] -# -# The function for obtainig the list of available ip addresses. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_user_ips() { - echo '{' - fileds_count=$(echo "$fields" | wc -w) - for IP in $(ls $VESTA/data/ips/); do - source $VESTA/data/ips/$IP - if [ "$OWNER" = "$user" ]; then - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - else - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - fi - fi - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' - -} - -# Shell function -shell_list_user_ips() { - for IP in $(ls $VESTA/data/ips/); do - source $VESTA/data/ips/$IP - if [ "$OWNER" = "$user" ]; then - eval echo "$fields" - else - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - eval echo "$fields" - fi - fi - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -fields='$IP $OWNER $STATUS $NAME' - -# Listing ips -case $format in - json) json_list_user_ips ;; - plain) nohead=1; shell_list_user_ips ;; - shell) shell_list_user_ips | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user ips +# options: USER [FORMAT] +# +# The function for obtainig the list of available ip addresses. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_user_ips() { + echo '{' + fileds_count=$(echo "$fields" | wc -w) + for IP in $(ls $VESTA/data/ips/); do + source $VESTA/data/ips/$IP + if [ "$OWNER" = "$user" ]; then + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + else + if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + fi + fi + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' + +} + +# Shell function +shell_list_user_ips() { + for IP in $(ls $VESTA/data/ips/); do + source $VESTA/data/ips/$IP + if [ "$OWNER" = "$user" ]; then + eval echo "$fields" + else + if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then + eval echo "$fields" + fi + fi + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +fields='$IP $OWNER $STATUS $NAME' + +# Listing ips +case $format in + json) json_list_user_ips ;; + plain) nohead=1; shell_list_user_ips ;; + shell) shell_list_user_ips | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-log b/bin/v-list-user-log index 1c3ee19c..c5fdcc1f 100755 --- a/bin/v-list-user-log +++ b/bin/v-list-user-log @@ -1,88 +1,88 @@ -#!/bin/bash -# info: list user log -# options: USER [FORMAT] -# -# The function of obtaining the list of 100 last users commands. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json func -json_list_history() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - IFS=$'\n' - eval $line - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done < $conf - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/history.log - -# Defining fileds to select -fields="\$ID \$DATE \$TIME \$CMD \$UNDO" - -# Listing domains -case $format in - json) json_list_history ;; - plain) nohead=1; shell_list ;; - shell) fields='$ID~$DATE~$TIME~$CMD'; - shell_list |column -t -s '~';; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user log +# options: USER [FORMAT] +# +# The function of obtaining the list of 100 last users commands. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json func +json_list_history() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + IFS=$'\n' + eval $line + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value" | sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done < $conf + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/history.log + +# Defining fileds to select +fields="\$ID \$DATE \$TIME \$CMD \$UNDO" + +# Listing domains +case $format in + json) json_list_history ;; + plain) nohead=1; shell_list ;; + shell) fields='$ID~$DATE~$TIME~$CMD'; + shell_list |column -t -s '~';; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-ns b/bin/v-list-user-ns index 9b216327..d296191b 100755 --- a/bin/v-list-user-ns +++ b/bin/v-list-user-ns @@ -1,75 +1,75 @@ -#!/bin/bash -# info: list user nameservers -# options: USER [FORMAT] -# -# Function for obtainig the list of user's DNS servers. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ns() { - ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') - echo '[' - i=1 - nslistc=$(echo -e "${ns//,/\n}"|wc -l) - for nameserver in ${ns//,/ };do - if [ "$i" -ne "$nslistc" ]; then - echo -e "\t\"$nameserver\"," - else - echo -e "\t\"$nameserver\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_ns() { - ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') - if [ -z "$nohead" ]; then - echo "NAMESERVER" - echo "----------" - fi - for nameserver in ${ns//,/ };do - echo "$nameserver" - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing nameservers -case $format in - json) json_list_ns ;; - plain) nohead=1; shell_list_ns ;; - shell) shell_list_ns ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user nameservers +# options: USER [FORMAT] +# +# Function for obtainig the list of user's DNS servers. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ns() { + ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') + echo '[' + i=1 + nslistc=$(echo -e "${ns//,/\n}"|wc -l) + for nameserver in ${ns//,/ };do + if [ "$i" -ne "$nslistc" ]; then + echo -e "\t\"$nameserver\"," + else + echo -e "\t\"$nameserver\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_ns() { + ns=$(grep "^NS='" $USER_DATA/user.conf |cut -f 2 -d \') + if [ -z "$nohead" ]; then + echo "NAMESERVER" + echo "----------" + fi + for nameserver in ${ns//,/ };do + echo "$nameserver" + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing nameservers +case $format in + json) json_list_ns ;; + plain) nohead=1; shell_list_ns ;; + shell) shell_list_ns ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-package b/bin/v-list-user-package index 2c30f966..13941589 100755 --- a/bin/v-list-user-package +++ b/bin/v-list-user-package @@ -1,92 +1,92 @@ -#!/bin/bash -# info: list user package -# options: PACKAGE [FORMAT] -# -# The function for getting the list of system ip parameters. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -package=$1 -PACKAGE=$package -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_package() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - pkg_data=$(cat $VESTA/data/packages/$PACKAGE.pkg) - echo '{' - eval $pkg_data - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ $fileds_count -eq $i ]; then - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_package() { - line=$(cat $VESTA/data/packages/$PACKAGE.pkg) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking args -check_args '1' "$#" 'PACKAGE [FORMAT]' -validate_format 'package' -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS - $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH - $NS $SHELL $BACKUPS $TIME $DATE' - -# Listing ip -case $format in - json) json_list_package ;; - plain) shell_list_package ;; - shell) shell_list_package | column -t ;; - *) check_args '1' '0' 'IP [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user package +# options: PACKAGE [FORMAT] +# +# The function for getting the list of system ip parameters. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +package=$1 +PACKAGE=$package +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_package() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + pkg_data=$(cat $VESTA/data/packages/$PACKAGE.pkg) + echo '{' + eval $pkg_data + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ $fileds_count -eq $i ]; then + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_package() { + line=$(cat $VESTA/data/packages/$PACKAGE.pkg) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking args +check_args '1' "$#" 'PACKAGE [FORMAT]' +validate_format 'package' +is_package_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS + $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH + $NS $SHELL $BACKUPS $TIME $DATE' + +# Listing ip +case $format in + json) json_list_package ;; + plain) shell_list_package ;; + shell) shell_list_package | column -t ;; + *) check_args '1' '0' 'IP [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-packages b/bin/v-list-user-packages index 34833753..d4dadaa0 100755 --- a/bin/v-list-user-packages +++ b/bin/v-list-user-packages @@ -1,91 +1,91 @@ -#!/bin/bash -# info: list user packages -# options: [FORMAT] -# -# The function for obtaining the list of available hosting packages. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_pkgs() { - echo '{' - fileds_count=$(echo "$fields" | wc -w) - for package in $(ls $VESTA/data/packages); do - PACKAGE=${package/.pkg/} - pkg_data=$(cat $VESTA/data/packages/$package) - eval $pkg_data - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - data=1 - fi - fi - done - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell fnction -shell_list_pkgs() { - for package in $(ls $VESTA/data/packages); do - PACKAGE=${package/.pkg/} - pkg_descr=$(cat $VESTA/data/packages/$package) - eval $pkg_descr - if [ -z "$nohead" ]; then - echo '----------' - fi - for field in $fields; do - eval value=$field - echo -e "${field//$/}: $value" - done - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fields -fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS - $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH - $NS $SHELL $BACKUPS $TIME $DATE' - -# Listing domains -case $format in - json) json_list_pkgs ;; - plain) nohead=1; shell_list_pkgs ;; - shell) shell_list_pkgs | column -t ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user packages +# options: [FORMAT] +# +# The function for obtaining the list of available hosting packages. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_pkgs() { + echo '{' + fileds_count=$(echo "$fields" | wc -w) + for package in $(ls $VESTA/data/packages); do + PACKAGE=${package/.pkg/} + pkg_data=$(cat $VESTA/data/packages/$package) + eval $pkg_data + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + data=1 + fi + fi + done + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell fnction +shell_list_pkgs() { + for package in $(ls $VESTA/data/packages); do + PACKAGE=${package/.pkg/} + pkg_descr=$(cat $VESTA/data/packages/$package) + eval $pkg_descr + if [ -z "$nohead" ]; then + echo '----------' + fi + for field in $fields; do + eval value=$field + echo -e "${field//$/}: $value" + done + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fields +fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES $DNS_DOMAINS $DNS_RECORDS + $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES $CRON_JOBS $DISK_QUOTA $BANDWIDTH + $NS $SHELL $BACKUPS $TIME $DATE' + +# Listing domains +case $format in + json) json_list_pkgs ;; + plain) nohead=1; shell_list_pkgs ;; + shell) shell_list_pkgs | column -t ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-user-stats b/bin/v-list-user-stats index c79631d5..8126fa2e 100755 --- a/bin/v-list-user-stats +++ b/bin/v-list-user-stats @@ -1,61 +1,61 @@ -#!/bin/bash -# info: list user stats -# options: USER [FORMAT] -# -# The function for listing user statistics - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/stats.log -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Defining fileds to select -fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" -fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" -fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" -fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" -fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DATE $PACKAGE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS'; - fields="$fields \$U_DATABASES" - shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list user stats +# options: USER [FORMAT] +# +# The function for listing user statistics + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/stats.log +if [ ! -e "$conf" ]; then + touch $conf +fi + +# Defining fileds to select +fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" +fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" +fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" +fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" +fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DATE $PACKAGE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS'; + fields="$fields \$U_DATABASES" + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-users b/bin/v-list-users index 69929227..a2d27691 100755 --- a/bin/v-list-users +++ b/bin/v-list-users @@ -1,102 +1,102 @@ -#!/bin/bash -# info: list system users -# options: [FORMAT] -# -# The function for obtainig the list of all server's users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Json function -json_list_users() { - echo '{' - fileds_count=$(echo "$fields" | wc -w) - for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do - source $VESTA/data/users/$USER/user.conf - if [ -n "$data" ]; then - echo -e ' },' - fi - i=1 - for field in $fields; do - eval value=$field - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"$value\"," - else - echo -e "\t\t\"${field//$/}\": \"$value\"" - data=1 - fi - fi - done - done - if [ -n "$data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell function -shell_list_users() { - if [ -z "$nohead" ]; then - echo "${fields//$/}" - for a in $fields; do - echo -e "--------- \c" - done - echo - fi - - for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do - source $VESTA/data/users/$USER/user.conf - for field in $fields; do - eval value=$field - if [ -z "$value" ]; then - value='NULL' - fi - echo -n "$value " - done - echo - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining fileds to select -fields="\$USER \$FNAME \$LNAME \$PACKAGE \$TEMPLATE \$WEB_DOMAINS" -fields="$fields \$WEB_ALIASES \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS" -fields="$fields \$MAIL_ACCOUNTS \$DATABASES \$CRON_JOBS \$DISK_QUOTA" -fields="$fields \$BANDWIDTH \$NS \$SHELL \$BACKUPS \$CONTACT" -fields="$fields \$CRON_REPORTS \$RKEY \$SUSPENDED \$SUSPENDED_USERS" -fields="$fields \$SUSPENDED_WEB \$SUSPENDED_DNS \$SUSPENDED_MAIL" -fields="$fields \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL \$IP_OWNED" -fields="$fields \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB \$U_DISK_MAIL" -fields="$fields \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL" -fields="$fields \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS" -fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS" -fields="$fields \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list_users ;; - plain) nohead=1; shell_list_users ;; - shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE'; - shell_list_users | column -t ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list system users +# options: [FORMAT] +# +# The function for obtainig the list of all server's users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Json function +json_list_users() { + echo '{' + fileds_count=$(echo "$fields" | wc -w) + for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do + source $VESTA/data/users/$USER/user.conf + if [ -n "$data" ]; then + echo -e ' },' + fi + i=1 + for field in $fields; do + eval value=$field + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"$value\"," + else + echo -e "\t\t\"${field//$/}\": \"$value\"" + data=1 + fi + fi + done + done + if [ -n "$data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell function +shell_list_users() { + if [ -z "$nohead" ]; then + echo "${fields//$/}" + for a in $fields; do + echo -e "--------- \c" + done + echo + fi + + for USER in $(grep @ /etc/passwd|cut -f 1 -d :); do + source $VESTA/data/users/$USER/user.conf + for field in $fields; do + eval value=$field + if [ -z "$value" ]; then + value='NULL' + fi + echo -n "$value " + done + echo + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining fileds to select +fields="\$USER \$FNAME \$LNAME \$PACKAGE \$TEMPLATE \$WEB_DOMAINS" +fields="$fields \$WEB_ALIASES \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS" +fields="$fields \$MAIL_ACCOUNTS \$DATABASES \$CRON_JOBS \$DISK_QUOTA" +fields="$fields \$BANDWIDTH \$NS \$SHELL \$BACKUPS \$CONTACT" +fields="$fields \$CRON_REPORTS \$RKEY \$SUSPENDED \$SUSPENDED_USERS" +fields="$fields \$SUSPENDED_WEB \$SUSPENDED_DNS \$SUSPENDED_MAIL" +fields="$fields \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL \$IP_OWNED" +fields="$fields \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB \$U_DISK_MAIL" +fields="$fields \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL" +fields="$fields \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS" +fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS" +fields="$fields \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list_users ;; + plain) nohead=1; shell_list_users ;; + shell) fields='$USER $PACKAGE $U_DISK $U_BANDWIDTH $SUSPENDED $DATE'; + shell_list_users | column -t ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-users-stats b/bin/v-list-users-stats index 95f39ea0..5416da7b 100755 --- a/bin/v-list-users-stats +++ b/bin/v-list-users-stats @@ -1,58 +1,58 @@ -#!/bin/bash -# info: list overall user stats -# options: [FORMAT] -# -# The function for listing overall user statistics - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" '[FORMAT]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$VESTA/data/users/admin/overall_stats.log -if [ ! -e "$conf" ]; then - touch $conf -fi - -# Defining fileds to select -fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" -fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" -fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" -fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" -fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DATE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_DATABASES'; - fields="$fields \$U_DATABASES" - shell_list | column -t ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list overall user stats +# options: [FORMAT] +# +# The function for listing overall user statistics + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" '[FORMAT]' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$VESTA/data/users/admin/overall_stats.log +if [ ! -e "$conf" ]; then + touch $conf +fi + +# Defining fileds to select +fields="\$DATE \$TIME \$PACKAGE \$IP_OWNED \$DISK_QUOTA \$U_DISK \$U_DISK_DIRS" +fields="$fields \$U_DISK_WEB \$U_DISK_MAIL \$U_DISK_DB \$BANDWIDTH" +fields="$fields \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL \$U_WEB_ALIASES" +fields="$fields \$U_DNS_DOMAINS \$U_DNS_RECORDS \$U_MAIL_DOMAINS \$U_MAIL_DKIM" +fields="$fields \$U_MAIL_ACCOUNTS \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DATE $U_DISK $U_BANDWIDTH $U_WEB_DOMAINS $U_DATABASES'; + fields="$fields \$U_DATABASES" + shell_list | column -t ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domain b/bin/v-list-web-domain index da1b8ce8..d74d1c68 100755 --- a/bin/v-list-web-domain +++ b/bin/v-list-web-domain @@ -1,94 +1,94 @@ -#!/bin/bash -# info: list web domain -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining the list of domain parameters. This call, just as -# all v_list_* calls, supports 3 formats - json, shell and plain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_domain() { - i=1 - fileds_count=$(echo "$fields" | wc -w) - line=$(grep "DOMAIN='$domain'" $conf) - echo '{' - eval $line - for field in $fields; do - eval value=$field - if [ "$i" -eq 1 ]; then - echo -e "\t\"$value\": {" - else - if [ "$fileds_count" -eq "$i" ]; then - echo -e "\t\t\"${field//$/}\": \"$value\"" - else - echo -e "\t\t\"${field//$/}\": \"$value\"," - fi - fi - (( ++i)) - done - if [ -n "$value" ]; then - echo -e ' }' - fi - echo -e "}" -} - -# Shell function -shell_list_domain() { - line=$(grep "DOMAIN='$domain'" $conf) - eval $line - for field in $fields; do - eval key="$field" - if [ -z "$key" ]; then - key='NULL' - fi - echo "${field//$/}: $key " - done -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $CGI $ELOG $STATS - $STATS_USER $SSL $SSL_HOME $FTP_USER $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE' - -# Listing domains -case $format in - json) json_list_domain ;; - plain) nohead=1; shell_list_domain ;; - shell) shell_list_domain |column -t;; - *) check_args '2' '0' 'USER DOMAIN [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domain +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining the list of domain parameters. This call, just as +# all v_list_* calls, supports 3 formats - json, shell and plain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_domain() { + i=1 + fileds_count=$(echo "$fields" | wc -w) + line=$(grep "DOMAIN='$domain'" $conf) + echo '{' + eval $line + for field in $fields; do + eval value=$field + if [ "$i" -eq 1 ]; then + echo -e "\t\"$value\": {" + else + if [ "$fileds_count" -eq "$i" ]; then + echo -e "\t\t\"${field//$/}\": \"$value\"" + else + echo -e "\t\t\"${field//$/}\": \"$value\"," + fi + fi + (( ++i)) + done + if [ -n "$value" ]; then + echo -e ' }' + fi + echo -e "}" +} + +# Shell function +shell_list_domain() { + line=$(grep "DOMAIN='$domain'" $conf) + eval $line + for field in $fields; do + eval key="$field" + if [ -z "$key" ]; then + key='NULL' + fi + echo "${field//$/}: $key " + done +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $CGI $ELOG $STATS + $STATS_USER $SSL $SSL_HOME $FTP_USER $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE' + +# Listing domains +case $format in + json) json_list_domain ;; + plain) nohead=1; shell_list_domain ;; + shell) shell_list_domain |column -t;; + *) check_args '2' '0' 'USER DOMAIN [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domain-ssl b/bin/v-list-web-domain-ssl index 0843b1a6..eb79b8f2 100755 --- a/bin/v-list-web-domain-ssl +++ b/bin/v-list-web-domain-ssl @@ -1,81 +1,81 @@ -#!/bin/bash -# info: list web domain ssl certificate -# options: USER DOMAIN [FORMAT] -# -# The function of obtaining domain ssl files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$2 -format=${3-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_ssl() { - i='1' # iterator - echo '{' - echo -e "\t\"$domain\": {" - echo " \"CRT\": \"$crt\"," - echo " \"KEY\": \"$key\"," - echo " \"CA\": \"$ca\"" - echo -e "\t}\n}" -} - -# Shell function -shell_list_ssl() { - if [ ! -z "$crt" ]; then - echo -e "$crt" - fi - if [ ! -z "$key" ]; then - echo -e "\n$key" - fi - if [ ! -z "$ca" ]; then - echo -e "\n$ca" - fi -} - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [FORMAT]' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -if [ -e "$USER_DATA/ssl/$domain.crt" ]; then - crt=$(cat $USER_DATA/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -if [ -e "$USER_DATA/ssl/$domain.key" ]; then - key=$(cat $USER_DATA/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - ca=$(cat $USER_DATA/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' ) -fi - -# Listing domains -case $format in - json) json_list_ssl ;; - plain) nohead=1; shell_list_ssl ;; - shell) shell_list_ssl ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domain ssl certificate +# options: USER DOMAIN [FORMAT] +# +# The function of obtaining domain ssl files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$2 +format=${3-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_ssl() { + i='1' # iterator + echo '{' + echo -e "\t\"$domain\": {" + echo " \"CRT\": \"$crt\"," + echo " \"KEY\": \"$key\"," + echo " \"CA\": \"$ca\"" + echo -e "\t}\n}" +} + +# Shell function +shell_list_ssl() { + if [ ! -z "$crt" ]; then + echo -e "$crt" + fi + if [ ! -z "$key" ]; then + echo -e "\n$key" + fi + if [ ! -z "$ca" ]; then + echo -e "\n$ca" + fi +} + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [FORMAT]' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +if [ -e "$USER_DATA/ssl/$domain.crt" ]; then + crt=$(cat $USER_DATA/ssl/$domain.crt |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +if [ -e "$USER_DATA/ssl/$domain.key" ]; then + key=$(cat $USER_DATA/ssl/$domain.key |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + ca=$(cat $USER_DATA/ssl/$domain.ca |sed -e ':a;N;$!ba;s/\n/\\n/g' ) +fi + +# Listing domains +case $format in + json) json_list_ssl ;; + plain) nohead=1; shell_list_ssl ;; + shell) shell_list_ssl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains b/bin/v-list-web-domains index 0d8e052d..17eeef03 100755 --- a/bin/v-list-web-domains +++ b/bin/v-list-web-domains @@ -1,55 +1,55 @@ -#!/bin/bash -# info: list web domains -# options: USER [FORMAT] -# -# The function of obtaining the list of all user domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$CGI" -fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$FTP_USER" -fields="$fields \$NGINX \$NGINX_EXT \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE'; - shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains +# options: USER [FORMAT] +# +# The function of obtaining the list of all user domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$CGI" +fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$FTP_USER" +fields="$fields \$NGINX \$NGINX_EXT \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) fields='$DOMAIN $IP $U_DISK $U_BANDWIDTH $TPL $DATE'; + shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-alias b/bin/v-list-web-domains-alias index 977bab93..fb8f2451 100755 --- a/bin/v-list-web-domains-alias +++ b/bin/v-list-web-domains-alias @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and alias key -# options: USER [FORMAT] -# -# The function for obtaining the list of aliases of all user's domains. This -# call was arranged for filling in the lack of information by applying -# v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$ALIAS" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and alias key +# options: USER [FORMAT] +# +# The function for obtaining the list of aliases of all user's domains. This +# call was arranged for filling in the lack of information by applying +# v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$ALIAS" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-elog b/bin/v-list-web-domains-elog index 7487e38c..ed99a044 100755 --- a/bin/v-list-web-domains-elog +++ b/bin/v-list-web-domains-elog @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and elog key -# options: USER [FORMAT] -# -# The function for obtaining the list of domains with parameter ErrorLog -# displayed. This call was arranged for filling in the lack of information by -# applying v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$ELOG \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and elog key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with parameter ErrorLog +# displayed. This call was arranged for filling in the lack of information by +# applying v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$ELOG \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-nginx b/bin/v-list-web-domains-nginx index 2b95ae5d..7642eb89 100755 --- a/bin/v-list-web-domains-nginx +++ b/bin/v-list-web-domains-nginx @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and nginx key -# options: USER [FORMAT] -# -# The function for obtaining the list of domains with nginx parameter -# displayed. This call was arranged for filling in the lack of information by -# applying v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$NGINX \$NGINX_EXT" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' '0' 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and nginx key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with nginx parameter +# displayed. This call was arranged for filling in the lack of information by +# applying v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$NGINX \$NGINX_EXT" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' '0' 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-ssl b/bin/v-list-web-domains-ssl index 6fc4bd09..6f05bc74 100755 --- a/bin/v-list-web-domains-ssl +++ b/bin/v-list-web-domains-ssl @@ -1,54 +1,54 @@ -#!/bin/bash -# info: list web domains and alias key -# options: USER [FORMAT] -# -# The function for obtaining the list of domains with SSL parameter displayed. -# This call was arranged for filling in the lack of information by applying -# v-list-web-domains call in the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf="$USER_DATA/web.conf" - -# Defining fileds to select -fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME \$SUSPENDED" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' "0" 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and alias key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with SSL parameter displayed. +# This call was arranged for filling in the lack of information by applying +# v-list-web-domains call in the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf="$USER_DATA/web.conf" + +# Defining fileds to select +fields="\$DOMAIN \$IP \$TPL \$SSL \$SSL_HOME \$SUSPENDED" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' "0" 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-domains-stats b/bin/v-list-web-domains-stats index 369aef89..52c3eb23 100755 --- a/bin/v-list-web-domains-stats +++ b/bin/v-list-web-domains-stats @@ -1,55 +1,55 @@ -#!/bin/bash -# info: list web domains and stats key -# options: USER [FORMAT] -# -# The function for obtaining the list of domains with statistics parameter -# displayed, including authentication settings. This call was arranged for -# filling in the lack of information by applying v-list-web-domains call in -# the shell format. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -format=${2-shell} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [FORMAT]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining config -conf=$USER_DATA/web.conf - -# Defining fileds to select -fields="\$DOMAIN \$STATS \$STATS_AUTH \$SUSPENDED \$TIME \$DATE" - -# Listing domains -case $format in - json) json_list ;; - plain) nohead=1; shell_list ;; - shell) shell_list | column -t ;; - *) check_args '1' "0" 'USER [FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web domains and stats key +# options: USER [FORMAT] +# +# The function for obtaining the list of domains with statistics parameter +# displayed, including authentication settings. This call was arranged for +# filling in the lack of information by applying v-list-web-domains call in +# the shell format. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +format=${2-shell} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [FORMAT]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining config +conf=$USER_DATA/web.conf + +# Defining fileds to select +fields="\$DOMAIN \$STATS \$STATS_AUTH \$SUSPENDED \$TIME \$DATE" + +# Listing domains +case $format in + json) json_list ;; + plain) nohead=1; shell_list ;; + shell) shell_list | column -t ;; + *) check_args '1' "0" 'USER [FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-stats b/bin/v-list-web-stats index 88499eec..33d56c24 100755 --- a/bin/v-list-web-stats +++ b/bin/v-list-web-stats @@ -1,66 +1,66 @@ -#!/bin/bash -# info: list web statistics -# options: [FORMAT] -# -# The function for obtaining the list of web statistics analyzer. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh -source $VESTA/conf/vesta.conf - -# Json function -json_list_st() { - stats=$(echo "${STATS_SYSTEM//,/ } none") - st_counter=$(echo "$stats" | wc -w) - i=1 - echo '[' - for st in $stats; do - if [ "$i" -lt "$st_counter" ]; then - echo -e "\t\"$st\"," - else - echo -e "\t\"$st\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_st() { - stats=$(echo "none ${STATS_SYSTEM//,/ }") - if [ -z "$nohead" ]; then - echo "STATS" - echo "----------" - fi - for st in $stats; do - echo "$st" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_st ;; - plain) nohead=1; shell_list_st ;; - shell) shell_list_st ;; - *) check_args '1' '0' '[FORMAT]' ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web statistics +# options: [FORMAT] +# +# The function for obtaining the list of web statistics analyzer. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh +source $VESTA/conf/vesta.conf + +# Json function +json_list_st() { + stats=$(echo "${STATS_SYSTEM//,/ } none") + st_counter=$(echo "$stats" | wc -w) + i=1 + echo '[' + for st in $stats; do + if [ "$i" -lt "$st_counter" ]; then + echo -e "\t\"$st\"," + else + echo -e "\t\"$st\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_st() { + stats=$(echo "none ${STATS_SYSTEM//,/ }") + if [ -z "$nohead" ]; then + echo "STATS" + echo "----------" + fi + for st in $stats; do + echo "$st" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_st ;; + plain) nohead=1; shell_list_st ;; + shell) shell_list_st ;; + *) check_args '1' '0' '[FORMAT]' ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-templates b/bin/v-list-web-templates index 9004ca9a..973ad913 100755 --- a/bin/v-list-web-templates +++ b/bin/v-list-web-templates @@ -1,68 +1,68 @@ -#!/bin/bash -# info: list web templates -# options: USER [FORMAT] -# -# The function for obtaining the list of apache templates available to a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - t_counter=$(echo "$templates" | wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" -} - -# Shell function -shell_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - if [ -z "$nohead" ]; then - echo "Templates" - echo "----------" - fi - for template in $templates; do - echo "$template" - done -} - - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_wtpl ;; - plain) nohead=1; shell_list_wtpl ;; - shell) shell_list_wtpl ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: list web templates +# options: USER [FORMAT] +# +# The function for obtaining the list of apache templates available to a user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + t_counter=$(echo "$templates" | wc -w) + i=1 + echo '[' + for template in $templates; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$template\"," + else + echo -e "\t\"$template\"" + fi + (( ++i)) + done + echo "]" +} + +# Shell function +shell_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + if [ -z "$nohead" ]; then + echo "Templates" + echo "----------" + fi + for template in $templates; do + echo "$template" + done +} + + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_wtpl ;; + plain) nohead=1; shell_list_wtpl ;; + shell) shell_list_wtpl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-list-web-templates-nginx b/bin/v-list-web-templates-nginx index 73d13cea..4b6b0f64 100755 --- a/bin/v-list-web-templates-nginx +++ b/bin/v-list-web-templates-nginx @@ -1,67 +1,67 @@ -#!/bin/bash -# info: listing nginx templates -# options: [FORMAT] -# -# The function for obtaining the list of nginx templates available to a user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -format=${1-shell} - -# Includes -source $VESTA/func/main.sh - -# Json function -json_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - t_counter=$(echo "$templates" | wc -w) - i=1 - echo '[' - for template in $templates; do - if [ "$i" -lt "$t_counter" ]; then - echo -e "\t\"$template\"," - else - echo -e "\t\"$template\"" - fi - (( ++i)) - done - echo "]" - } - -# Shell function -shell_list_wtpl() { - templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ - |cut -f 1 -d '.') - if [ -z "$nohead" ]; then - echo "Templates" - echo "----------" - fi - for template in $templates; do - echo "$template" - done -} - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Listing domains -case $format in - json) json_list_wtpl ;; - plain) nohead=1; shell_list_wtpl ;; - shell) shell_list_wtpl ;; - *) check_args '1' '0' '[FORMAT]' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: listing nginx templates +# options: [FORMAT] +# +# The function for obtaining the list of nginx templates available to a user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +format=${1-shell} + +# Includes +source $VESTA/func/main.sh + +# Json function +json_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + t_counter=$(echo "$templates" | wc -w) + i=1 + echo '[' + for template in $templates; do + if [ "$i" -lt "$t_counter" ]; then + echo -e "\t\"$template\"," + else + echo -e "\t\"$template\"" + fi + (( ++i)) + done + echo "]" + } + +# Shell function +shell_list_wtpl() { + templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ + |cut -f 1 -d '.') + if [ -z "$nohead" ]; then + echo "Templates" + echo "----------" + fi + for template in $templates; do + echo "$template" + done +} + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Listing domains +case $format in + json) json_list_wtpl ;; + plain) nohead=1; shell_list_wtpl ;; + shell) shell_list_wtpl ;; + *) check_args '1' '0' '[FORMAT]' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-rebuild-cron-jobs b/bin/v-rebuild-cron-jobs index 52f412bd..f27b6ccf 100755 --- a/bin/v-rebuild-cron-jobs +++ b/bin/v-rebuild-cron-jobs @@ -1,51 +1,51 @@ -#!/bin/bash -# info: rebuild cron jobs -# options: USER [RESTART] -# -# The function rebuilds system cron config file for specified user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$CRON_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Rebuild cron jobs -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild cron jobs +# options: USER [RESTART] +# +# The function rebuilds system cron config file for specified user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$CRON_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Rebuild cron jobs +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-databases b/bin/v-rebuild-databases index f34f27dc..eee88915 100755 --- a/bin/v-rebuild-databases +++ b/bin/v-rebuild-databases @@ -1,53 +1,53 @@ -#!/bin/bash -# info: rebuild databases -# options: USER -# -# The function for rebuilding of all databases of a single user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting rebuild loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - get_database_values - # Switching on db type - case $TYPE in - mysql) rebuild_mysql_database ;; - pgsql) rebuild_pgsql_database ;; - esac -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild databases +# options: USER +# +# The function for rebuilding of all databases of a single user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting rebuild loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + get_database_values + # Switching on db type + case $TYPE in + mysql) rebuild_mysql_database ;; + pgsql) rebuild_pgsql_database ;; + esac +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-dns-domains b/bin/v-rebuild-dns-domains index b15200c9..aaec4e98 100755 --- a/bin/v-rebuild-dns-domains +++ b/bin/v-rebuild-dns-domains @@ -1,128 +1,128 @@ -#!/bin/bash -# info: rebuild dns domains -# options: USER [RESTART] -# -# The function rebuilds BIND configuration files for all dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_records=0 -suspended_dns=0 - -# Checking dns folder -if [ ! -d "$USER_DATA/dns" ]; then - rm -f $USER_DATA/dns - mkdir $USER_DATA/dns -fi - -# Defining config and fie -conf="$USER_DATA/dns.conf" - - -# Defining user name servers -ns=$(get_user_value '$NS') -i=1 -for nameserver in ${ns//,/ };do - eval ns$i="$nameserver" - i=$((i + 1)) -done - -# Starting loop -for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do - # Defining variables - get_domain_values 'dns' - domain_idn=$(idn -t --quiet -a "$domain") - - # Checking zone file - if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then - cat $DNSTPL/$TPL.tpl |\ - sed -e "s/%ip%/$IP/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%ns1%/$ns1/g" \ - -e "s/%ns2%/$ns2/g" \ - -e "s/%ns3%/$ns3/g" \ - -e "s/%ns4%/$ns4/g" \ - -e "s/%time%/$TIME/g" \ - -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf - fi - - # Sorting records - sort_dns_records - - # Updating zone - update_domain_zone - - # Set file permissions - chmod 640 $HOMEDIR/$user/conf/dns/$domain.db - chown root:named $HOMEDIR/$user/conf/dns/$domain.db - - # Bind config check - nconf='/etc/named.conf' - if [ "$SUSPENDED" = 'yes' ]; then - rm_string=$(grep -n /etc/namedb/$domain.db $nconf | cut -d : -f 1) - if [ ! -z "$rm_string" ]; then - sed -i "$rm_string d" $nconf - fi - suspended_dns=$((suspended_dns + 1)) - else - if [ -z "$(grep /$domain.db $nconf)" ]; then - named="zone \"$domain_idn\" {type master; file" - named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" - echo "$named" >> /etc/named.conf - fi - fi - user_domains=$((user_domains + 1)) - records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') - user_records=$((user_records + records)) - update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains" -update_user_value "$user" '$U_DNS_RECORDS' "$user_records" -update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild dns domains +# options: USER [RESTART] +# +# The function rebuilds BIND configuration files for all dns domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +user_domains=0 +user_records=0 +suspended_dns=0 + +# Checking dns folder +if [ ! -d "$USER_DATA/dns" ]; then + rm -f $USER_DATA/dns + mkdir $USER_DATA/dns +fi + +# Defining config and fie +conf="$USER_DATA/dns.conf" + + +# Defining user name servers +ns=$(get_user_value '$NS') +i=1 +for nameserver in ${ns//,/ };do + eval ns$i="$nameserver" + i=$((i + 1)) +done + +# Starting loop +for domain in $(search_objects 'dns' 'DOMAIN' "*" 'DOMAIN'); do + # Defining variables + get_domain_values 'dns' + domain_idn=$(idn -t --quiet -a "$domain") + + # Checking zone file + if [ ! -e "$USER_DATA/dns/$domain.conf" ]; then + cat $DNSTPL/$TPL.tpl |\ + sed -e "s/%ip%/$IP/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%ns1%/$ns1/g" \ + -e "s/%ns2%/$ns2/g" \ + -e "s/%ns3%/$ns3/g" \ + -e "s/%ns4%/$ns4/g" \ + -e "s/%time%/$TIME/g" \ + -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf + fi + + # Sorting records + sort_dns_records + + # Updating zone + update_domain_zone + + # Set file permissions + chmod 640 $HOMEDIR/$user/conf/dns/$domain.db + chown root:named $HOMEDIR/$user/conf/dns/$domain.db + + # Bind config check + nconf='/etc/named.conf' + if [ "$SUSPENDED" = 'yes' ]; then + rm_string=$(grep -n /etc/namedb/$domain.db $nconf | cut -d : -f 1) + if [ ! -z "$rm_string" ]; then + sed -i "$rm_string d" $nconf + fi + suspended_dns=$((suspended_dns + 1)) + else + if [ -z "$(grep /$domain.db $nconf)" ]; then + named="zone \"$domain_idn\" {type master; file" + named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" + echo "$named" >> /etc/named.conf + fi + fi + user_domains=$((user_domains + 1)) + records=$(wc -l $USER_DATA/dns/$domain.conf | cut -f 1 -d ' ') + user_records=$((user_records + records)) + update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$U_DNS_DOMAINS' "$user_domains" +update_user_value "$user" '$U_DNS_RECORDS' "$user_records" +update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns" + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-mail-domains b/bin/v-rebuild-mail-domains index 8855bd80..db539ad6 100755 --- a/bin/v-rebuild-mail-domains +++ b/bin/v-rebuild-mail-domains @@ -1,184 +1,184 @@ -#!/bin/bash -# info: rebuild mail domains -# options: USER -# -# The function rebuilds EXIM configuration files for all mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Reset counters -U_MAIL_DOMAINS=0 -U_MAIL_DKMI=0 -U_MAIL_ACCOUNTS=0 -SUSPENDED_MAIL=0 -U_DISK_MAIL=0 - -# Checking mail folder -if [ ! -d "$USER_DATA/mail" ]; then - rm -f $USER_DATA/mail - mkdir $USER_DATA/mail -fi - -# Starting loop -for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do - # Defining variables - get_domain_values 'mail' - - # Rebuilding config structure - rm -f /etc/exim/domains/$domain - mkdir -p $HOMEDIR/$user/conf/mail/$domain - ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ - rm -f $HOMEDIR/$user/conf/mail/$domain/aliases - rm -f $HOMEDIR/$user/conf/mail/$domain/protection - rm -f $HOMEDIR/$user/conf/mail/$domain/passwd - touch $HOMEDIR/$user/conf/mail/$domain/aliases - touch $HOMEDIR/$user/conf/mail/$domain/protection - touch $HOMEDIR/$user/conf/mail/$domain/passwd - chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain - chown -R dovecot:mail /etc/exim/domains/$domain - chmod 770 $HOMEDIR/$user/conf/mail/$domain - chmod 660 $HOMEDIR/$user/conf/mail/$domain* - chmod 660 /etc/exim/domains/$domain - - # Adding antispam protection - if [ "$ANTISPAM" = 'yes' ]; then - echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection - fi - - # Adding antivirus protection - if [ "$ANTIVIRUS" = 'yes' ]; then - echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection - fi - - # Adding dkim - if [ "$DKIM" = 'yes' ]; then - U_MAIL_DKMI=$((U_MAIL_DKMI + 1)) - pem="$USER_DATA/mail/$domain.pem" - pub="$USER_DATA/mail/$domain.pub" - openssl genrsa -out $pem 512 &>/dev/null - openssl rsa -pubout -in $pem -out $pub &>/dev/null - chmod 660 $USER_DATA/mail/$domain.* - - cp $pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem - chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem - - # Deleting old dkim records - records=$($BIN/v-list-dns-domain-records $user $domain plain) - dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') - for id in $dkim_records; do - $BIN/v-delete-dns-domain-record $user $domain $id - done - - # Adding dkim dns records - check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") - if [ "$?" -eq 0 ]; then - p=$(cat $pub|grep -v ' KEY---'|tr -d '\n') - record='_domainkey' - policy="\"t=y; o=~;\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" - - record='mail._domainkey' - slct="\"k=rsa\; p=$p\"" - $BIN/v-add-dns-domain-record $user $domain $record TXT "$slct" - fi - fi - - # Removing symbolic link - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_MAIL=$((SUSPENDED_MAIL +1)) - rm -f /etc/exim/domains/$domain - fi - - if [ ! -e $HOMEDIR/$user/mail/$domain ]; then - mkdir $HOMEDIR/$user/mail/$domain - fi - chown $user:mail $HOMEDIR/$user/mail/$domain - chmod 770 $HOMEDIR/$user/mail/$domain - - dom_aliases=$HOMEDIR/$user/conf/mail/$domain/aliases - if [ ! -z "$CATCHALL" ]; then - echo "*@$domain:$CATCHALL" >> $dom_aliases - fi - - # Rebuild domain accounts - accs=0 - dom_diks=0 - if [ -e "$USER_DATA/mail/$domain.conf" ]; then - accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') - else - accounts='' - fi - - for account in $accounts; do - (( ++accs)) - dom_diks=$((dom_diks + U_DISK)) - object=$(grep "ACCOUNT='$account'" $USER_DATA/mail/$domain.conf) - eval "$object" - if [ "$SUSPENDED" = 'yes' ]; then - MD5='SUSPENDED' - fi - - str="$account:$MD5:$user:mail::$HOMEDIR/$user:$QUOTA" - echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - for malias in ${ALIAS//,/ }; do - echo "$malias@$domain:$account@$domain" >> $dom_aliases - done - if [ ! -z "$FWD" ]; then - echo "$account@$domain:$FWD" >> $dom_aliases - fi - - done - update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accs" - update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" - U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accs)) - U_DISK_MAIL=$((U_DISK_MAIL + dom_diks)) - U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" -update_user_value "$user" '$U_MAIL_DKMI' "$U_MAIL_DKMI" -update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" -update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" -update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" - -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild mail domains +# options: USER +# +# The function rebuilds EXIM configuration files for all mail domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Reset counters +U_MAIL_DOMAINS=0 +U_MAIL_DKMI=0 +U_MAIL_ACCOUNTS=0 +SUSPENDED_MAIL=0 +U_DISK_MAIL=0 + +# Checking mail folder +if [ ! -d "$USER_DATA/mail" ]; then + rm -f $USER_DATA/mail + mkdir $USER_DATA/mail +fi + +# Starting loop +for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do + # Defining variables + get_domain_values 'mail' + + # Rebuilding config structure + rm -f /etc/exim/domains/$domain + mkdir -p $HOMEDIR/$user/conf/mail/$domain + ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ + rm -f $HOMEDIR/$user/conf/mail/$domain/aliases + rm -f $HOMEDIR/$user/conf/mail/$domain/protection + rm -f $HOMEDIR/$user/conf/mail/$domain/passwd + touch $HOMEDIR/$user/conf/mail/$domain/aliases + touch $HOMEDIR/$user/conf/mail/$domain/protection + touch $HOMEDIR/$user/conf/mail/$domain/passwd + chown -R dovecot:mail $HOMEDIR/$user/conf/mail/$domain + chown -R dovecot:mail /etc/exim/domains/$domain + chmod 770 $HOMEDIR/$user/conf/mail/$domain + chmod 660 $HOMEDIR/$user/conf/mail/$domain* + chmod 660 /etc/exim/domains/$domain + + # Adding antispam protection + if [ "$ANTISPAM" = 'yes' ]; then + echo 'antispam' >> $HOMEDIR/$user/conf/mail/$domain/protection + fi + + # Adding antivirus protection + if [ "$ANTIVIRUS" = 'yes' ]; then + echo 'antivirus' >> $HOMEDIR/$user/conf/mail/$domain/protection + fi + + # Adding dkim + if [ "$DKIM" = 'yes' ]; then + U_MAIL_DKMI=$((U_MAIL_DKMI + 1)) + pem="$USER_DATA/mail/$domain.pem" + pub="$USER_DATA/mail/$domain.pub" + openssl genrsa -out $pem 512 &>/dev/null + openssl rsa -pubout -in $pem -out $pub &>/dev/null + chmod 660 $USER_DATA/mail/$domain.* + + cp $pem $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chown root:mail $HOMEDIR/$user/conf/mail/$domain/dkim.pem + chmod 660 $HOMEDIR/$user/conf/mail/$domain/dkim.pem + + # Deleting old dkim records + records=$($BIN/v-list-dns-domain-records $user $domain plain) + dkim_records=$(echo "$records" |grep -w '_domainkey'|cut -f 1 -d ' ') + for id in $dkim_records; do + $BIN/v-delete-dns-domain-record $user $domain $id + done + + # Adding dkim dns records + check_dns_domain=$(is_object_valid 'dns' 'DOMAIN' "$domain") + if [ "$?" -eq 0 ]; then + p=$(cat $pub|grep -v ' KEY---'|tr -d '\n') + record='_domainkey' + policy="\"t=y; o=~;\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$policy" + + record='mail._domainkey' + slct="\"k=rsa\; p=$p\"" + $BIN/v-add-dns-domain-record $user $domain $record TXT "$slct" + fi + fi + + # Removing symbolic link + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_MAIL=$((SUSPENDED_MAIL +1)) + rm -f /etc/exim/domains/$domain + fi + + if [ ! -e $HOMEDIR/$user/mail/$domain ]; then + mkdir $HOMEDIR/$user/mail/$domain + fi + chown $user:mail $HOMEDIR/$user/mail/$domain + chmod 770 $HOMEDIR/$user/mail/$domain + + dom_aliases=$HOMEDIR/$user/conf/mail/$domain/aliases + if [ ! -z "$CATCHALL" ]; then + echo "*@$domain:$CATCHALL" >> $dom_aliases + fi + + # Rebuild domain accounts + accs=0 + dom_diks=0 + if [ -e "$USER_DATA/mail/$domain.conf" ]; then + accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') + else + accounts='' + fi + + for account in $accounts; do + (( ++accs)) + dom_diks=$((dom_diks + U_DISK)) + object=$(grep "ACCOUNT='$account'" $USER_DATA/mail/$domain.conf) + eval "$object" + if [ "$SUSPENDED" = 'yes' ]; then + MD5='SUSPENDED' + fi + + str="$account:$MD5:$user:mail::$HOMEDIR/$user:$QUOTA" + echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + for malias in ${ALIAS//,/ }; do + echo "$malias@$domain:$account@$domain" >> $dom_aliases + done + if [ ! -z "$FWD" ]; then + echo "$account@$domain:$FWD" >> $dom_aliases + fi + + done + update_object_value 'mail' 'DOMAIN' "$domain" '$ACCOUNTS' "$accs" + update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" + U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accs)) + U_DISK_MAIL=$((U_DISK_MAIL + dom_diks)) + U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" +update_user_value "$user" '$U_MAIL_DKMI' "$U_MAIL_DKMI" +update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" +update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" +update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" + +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-rebuild-user b/bin/v-rebuild-user index a6d017e2..b398f699 100755 --- a/bin/v-rebuild-user +++ b/bin/v-rebuild-user @@ -1,161 +1,161 @@ <<<<<<< HEAD -#!/bin/bash -# info: rebuild system user -# options: USER [RESTART] -# -# The function rebuilds system user account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# -export PATH=$PATH:/usr/sbin - -# Get user variables -source $USER_DATA/user.conf - -# Rebuild user -shell=$(chsh --list-shells | grep -w "$SHELL" |head -n1) -adduser "$user" -s "$shell" -c "$CONTACT" -m -d "$HOMEDIR/$user" &>/dev/null - -# Update password -shadow='/etc/shadow' -shdw=$(grep ^$user: $shadow) -shdw3=$(echo "$shdw" | cut -f3 -d :) -shdw4=$(echo "$shdw" | cut -f4 -d :) -shdw5=$(echo "$shdw" | cut -f5 -d :) -shdw6=$(echo "$shdw" | cut -f6 -d :) -shdw7=$(echo "$shdw" | cut -f7 -d :) -shdw8=$(echo "$shdw" | cut -f8 -d :) -shdw9=$(echo "$shdw" | cut -f9 -d :) -chmod u+w $shadow -sed -i "/^$user:*/d" $shadow -echo "$user:$MD5:$shdw3:$shdw4:$shdw5:$shdw6:$shdw7:$shdw8:$shdw9" >> $shadow -chmod u-w $shadow - -# Building directory tree -mkdir -p $HOMEDIR/$user/conf -chmod a+x $HOMEDIR/$user -chmod a+x $HOMEDIR/$user/conf -chown $user:$user $HOMEDIR/$user -chown $user:$user $HOMEDIR/$user/conf - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir -p $HOMEDIR/$user/conf/web - mkdir -p $HOMEDIR/$user/web - mkdir -p $HOMEDIR/$user/tmp - chmod 751 $HOMEDIR/$user/conf/web - chmod 751 $HOMEDIR/$user/web - chmod 771 $HOMEDIR/$user/tmp - chown $user:$user $HOMEDIR/$user/web - $BIN/v-rebuild-web-domains $user $restart -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir -p $HOMEDIR/$user/conf/dns - chmod 751 $HOMEDIR/$user/conf/dns - $BIN/v-rebuild-dns-domains $user $restart -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir -p $HOMEDIR/$user/conf/mail - mkdir -p $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/mail - chmod 751 $HOMEDIR/$user/conf/mail - $BIN/v-rebuild-mail-domains $user -fi - - -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-rebuild-databases $user -fi - -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-rebuild-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Creating configuration files and pipes -chmod 770 $USER_DATA -touch $USER_DATA/backup.conf -chmod 660 $USER_DATA/backup.conf -touch $USER_DATA/history.log -chmod 660 $USER_DATA/history.log -touch $USER_DATA/stats.log -chmod 660 $USER_DATA/stats.log - -sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe -echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe - -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - mkdir -p $USER_DATA/ssl - chmod 770 $USER_DATA/ssl - touch $USER_DATA/web.conf - chmod 660 $USER_DATA/web.conf - if [ "$(grep -w $user $VESTA/data/queue/traffic.pipe)" ]; then - echo "$BIN/v-update-web-domains-traff $user" \ - >> $VESTA/data/queue/traffic.pipe - fi - echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - mkdir -p $USER_DATA/dns - chmod 770 $USER_DATA/dns - touch $USER_DATA/dns.conf - chmod 660 $USER_DATA/dns.conf -fi - -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - mkdir -p $USER_DATA/mail - chmod 770 $USER_DATA/mail - touch $USER_DATA/mail.conf - chmod 660 $USER_DATA/mail.conf - echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - touch $USER_DATA/db.conf - chmod 660 $USER_DATA/db.conf - echo "v-update-datbases-disk $user" >> $VESTA/data/queue/disk.pipe -fi - -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - touch $USER_DATA/cron.conf - chmod 660 $USER_DATA/cron.conf -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild system user +# options: USER [RESTART] +# +# The function rebuilds system user account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# +export PATH=$PATH:/usr/sbin + +# Get user variables +source $USER_DATA/user.conf + +# Rebuild user +shell=$(chsh --list-shells | grep -w "$SHELL" |head -n1) +adduser "$user" -s "$shell" -c "$CONTACT" -m -d "$HOMEDIR/$user" &>/dev/null + +# Update password +shadow='/etc/shadow' +shdw=$(grep ^$user: $shadow) +shdw3=$(echo "$shdw" | cut -f3 -d :) +shdw4=$(echo "$shdw" | cut -f4 -d :) +shdw5=$(echo "$shdw" | cut -f5 -d :) +shdw6=$(echo "$shdw" | cut -f6 -d :) +shdw7=$(echo "$shdw" | cut -f7 -d :) +shdw8=$(echo "$shdw" | cut -f8 -d :) +shdw9=$(echo "$shdw" | cut -f9 -d :) +chmod u+w $shadow +sed -i "/^$user:*/d" $shadow +echo "$user:$MD5:$shdw3:$shdw4:$shdw5:$shdw6:$shdw7:$shdw8:$shdw9" >> $shadow +chmod u-w $shadow + +# Building directory tree +mkdir -p $HOMEDIR/$user/conf +chmod a+x $HOMEDIR/$user +chmod a+x $HOMEDIR/$user/conf +chown $user:$user $HOMEDIR/$user +chown $user:$user $HOMEDIR/$user/conf + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir -p $HOMEDIR/$user/conf/web + mkdir -p $HOMEDIR/$user/web + mkdir -p $HOMEDIR/$user/tmp + chmod 751 $HOMEDIR/$user/conf/web + chmod 751 $HOMEDIR/$user/web + chmod 771 $HOMEDIR/$user/tmp + chown $user:$user $HOMEDIR/$user/web + $BIN/v-rebuild-web-domains $user $restart +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir -p $HOMEDIR/$user/conf/dns + chmod 751 $HOMEDIR/$user/conf/dns + $BIN/v-rebuild-dns-domains $user $restart +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir -p $HOMEDIR/$user/conf/mail + mkdir -p $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/mail + chmod 751 $HOMEDIR/$user/conf/mail + $BIN/v-rebuild-mail-domains $user +fi + + +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-rebuild-databases $user +fi + +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + $BIN/v-rebuild-cron-jobs $user $restart +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Creating configuration files and pipes +chmod 770 $USER_DATA +touch $USER_DATA/backup.conf +chmod 660 $USER_DATA/backup.conf +touch $USER_DATA/history.log +chmod 660 $USER_DATA/history.log +touch $USER_DATA/stats.log +chmod 660 $USER_DATA/stats.log + +sed -i "/ $user$/d" $VESTA/data/queue/disk.pipe +echo "v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe + +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + mkdir -p $USER_DATA/ssl + chmod 770 $USER_DATA/ssl + touch $USER_DATA/web.conf + chmod 660 $USER_DATA/web.conf + if [ "$(grep -w $user $VESTA/data/queue/traffic.pipe)" ]; then + echo "$BIN/v-update-web-domains-traff $user" \ + >> $VESTA/data/queue/traffic.pipe + fi + echo "v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + mkdir -p $USER_DATA/dns + chmod 770 $USER_DATA/dns + touch $USER_DATA/dns.conf + chmod 660 $USER_DATA/dns.conf +fi + +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + mkdir -p $USER_DATA/mail + chmod 770 $USER_DATA/mail + touch $USER_DATA/mail.conf + chmod 660 $USER_DATA/mail.conf + echo "v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + touch $USER_DATA/db.conf + chmod 660 $USER_DATA/db.conf + echo "v-update-datbases-disk $user" >> $VESTA/data/queue/disk.pipe +fi + +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + touch $USER_DATA/cron.conf + chmod 660 $USER_DATA/cron.conf +fi + +# Logging +log_event "$OK" "$EVENT" + +exit ======= #!/bin/bash # info: rebuild system user diff --git a/bin/v-rebuild-web-domains b/bin/v-rebuild-web-domains index 847efb8a..9598ed10 100755 --- a/bin/v-rebuild-web-domains +++ b/bin/v-rebuild-web-domains @@ -1,312 +1,312 @@ -#!/bin/bash -# info: rebuild dns domains -# options: USER [RESTART] -# -# The function rebuilds BIND configuration files for all dns domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/ip.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -user_domains=0 -user_ssl=0 -user_aliases=0 -suspended_web=0 - -# Clean up old config -rm -f $HOMEDIR/$user/conf/tmp_*.conf - -# Defining config -conf=$USER_DATA/web.conf -fields='$DOMAIN' -nohead=1 - -# Starting loop -for domain in $(shell_list) ; do - - # Rebuilding directories - mkdir -p $HOMEDIR/$user/web/$domain \ - $HOMEDIR/$user/web/$domain/public_html \ - $HOMEDIR/$user/web/$domain/public_shtml \ - $HOMEDIR/$user/web/$domain/document_errors \ - $HOMEDIR/$user/web/$domain/cgi-bin \ - $HOMEDIR/$user/web/$domain/private \ - $HOMEDIR/$user/web/$domain/stats \ - $HOMEDIR/$user/web/$domain/logs - if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then - ln -s /var/log/httpd/domains/$domain.error.log \ - $HOMEDIR/$user/web/$domain/logs/$domain.log - fi - if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then - ln -s /var/log/httpd/domains/$domain.error.log \ - $HOMEDIR/$user/web/$domain/logs/$domain.error.log - fi - if [ -e "$WEBTPL/skel/document_errors/" ]; then - cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ - fi - - touch /var/log/httpd/domains/$domain.bytes \ - /var/log/httpd/domains/$domain.log \ - /var/log/httpd/domains/$domain.error.log - - chmod 551 $HOMEDIR/$user/web/$domain - chmod 771 $HOMEDIR/$user/web/$domain/private - chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin - chmod 771 $HOMEDIR/$user/web/$domain/public_html - chmod 771 $HOMEDIR/$user/web/$domain/public_shtml - chmod 771 $HOMEDIR/$user/web/$domain/document_errors - chmod 551 $HOMEDIR/$user/web/$domain/stats - chmod 551 $HOMEDIR/$user/web/$domain/logs - chmod 640 /var/log/httpd/domains/$domain.* - - chown $user:$user $HOMEDIR/$user/web/$domain - chown $user:$user $HOMEDIR/$user/web/$domain/private - chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin - chown $user:$user $HOMEDIR/$user/web/$domain/public_html - chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml - chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors - chown root:$user /var/log/httpd/domains/$domain.* - chown root:apache $conf - - # Parsing domain values - domain_idn=$(idn -t --quiet -a "$domain") - get_domain_values 'web' - - # Preparing domain values for the template substitution - upd_web_domain_values - - # Adding domain to the tmp_httpd.conf - tpl_file="$WEBTPL/apache_$TPL.tpl" - conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" - add_web_config - chown root:apache $conf - chmod 640 $conf - - # Running template trigger - if [ -x $WEBTPL/apache_$TPL.sh ]; then - $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot - fi - - # Checking aliases - if [ ! -z "$ALIAS" ]; then - aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) - user_aliases=$((user_aliases + aliases)) - fi - - # Checking stats - if [ ! -z "$STATS" ]; then - cat $WEBTPL/$STATS.tpl |\ - sed -e "s/%ip%/$ip/g" \ - -e "s/%web_port%/$WEB_PORT/g" \ - -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ - -e "s/%proxy_port%/$PROXY_PORT/g" \ - -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ - -e "s/%domain_idn%/$domain_idn/g" \ - -e "s/%domain%/$domain/g" \ - -e "s/%user%/$user/g" \ - -e "s/%home%/${HOMEDIR////\/}/g" \ - -e "s/%alias%/${aliases//,/ }/g" \ - -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ - > $HOMEDIR/$user/conf/web/$STATS.$domain.conf - - if [ "$STATS" == 'awstats' ]; then - if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then - ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/ - fi - fi - - webstats="$BIN/v-update-web-domain-stat $user $domain" - check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe) - if [ -z "$check_webstats" ]; then - echo "$webstats" >> $VESTA/data/queue/webstats.pipe - fi - - if [ ! -z "$STATS_USER" ]; then - # Definining statistic dir - stats_dir="$HOMEDIR/$user/web/$domain/stats" - - # Adding htaccess file - echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess - echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess - echo "AuthType Basic" >> $stats_dir/.htaccess - echo "Require valid-user" >> $stats_dir/.htaccess - - # Generating htaccess user and password - echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd - fi - fi - - # Checking ssl - if [ "$SSL" = 'yes' ]; then - # Adding domain to the shttpd.conf - conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" - tpl_file="$WEBTPL/apache_$TPL.stpl" - add_web_config - chown root:apache $conf - chmod 640 $conf - - cp -f $USER_DATA/ssl/$domain.crt \ - $HOMEDIR/$user/conf/web/ssl.$domain.crt - cp -f $USER_DATA/ssl/$domain.key \ - $HOMEDIR/$user/conf/web/ssl.$domain.key - cp -f $USER_DATA/ssl/$domain.pem \ - $HOMEDIR/$user/conf/web/ssl.$domain.pem - if [ -e "$USER_DATA/ssl/$domain.ca" ]; then - cp -f $USER_DATA/ssl/$domain.ca \ - $HOMEDIR/$user/conf/web/ssl.$domain.ca - fi - - # Running template trigger - if [ -x $WEBTPL/apache_$TPL.sh ]; then - $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot - fi - - user_ssl=$((user_ssl + 1)) - ssl_change='yes' - fi - - # Checking nginx - if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" - add_web_config - chown root:nginx $conf - chmod 640 $conf - fi - ngix_change='yes' - fi - if [ "$SUSPENDED" = 'yes' ]; then - suspended_web=$((suspended_web + 1)) - fi - user_domains=$((user_domains + 1)) - - # Checking ftp - if [ ! -z "$FTP_USER" ]; then - if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then - /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \ - -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 - - shadow='/etc/shadow' - shdw=$(grep "^$FTP_USER:" $shadow) - shdw3=$(echo "$shdw" | cut -f3 -d :) - shdw4=$(echo "$shdw" | cut -f4 -d :) - shdw5=$(echo "$shdw" | cut -f5 -d :) - shdw6=$(echo "$shdw" | cut -f6 -d :) - shdw7=$(echo "$shdw" | cut -f7 -d :) - shdw8=$(echo "$shdw" | cut -f8 -d :) - shdw9=$(echo "$shdw" | cut -f9 -d :) - chmod u+w $shadow - sed -i "/^$FTP_USER:*/d" $shadow - shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6" - shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9" - echo "$shdw_str" >> $shadow - chmod u-w $shadow - fi - fi - -done - -# Renaming tmp config -tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -if [ -e "$tmp_conf" ]; then - mv $tmp_conf $conf -fi - -# Checking include in main httpd.conf -main_conf='/etc/httpd/conf.d/vesta.conf' -main_conf_check=$(grep "$conf" $main_conf ) -if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf -fi - -# Checking ssl -if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - mv $tmp_conf $conf - - # Checking include in main httpd.conf - main_conf_check=$(grep "$conf" $main_conf ) - if [ -z "$main_conf_check" ]; then - echo "Include $conf" >>$main_conf - fi -fi - -# Checking nginx -if [ "$ngix_change" = 'yes' ]; then - nginx_conf='/etc/nginx/conf.d/vesta_users.conf' - tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - mv $tmp_conf $conf - - nginx_conf_check=$(grep "$conf" $nginx_conf ) - if [ -z "$nginx_conf_check" ]; then - echo "include $conf;" >>$nginx_conf - fi - - # Checking ssl for nginx - if [ "$ssl_change" = 'yes' ]; then - tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - mv $tmp_conf $conf - nginx_conf_check=$(grep "$conf" $nginx_conf ) - if [ -z "$nginx_conf_check" ]; then - echo "include $conf;" >>$nginx_conf - fi - fi -fi - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating counters -update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web" -update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains" -update_user_value "$user" '$U_WEB_SSL' "$user_ssl" -update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: rebuild dns domains +# options: USER [RESTART] +# +# The function rebuilds BIND configuration files for all dns domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/ip.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +user_domains=0 +user_ssl=0 +user_aliases=0 +suspended_web=0 + +# Clean up old config +rm -f $HOMEDIR/$user/conf/tmp_*.conf + +# Defining config +conf=$USER_DATA/web.conf +fields='$DOMAIN' +nohead=1 + +# Starting loop +for domain in $(shell_list) ; do + + # Rebuilding directories + mkdir -p $HOMEDIR/$user/web/$domain \ + $HOMEDIR/$user/web/$domain/public_html \ + $HOMEDIR/$user/web/$domain/public_shtml \ + $HOMEDIR/$user/web/$domain/document_errors \ + $HOMEDIR/$user/web/$domain/cgi-bin \ + $HOMEDIR/$user/web/$domain/private \ + $HOMEDIR/$user/web/$domain/stats \ + $HOMEDIR/$user/web/$domain/logs + if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.log" ]; then + ln -s /var/log/httpd/domains/$domain.error.log \ + $HOMEDIR/$user/web/$domain/logs/$domain.log + fi + if [ ! -e "$HOMEDIR/$user/web/$domain/logs/$domain.error.log" ]; then + ln -s /var/log/httpd/domains/$domain.error.log \ + $HOMEDIR/$user/web/$domain/logs/$domain.error.log + fi + if [ -e "$WEBTPL/skel/document_errors/" ]; then + cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/ + fi + + touch /var/log/httpd/domains/$domain.bytes \ + /var/log/httpd/domains/$domain.log \ + /var/log/httpd/domains/$domain.error.log + + chmod 551 $HOMEDIR/$user/web/$domain + chmod 771 $HOMEDIR/$user/web/$domain/private + chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin + chmod 771 $HOMEDIR/$user/web/$domain/public_html + chmod 771 $HOMEDIR/$user/web/$domain/public_shtml + chmod 771 $HOMEDIR/$user/web/$domain/document_errors + chmod 551 $HOMEDIR/$user/web/$domain/stats + chmod 551 $HOMEDIR/$user/web/$domain/logs + chmod 640 /var/log/httpd/domains/$domain.* + + chown $user:$user $HOMEDIR/$user/web/$domain + chown $user:$user $HOMEDIR/$user/web/$domain/private + chown $user:$user $HOMEDIR/$user/web/$domain/cgi-bin + chown $user:$user $HOMEDIR/$user/web/$domain/public_html + chown $user:$user $HOMEDIR/$user/web/$domain/public_shtml + chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors + chown root:$user /var/log/httpd/domains/$domain.* + chown root:apache $conf + + # Parsing domain values + domain_idn=$(idn -t --quiet -a "$domain") + get_domain_values 'web' + + # Preparing domain values for the template substitution + upd_web_domain_values + + # Adding domain to the tmp_httpd.conf + tpl_file="$WEBTPL/apache_$TPL.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" + add_web_config + chown root:apache $conf + chmod 640 $conf + + # Running template trigger + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot + fi + + # Checking aliases + if [ ! -z "$ALIAS" ]; then + aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) + user_aliases=$((user_aliases + aliases)) + fi + + # Checking stats + if [ ! -z "$STATS" ]; then + cat $WEBTPL/$STATS.tpl |\ + sed -e "s/%ip%/$ip/g" \ + -e "s/%web_port%/$WEB_PORT/g" \ + -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ + -e "s/%proxy_port%/$PROXY_PORT/g" \ + -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \ + -e "s/%domain_idn%/$domain_idn/g" \ + -e "s/%domain%/$domain/g" \ + -e "s/%user%/$user/g" \ + -e "s/%home%/${HOMEDIR////\/}/g" \ + -e "s/%alias%/${aliases//,/ }/g" \ + -e "s/%alias_idn%/${aliases_idn//,/ }/g" \ + > $HOMEDIR/$user/conf/web/$STATS.$domain.conf + + if [ "$STATS" == 'awstats' ]; then + if [ ! -e "/etc/awstats/$STATS.$domain.conf" ]; then + ln -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf /etc/awstats/ + fi + fi + + webstats="$BIN/v-update-web-domain-stat $user $domain" + check_webstats=$(grep "$webstats" $VESTA/data/queue/webstats.pipe) + if [ -z "$check_webstats" ]; then + echo "$webstats" >> $VESTA/data/queue/webstats.pipe + fi + + if [ ! -z "$STATS_USER" ]; then + # Definining statistic dir + stats_dir="$HOMEDIR/$user/web/$domain/stats" + + # Adding htaccess file + echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess + echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess + echo "AuthType Basic" >> $stats_dir/.htaccess + echo "Require valid-user" >> $stats_dir/.htaccess + + # Generating htaccess user and password + echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd + fi + fi + + # Checking ssl + if [ "$SSL" = 'yes' ]; then + # Adding domain to the shttpd.conf + conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + tpl_file="$WEBTPL/apache_$TPL.stpl" + add_web_config + chown root:apache $conf + chmod 640 $conf + + cp -f $USER_DATA/ssl/$domain.crt \ + $HOMEDIR/$user/conf/web/ssl.$domain.crt + cp -f $USER_DATA/ssl/$domain.key \ + $HOMEDIR/$user/conf/web/ssl.$domain.key + cp -f $USER_DATA/ssl/$domain.pem \ + $HOMEDIR/$user/conf/web/ssl.$domain.pem + if [ -e "$USER_DATA/ssl/$domain.ca" ]; then + cp -f $USER_DATA/ssl/$domain.ca \ + $HOMEDIR/$user/conf/web/ssl.$domain.ca + fi + + # Running template trigger + if [ -x $WEBTPL/apache_$TPL.sh ]; then + $WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot + fi + + user_ssl=$((user_ssl + 1)) + ssl_change='yes' + fi + + # Checking nginx + if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + add_web_config + chown root:nginx $conf + chmod 640 $conf + fi + ngix_change='yes' + fi + if [ "$SUSPENDED" = 'yes' ]; then + suspended_web=$((suspended_web + 1)) + fi + user_domains=$((user_domains + 1)) + + # Checking ftp + if [ ! -z "$FTP_USER" ]; then + if [ -z "$(grep ^$FTP_USER: /etc/passwd)" ]; then + /usr/sbin/adduser $FTP_USER -g $user -s /sbin/nologin -M \ + -d "$HOMEDIR/$user/web/$domain" > /dev/null 2>&1 + + shadow='/etc/shadow' + shdw=$(grep "^$FTP_USER:" $shadow) + shdw3=$(echo "$shdw" | cut -f3 -d :) + shdw4=$(echo "$shdw" | cut -f4 -d :) + shdw5=$(echo "$shdw" | cut -f5 -d :) + shdw6=$(echo "$shdw" | cut -f6 -d :) + shdw7=$(echo "$shdw" | cut -f7 -d :) + shdw8=$(echo "$shdw" | cut -f8 -d :) + shdw9=$(echo "$shdw" | cut -f9 -d :) + chmod u+w $shadow + sed -i "/^$FTP_USER:*/d" $shadow + shdw_str="$FTP_USER:$FTP_MD5:$shdw3:$shdw4:$shdw5:$shdw6" + shdw_str="$shdw_str:$shdw7:$shdw8:$shdw9" + echo "$shdw_str" >> $shadow + chmod u-w $shadow + fi + fi + +done + +# Renaming tmp config +tmp_conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +if [ -e "$tmp_conf" ]; then + mv $tmp_conf $conf +fi + +# Checking include in main httpd.conf +main_conf='/etc/httpd/conf.d/vesta.conf' +main_conf_check=$(grep "$conf" $main_conf ) +if [ ! -z "$domain" ] && [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf +fi + +# Checking ssl +if [ "$ssl_change" = 'yes' ]; then + tmp_conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + mv $tmp_conf $conf + + # Checking include in main httpd.conf + main_conf_check=$(grep "$conf" $main_conf ) + if [ -z "$main_conf_check" ]; then + echo "Include $conf" >>$main_conf + fi +fi + +# Checking nginx +if [ "$ngix_change" = 'yes' ]; then + nginx_conf='/etc/nginx/conf.d/vesta_users.conf' + tmp_conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + mv $tmp_conf $conf + + nginx_conf_check=$(grep "$conf" $nginx_conf ) + if [ -z "$nginx_conf_check" ]; then + echo "include $conf;" >>$nginx_conf + fi + + # Checking ssl for nginx + if [ "$ssl_change" = 'yes' ]; then + tmp_conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + mv $tmp_conf $conf + nginx_conf_check=$(grep "$conf" $nginx_conf ) + if [ -z "$nginx_conf_check" ]; then + echo "include $conf;" >>$nginx_conf + fi + fi +fi + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating counters +update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web" +update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains" +update_user_value "$user" '$U_WEB_SSL' "$user_ssl" +update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases" + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-restart-cron b/bin/v-restart-cron index be1ce97e..deac9a6a 100755 --- a/bin/v-restart-cron +++ b/bin/v-restart-cron @@ -1,37 +1,37 @@ -#!/bin/bash -# info: restart cron service -# options: NONE -# -# The function tells crond service to reread its configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing config / or just source config -if [ "$CRON_SYSTEM" = 'crond' ]; then - /etc/init.d/crond 'reload' >/dev/null 2>&1 - if [ $? -ne 0 ]; then - /etc/init.d/crond 'restart' >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart cron service +# options: NONE +# +# The function tells crond service to reread its configuration files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing config / or just source config +if [ "$CRON_SYSTEM" = 'crond' ]; then + /etc/init.d/crond 'reload' >/dev/null 2>&1 + if [ $? -ne 0 ]; then + /etc/init.d/crond 'restart' >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-dns b/bin/v-restart-dns index f4cdf7e0..e9cf4e57 100755 --- a/bin/v-restart-dns +++ b/bin/v-restart-dns @@ -1,36 +1,36 @@ -#!/bin/bash -# info: restart dns service -# options: NONE -# -# The function tells BIND service to reload dns zone files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$DNS_SYSTEM" = 'bind' ]; then - /etc/init.d/named reload >/dev/null 2>&1 - if [ $? -ne 0 ]; then - /etc/init.d/named restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart dns service +# options: NONE +# +# The function tells BIND service to reload dns zone files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$DNS_SYSTEM" = 'bind' ]; then + /etc/init.d/named reload >/dev/null 2>&1 + if [ $? -ne 0 ]; then + /etc/init.d/named restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-mail b/bin/v-restart-mail index c0217ee7..cc2a9db3 100755 --- a/bin/v-restart-mail +++ b/bin/v-restart-mail @@ -1,36 +1,36 @@ -#!/bin/bash -# info: restart mail service -# options: NONE -# -# The function tells Exim service to reload configuration files. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$MAIL_SYSTEM" = 'exim' ]; then - /etc/init.d/exim reload >/dev/null 2>&1 - if [ $? -ne 0 ]; then - /etc/init.d/exim restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart mail service +# options: NONE +# +# The function tells Exim service to reload configuration files. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$MAIL_SYSTEM" = 'exim' ]; then + /etc/init.d/exim reload >/dev/null 2>&1 + if [ $? -ne 0 ]; then + /etc/init.d/exim restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-service b/bin/v-restart-service index bd72de25..cf41b493 100755 --- a/bin/v-restart-service +++ b/bin/v-restart-service @@ -1,42 +1,42 @@ -#!/bin/bash -# info: restart service -# options: service -# -# The function restarts system service. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -service=$1 - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SERVICE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x "/etc/init.d/$service" ]; then - /etc/init.d/$service restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart service +# options: service +# +# The function restarts system service. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +service=$1 + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'SERVICE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x "/etc/init.d/$service" ]; then + /etc/init.d/$service restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restart-web b/bin/v-restart-web index d82f40e1..1c71d90b 100755 --- a/bin/v-restart-web +++ b/bin/v-restart-web @@ -1,57 +1,57 @@ -#!/bin/bash -# info: restart web services -# options: NONE -# -# The function reloads web server configuration. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ "$WEB_SYSTEM" = 'apache' ]; then - /etc/init.d/httpd status >/dev/null 2>&1 - if [ $? -eq 0 ]; then - /etc/init.d/httpd graceful >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - else - /etc/init.d/httpd start >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - fi -fi - -if [ "$PROXY_SYSTEM" = 'nginx' ]; then - /etc/init.d/nginx status >/dev/null 2>&1 - if [ $? -eq 0 ]; then - /etc/init.d/nginx reload >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - else - /etc/init.d/nginx start >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi - fi - -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: restart web services +# options: NONE +# +# The function reloads web server configuration. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ "$WEB_SYSTEM" = 'apache' ]; then + /etc/init.d/httpd status >/dev/null 2>&1 + if [ $? -eq 0 ]; then + /etc/init.d/httpd graceful >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + else + /etc/init.d/httpd start >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi +fi + +if [ "$PROXY_SYSTEM" = 'nginx' ]; then + /etc/init.d/nginx status >/dev/null 2>&1 + if [ $? -eq 0 ]; then + /etc/init.d/nginx reload >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + else + /etc/init.d/nginx start >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi + fi + +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-restore-user b/bin/v-restore-user index 3a90a300..84cc3e38 100755 --- a/bin/v-restore-user +++ b/bin/v-restore-user @@ -1,40 +1,40 @@ -#!/bin/bash -# info: restore user -# options: USER BACKUP -# -# The function for resotring user from backup. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -backup=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: restore user +# options: USER BACKUP +# +# The function for resotring user from backup. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +backup=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-search-domain-owner b/bin/v-search-domain-owner index c334888f..21ed0b09 100755 --- a/bin/v-search-domain-owner +++ b/bin/v-search-domain-owner @@ -1,55 +1,55 @@ -#!/bin/bash -# info: search domain owner -# options: DOMAIN [TYPE] -# -# The function that allows to find user objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -domain=$(idn -t --quiet -u "$1" ) -type=${2-any} - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'DOMAIN [TYPE]' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Define conf -case $type in - web) conf="$VESTA/data/users/*/web.conf" ;; - dns) conf="$VESTA/data/users/*/dns.conf" ;; - mail) conf="$VESTA/data/users/*/mail.conf" ;; - *) conf="$VESTA/data/users/*/*.conf" -esac - - -owner=$(grep "DOMAIN='$domain'" $conf | head -n 1 | cut -f7 -d '/') -if [ -z "$owner" ]; then - exit $E_NOTEXIST -fi - -echo $owner - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: search domain owner +# options: DOMAIN [TYPE] +# +# The function that allows to find user objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +domain=$(idn -t --quiet -u "$1" ) +type=${2-any} + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'DOMAIN [TYPE]' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Define conf +case $type in + web) conf="$VESTA/data/users/*/web.conf" ;; + dns) conf="$VESTA/data/users/*/dns.conf" ;; + mail) conf="$VESTA/data/users/*/mail.conf" ;; + *) conf="$VESTA/data/users/*/*.conf" +esac + + +owner=$(grep "DOMAIN='$domain'" $conf | head -n 1 | cut -f7 -d '/') +if [ -z "$owner" ]; then + exit $E_NOTEXIST +fi + +echo $owner + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-search-object b/bin/v-search-object index 61809081..7c4185ad 100755 --- a/bin/v-search-object +++ b/bin/v-search-object @@ -1,258 +1,258 @@ -#!/bin/bash -# info: search objects -# options: OBJECT [FORMAT] -# -# The function that allows to find system objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -object=$1 -format=${2-shell} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Json list function -json_list_search() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$list_data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - list_data=1 - fi - fi - done - done < $conf - if [ -n "$list_data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_search() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'OBJECT [FORMAT]' -validate_format 'object' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -conf=$(mktemp) -i=0 -OLD_IFS=$IFS -IFS=$'\n' - -# User loop -for user in $(ls $VESTA/data/users/); do - # Search query - search=$(grep "$object" \ - $VESTA/data/users/$user/web.conf \ - $VESTA/data/users/$user/dns.conf \ - $VESTA/data/users/$user/dns/*.conf \ - $VESTA/data/users/$user/mail.conf \ - $VESTA/data/users/$user/mail/*.conf \ - $VESTA/data/users/$user/db.conf \ - $VESTA/data/users/$user/cron.conf 2> /dev/null) - - for row in $search; do - # Initialise variable - key='' - result='' - dom_alias='' - suspended='' - object_link='' - object_parent='' - object_time='' - object_date='' - - # Parsing result - type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) - data=$(echo $row |cut -f 2,3,4,5 -d :) - eval "$data" - - # Check WEB domain - if [ "$type" = 'web.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - # Check domain alias - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - dom_alias=$(echo $check_alias | tr ' ' ',') - fi - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - else - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - key="DOMAIN" - result="$DOMAIN" - object_parent="$DOMAIN" - dom_alias=$(echo $check_alias | tr ' ' ',') - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - fi - - # DNS - if [ "$type" = 'dns.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DNS Records - if [ "$type" = 'dns' ]; then - if [ -n "$(echo $RECORD |grep $object)" ]; then - key="RECORD" - result="$RECORD.$DOMAIN" - suspended=$SUSPENDED - object_link=$ID - object_parent=$DOMAIN - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # MAIL - if [ "$type" = 'mail.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Mail Accounts - if [ "$type" = 'mail' ]; then - type='mail' - if [ -n "$(echo $ACCOUNT |grep $object)" ]; then - key="ACCOUNT" - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" - result="$ACCOUNT@$dom" - suspended=$SUSPENDED - object_link=$ACCOUNT - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DB - if [ "$type" = 'db.conf' ]; then - if [ -n "$(echo $DB |grep $object)" ]; then - key="DATABASE" - result="$DB" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Cron Jobs - if [ "$type" = 'cron.conf' ]; then - if [ -n "$(echo $CMD |grep $object)" ]; then - key="JOB" - result="$CMD" - suspended=$SUSPENDED - object_link=$JOB - object_parent=$JOB - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - if [ ! -z "$result" ]; then - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" - str="$str RESULT='$result' ALIAS='$dom_alias'" - str="$str LINK='$object_link' PARENT='$object_parent'" - str="$str SUSPENDED='$suspended' TIME='$object_time'" - str="$str DATE='$object_date'" - echo $str >> $conf - fi - done -done -IFS=$OLD_IFS - -# Defining fileds to select -fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' -fields="$fields \$DATE" - -# Listing domains -case $format in - json) json_list_search ;; - plain) nohead=1; shell_list_search ;; - shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; - shell_list |column -t -s '~' ;; - *) check_args '1' '0' 'OBJECT [FORMAT]' -esac - -rm $conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: search objects +# options: OBJECT [FORMAT] +# +# The function that allows to find system objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +object=$1 +format=${2-shell} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Json list function +json_list_search() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + eval $line + if [ -n "$list_data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + list_data=1 + fi + fi + done + done < $conf + if [ -n "$list_data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell list function +shell_list_search() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'OBJECT [FORMAT]' +validate_format 'object' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +conf=$(mktemp) +i=0 +OLD_IFS=$IFS +IFS=$'\n' + +# User loop +for user in $(ls $VESTA/data/users/); do + # Search query + search=$(grep "$object" \ + $VESTA/data/users/$user/web.conf \ + $VESTA/data/users/$user/dns.conf \ + $VESTA/data/users/$user/dns/*.conf \ + $VESTA/data/users/$user/mail.conf \ + $VESTA/data/users/$user/mail/*.conf \ + $VESTA/data/users/$user/db.conf \ + $VESTA/data/users/$user/cron.conf 2> /dev/null) + + for row in $search; do + # Initialise variable + key='' + result='' + dom_alias='' + suspended='' + object_link='' + object_parent='' + object_time='' + object_date='' + + # Parsing result + type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) + data=$(echo $row |cut -f 2,3,4,5 -d :) + eval "$data" + + # Check WEB domain + if [ "$type" = 'web.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + # Check domain alias + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + dom_alias=$(echo $check_alias | tr ' ' ',') + fi + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + else + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + key="DOMAIN" + result="$DOMAIN" + object_parent="$DOMAIN" + dom_alias=$(echo $check_alias | tr ' ' ',') + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + fi + + # DNS + if [ "$type" = 'dns.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DNS Records + if [ "$type" = 'dns' ]; then + if [ -n "$(echo $RECORD |grep $object)" ]; then + key="RECORD" + result="$RECORD.$DOMAIN" + suspended=$SUSPENDED + object_link=$ID + object_parent=$DOMAIN + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # MAIL + if [ "$type" = 'mail.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Mail Accounts + if [ "$type" = 'mail' ]; then + type='mail' + if [ -n "$(echo $ACCOUNT |grep $object)" ]; then + key="ACCOUNT" + dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" + result="$ACCOUNT@$dom" + suspended=$SUSPENDED + object_link=$ACCOUNT + object_parent=$dom + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DB + if [ "$type" = 'db.conf' ]; then + if [ -n "$(echo $DB |grep $object)" ]; then + key="DATABASE" + result="$DB" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Cron Jobs + if [ "$type" = 'cron.conf' ]; then + if [ -n "$(echo $CMD |grep $object)" ]; then + key="JOB" + result="$CMD" + suspended=$SUSPENDED + object_link=$JOB + object_parent=$JOB + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + if [ ! -z "$result" ]; then + type=$(echo $type|cut -f1 -d \.) + str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" + str="$str RESULT='$result' ALIAS='$dom_alias'" + str="$str LINK='$object_link' PARENT='$object_parent'" + str="$str SUSPENDED='$suspended' TIME='$object_time'" + str="$str DATE='$object_date'" + echo $str >> $conf + fi + done +done +IFS=$OLD_IFS + +# Defining fileds to select +fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' +fields="$fields \$DATE" + +# Listing domains +case $format in + json) json_list_search ;; + plain) nohead=1; shell_list_search ;; + shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; + shell_list |column -t -s '~' ;; + *) check_args '1' '0' 'OBJECT [FORMAT]' +esac + +rm $conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-search-user-object b/bin/v-search-user-object index ec95264d..86e4bbcf 100755 --- a/bin/v-search-user-object +++ b/bin/v-search-user-object @@ -1,258 +1,258 @@ -#!/bin/bash -# info: search objects -# options: USER OBJECT [FORMAT] -# -# The function that allows to find user objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -object=$2 -format=${3-shell} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Json list function -json_list_search() { - echo '{' - fileds_count=$(echo $fields| wc -w ) - while read line; do - eval $line - if [ -n "$list_data" ]; then - echo -e ' },' - fi - i=1 - IFS=' ' - for field in $fields; do - eval value=\"$field\" - value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") - if [ $i -eq 1 ]; then - (( ++i)) - echo -e "\t\"$value\": {" - else - if [ $i -lt $fileds_count ]; then - (( ++i)) - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," - else - echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" - list_data=1 - fi - fi - done - done < $conf - if [ -n "$list_data" ]; then - echo -e ' }' - fi - echo -e '}' -} - -# Shell list function -shell_list_search() { - if [ -z "$nohead" ] ; then - echo "${fields//$/}" - for a in $fields; do - echo -e "------ \c" - done - echo - fi - while read line ; do - eval $line - eval echo "$fields" | sed -e "s/%quote%/'/g" - done < $conf -} - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER OBJECT [FORMAT]' -validate_format 'user' 'object' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -conf=$(mktemp) -i=0 -OLD_IFS=$IFS -IFS=$'\n' - -# Search query -search=$(grep "$object" \ - $VESTA/data/users/$user/web.conf \ - $VESTA/data/users/$user/dns.conf \ - $VESTA/data/users/$user/dns/*.conf \ - $VESTA/data/users/$user/mail.conf \ - $VESTA/data/users/$user/mail/*.conf \ - $VESTA/data/users/$user/db.conf \ - $VESTA/data/users/$user/cron.conf 2> /dev/null) - -for row in $search; do - # Initialise variable - key='' - result='' - dom_alias='' - suspended='' - object_link='' - object_parent='' - object_time='' - object_date='' - - # Parsing result - type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) - data=$(echo $row |cut -f 2,3,4,5 -d :) - eval "$data" - - # Check WEB domain - if [ "$type" = 'web.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - # Check domain alias - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - dom_alias=$(echo $check_alias | tr ' ' ',') - fi - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - else - check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" - if [ ! -z "$check_alias" ];then - key="DOMAIN" - result="$DOMAIN" - object_parent="$DOMAIN" - dom_alias=$(echo $check_alias | tr ' ' ',') - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - fi - - # DNS - if [ "$type" = 'dns.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DNS Records - if [ "$type" = 'dns' ]; then - if [ -n "$(echo $RECORD |grep $object)" ]; then - key="RECORD" - result="$RECORD.$DOMAIN" - suspended=$SUSPENDED - object_link=$ID - object_parent=$DOMAIN - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # MAIL - if [ "$type" = 'mail.conf' ]; then - if [ -n "$(echo $DOMAIN |grep $object)" ]; then - key="DOMAIN" - result="$DOMAIN" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Mail Accounts - if [ "$type" = 'mail' ]; then - type='mail' - if [ -n "$(echo $ACCOUNT |grep $object)" ]; then - key="ACCOUNT" - dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" - result="$ACCOUNT@$dom" - suspended=$SUSPENDED - object_link=$ACCOUNT - object_parent=$dom - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # DB - if [ "$type" = 'db.conf' ]; then - if [ -n "$(echo $DB |grep $object)" ]; then - key="DATABASE" - result="$DB" - suspended=$SUSPENDED - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - # Cron Jobs - if [ "$type" = 'cron.conf' ]; then - if [ -n "$(echo $CMD |grep $object)" ]; then - key="JOB" - result="$CMD" - suspended=$SUSPENDED - object_link=$JOB - object_parent=$JOB - object_time=$TIME - object_date=$DATE - ((i ++)) - fi - fi - - if [ ! -z "$result" ]; then - type=$(echo $type|cut -f1 -d \.) - str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" - str="$str RESULT='$result' ALIAS='$dom_alias'" - str="$str LINK='$object_link' PARENT='$object_parent'" - str="$str SUSPENDED='$suspended' TIME='$object_time'" - str="$str DATE='$object_date'" - echo $str >> $conf - fi -done - -IFS=$OLD_IFS - -# Defining fileds to select -fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' -fields="$fields \$DATE" - -# Listing domains -case $format in - json) json_list_search ;; - plain) nohead=1; shell_list_search ;; - shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; - shell_list |column -t -s '~' ;; - *) check_args '2' '0' 'USER OBJECT [FORMAT]' -esac - -rm $conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: search objects +# options: USER OBJECT [FORMAT] +# +# The function that allows to find user objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +object=$2 +format=${3-shell} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Json list function +json_list_search() { + echo '{' + fileds_count=$(echo $fields| wc -w ) + while read line; do + eval $line + if [ -n "$list_data" ]; then + echo -e ' },' + fi + i=1 + IFS=' ' + for field in $fields; do + eval value=\"$field\" + value=$(echo "$value"|sed -e 's/"/\\"/g' -e "s/%quote%/'/g") + if [ $i -eq 1 ]; then + (( ++i)) + echo -e "\t\"$value\": {" + else + if [ $i -lt $fileds_count ]; then + (( ++i)) + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"," + else + echo -e "\t\t\"${field//$/}\": \"${value//,/, }\"" + list_data=1 + fi + fi + done + done < $conf + if [ -n "$list_data" ]; then + echo -e ' }' + fi + echo -e '}' +} + +# Shell list function +shell_list_search() { + if [ -z "$nohead" ] ; then + echo "${fields//$/}" + for a in $fields; do + echo -e "------ \c" + done + echo + fi + while read line ; do + eval $line + eval echo "$fields" | sed -e "s/%quote%/'/g" + done < $conf +} + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER OBJECT [FORMAT]' +validate_format 'user' 'object' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +conf=$(mktemp) +i=0 +OLD_IFS=$IFS +IFS=$'\n' + +# Search query +search=$(grep "$object" \ + $VESTA/data/users/$user/web.conf \ + $VESTA/data/users/$user/dns.conf \ + $VESTA/data/users/$user/dns/*.conf \ + $VESTA/data/users/$user/mail.conf \ + $VESTA/data/users/$user/mail/*.conf \ + $VESTA/data/users/$user/db.conf \ + $VESTA/data/users/$user/cron.conf 2> /dev/null) + +for row in $search; do + # Initialise variable + key='' + result='' + dom_alias='' + suspended='' + object_link='' + object_parent='' + object_time='' + object_date='' + + # Parsing result + type=$(echo $row |cut -f 1 -d : |cut -f 8 -d /) + data=$(echo $row |cut -f 2,3,4,5 -d :) + eval "$data" + + # Check WEB domain + if [ "$type" = 'web.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + # Check domain alias + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + dom_alias=$(echo $check_alias | tr ' ' ',') + fi + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + else + check_alias="$(echo $ALIAS| tr ',' '\n' |grep $object)" + if [ ! -z "$check_alias" ];then + key="DOMAIN" + result="$DOMAIN" + object_parent="$DOMAIN" + dom_alias=$(echo $check_alias | tr ' ' ',') + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + fi + + # DNS + if [ "$type" = 'dns.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DNS Records + if [ "$type" = 'dns' ]; then + if [ -n "$(echo $RECORD |grep $object)" ]; then + key="RECORD" + result="$RECORD.$DOMAIN" + suspended=$SUSPENDED + object_link=$ID + object_parent=$DOMAIN + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # MAIL + if [ "$type" = 'mail.conf' ]; then + if [ -n "$(echo $DOMAIN |grep $object)" ]; then + key="DOMAIN" + result="$DOMAIN" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Mail Accounts + if [ "$type" = 'mail' ]; then + type='mail' + if [ -n "$(echo $ACCOUNT |grep $object)" ]; then + key="ACCOUNT" + dom="$(echo $row|cut -f 1 -d :|cut -f 9 -d /|sed -e "s/.conf//")" + result="$ACCOUNT@$dom" + suspended=$SUSPENDED + object_link=$ACCOUNT + object_parent=$dom + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # DB + if [ "$type" = 'db.conf' ]; then + if [ -n "$(echo $DB |grep $object)" ]; then + key="DATABASE" + result="$DB" + suspended=$SUSPENDED + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + # Cron Jobs + if [ "$type" = 'cron.conf' ]; then + if [ -n "$(echo $CMD |grep $object)" ]; then + key="JOB" + result="$CMD" + suspended=$SUSPENDED + object_link=$JOB + object_parent=$JOB + object_time=$TIME + object_date=$DATE + ((i ++)) + fi + fi + + if [ ! -z "$result" ]; then + type=$(echo $type|cut -f1 -d \.) + str="ID='$i' USER='$user' TYPE='$type' KEY='$key'" + str="$str RESULT='$result' ALIAS='$dom_alias'" + str="$str LINK='$object_link' PARENT='$object_parent'" + str="$str SUSPENDED='$suspended' TIME='$object_time'" + str="$str DATE='$object_date'" + echo $str >> $conf + fi +done + +IFS=$OLD_IFS + +# Defining fileds to select +fields='$ID $USER $TYPE $KEY $RESULT $ALIAS $LINK $PARENT $SUSPENDED $TIME' +fields="$fields \$DATE" + +# Listing domains +case $format in + json) json_list_search ;; + plain) nohead=1; shell_list_search ;; + shell) fields='$USER~$TYPE~$KEY~$RESULT~$ALIAS'; + shell_list |column -t -s '~' ;; + *) check_args '2' '0' 'USER OBJECT [FORMAT]' +esac + +rm $conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-start-service b/bin/v-start-service index 47434f19..69cbfea6 100755 --- a/bin/v-start-service +++ b/bin/v-start-service @@ -1,42 +1,42 @@ -#!/bin/bash -# info: start service -# options: service -# -# The function starts system service. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -service=$1 - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SERVICE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x "/etc/init.d/$service" ]; then - /etc/init.d/$service start >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: start service +# options: service +# +# The function starts system service. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +service=$1 + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'SERVICE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x "/etc/init.d/$service" ]; then + /etc/init.d/$service start >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-stop-service b/bin/v-stop-service index 09750db4..3984a36a 100755 --- a/bin/v-stop-service +++ b/bin/v-stop-service @@ -1,42 +1,42 @@ -#!/bin/bash -# info: stop service -# options: service -# -# The function stops system service. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -service=$1 - -# Includes -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'SERVICE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -if [ -x "/etc/init.d/$service" ]; then - /etc/init.d/$service stop >/dev/null 2>&1 - if [ $? -ne 0 ]; then - exit $E_RESTART - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: stop service +# options: service +# +# The function stops system service. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +service=$1 + +# Includes +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'SERVICE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +if [ -x "/etc/init.d/$service" ]; then + /etc/init.d/$service stop >/dev/null 2>&1 + if [ $? -ne 0 ]; then + exit $E_RESTART + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-suspend-cron-job b/bin/v-suspend-cron-job index 400f095c..a9c29019 100755 --- a/bin/v-suspend-cron-job +++ b/bin/v-suspend-cron-job @@ -1,57 +1,57 @@ -#!/bin/bash -# info: suspend cron job -# options: USER JOB [RESTART] -# -# The function suspends a certain job of the cron scheduler. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -restart=$3 - -# Inlcudes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB [RESTART]' -validate_format 'user' 'job' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_unsuspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspending job -update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_CRON' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend cron job +# options: USER JOB [RESTART] +# +# The function suspends a certain job of the cron scheduler. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +restart=$3 + +# Inlcudes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB [RESTART]' +validate_format 'user' 'job' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_unsuspended 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Suspending job +update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'yes' +increase_user_value "$user" '$SUSPENDED_CRON' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-cron-jobs b/bin/v-suspend-cron-jobs index cf31c6e9..5dadc5c6 100755 --- a/bin/v-suspend-cron-jobs +++ b/bin/v-suspend-cron-jobs @@ -1,52 +1,52 @@ -#!/bin/bash -# info: Suspending sys cron jobs -# options: USER [RESTART] -# -# The function suspends all user cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspendn all jobs -for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do - $BIN/v-suspend-cron-job $user $job 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: Suspending sys cron jobs +# options: USER [RESTART] +# +# The function suspends all user cron jobs. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Suspendn all jobs +for job in $(search_objects 'cron' 'SUSPENDED' 'no' 'JOB'); do + $BIN/v-suspend-cron-job $user $job 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-database b/bin/v-suspend-database index 5145a9c0..7153182c 100755 --- a/bin/v-suspend-database +++ b/bin/v-suspend-database @@ -1,60 +1,60 @@ -#!/bin/bash -# info: suspend database -# options: USER DATABASE -# -# The function for suspending a certain user database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) suspend_mysql_database ;; - pgsql) suspend_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating db value -update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_DB' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend database +# options: USER DATABASE +# +# The function for suspending a certain user database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) suspend_mysql_database ;; + pgsql) suspend_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating db value +update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'yes' +increase_user_value "$user" '$SUSPENDED_DB' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-database-server b/bin/v-suspend-database-server index c9c8f3b6..51d3e428 100755 --- a/bin/v-suspend-database-server +++ b/bin/v-suspend-database-server @@ -1,47 +1,47 @@ -#!/bin/bash -# info: suspend database server -# options: TYPE HOST -# -# The function for suspending a database server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST' -validate_format 'type' 'host' -is_system_enabled "$DB_SYSTEM" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_object_unsuspended "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Suspend database creation on a server -update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'yes' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend database server +# options: TYPE HOST +# +# The function for suspending a database server. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST' +validate_format 'type' 'host' +is_system_enabled "$DB_SYSTEM" +is_object_valid "../../conf/$type" 'HOST' "$host" +is_object_unsuspended "../../conf/$type" 'HOST' "$host" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Suspend database creation on a server +update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'yes' + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-databases b/bin/v-suspend-databases index ef6260b3..e3ed49bb 100755 --- a/bin/v-suspend-databases +++ b/bin/v-suspend-databases @@ -1,47 +1,47 @@ -#!/bin/bash -# info: suspend databases -# options: USER -# -# The function for suspending of all databases of a single user. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-suspend-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend databases +# options: USER +# +# The function for suspending of all databases of a single user. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + $BIN/v-suspend-database "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-dns-domain b/bin/v-suspend-dns-domain index 29df2005..7f061805 100755 --- a/bin/v-suspend-dns-domain +++ b/bin/v-suspend-dns-domain @@ -1,60 +1,60 @@ -#!/bin/bash -# info: suspend dns domain -# options: USER DOMAIN [RESTART] -# -# The function suspends a certain user's domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -validate_format 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting domain from named.conf -sed -i "/\/$domain.db\"/d" /etc/named.conf - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Adding suspend in config -update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf -increase_user_value "$user" '$SUSPENDED_DNS' - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend dns domain +# options: USER DOMAIN [RESTART] +# +# The function suspends a certain user's domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting domain from named.conf +sed -i "/\/$domain.db\"/d" /etc/named.conf + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Adding suspend in config +update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' +sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/dns/$domain.conf +increase_user_value "$user" '$SUSPENDED_DNS' + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-dns-domain-record b/bin/v-suspend-dns-domain-record index 7d683cf9..bad2e6cf 100755 --- a/bin/v-suspend-dns-domain-record +++ b/bin/v-suspend-dns-domain-record @@ -1,71 +1,71 @@ -#!/bin/bash -# info: suspend dns domain record -# options: USER DOMAIN ID [RESTART] -# -# The function suspends a certain domain record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID [RESTART]' -validate_format 'user' 'domain' 'id' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" -is_object_unsuspended "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" -dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend dns domain record +# options: USER DOMAIN ID [RESTART] +# +# The function suspends a certain domain record. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ID [RESTART]' +validate_format 'user' 'domain' 'id' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" +is_object_unsuspended "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) +eval $line +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Adding record +dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" +dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='yes' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-dns-domains b/bin/v-suspend-dns-domains index 332f89b5..fa64aaed 100755 --- a/bin/v-suspend-dns-domains +++ b/bin/v-suspend-dns-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: suspend dns domains -# options: USER [RESTART] -# -# The function suspends all user's DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart dns server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend dns domains +# options: USER [RESTART] +# +# The function suspends all user's DNS domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for domain in $(search_objects 'dns' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-suspend-dns-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart dns server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-account b/bin/v-suspend-mail-account index ee3cb279..6d1f9047 100755 --- a/bin/v-suspend-mail-account +++ b/bin/v-suspend-mail-account @@ -1,60 +1,60 @@ -#!/bin/bash -# info: suspend mail account -# options: USER DOMAIN ACCOUNT -# -# The function suspends mail account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend mail account +# options: USER DOMAIN ACCOUNT +# +# The function suspends mail account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_unsuspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:SUSPENDED:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'yes' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-accounts b/bin/v-suspend-mail-accounts index 15656a5d..e0b439cc 100755 --- a/bin/v-suspend-mail-accounts +++ b/bin/v-suspend-mail-accounts @@ -1,53 +1,53 @@ -#!/bin/bash -# info: suspend all mail domain accounts -# options: USER DOMAIN -# -# The function suspends all mail domain accounts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do - $BIN/v-suspend-mail-account "$user" "$domain" "$account" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend all mail domain accounts +# options: USER DOMAIN +# +# The function suspends all mail domain accounts. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do + $BIN/v-suspend-mail-account "$user" "$domain" "$account" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-domain b/bin/v-suspend-mail-domain index 2128609e..7fdc60f2 100755 --- a/bin/v-suspend-mail-domain +++ b/bin/v-suspend-mail-domain @@ -1,58 +1,58 @@ -#!/bin/bash -# info: suspend mail domain -# options: USER DOMAIN -# -# The function suspends mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting symbolic link -rm -f /etc/exim/domains/$domain - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/mail/$domain.conf -increase_user_value "$user" '$SUSPENDED_MAIL' - - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend mail domain +# options: USER DOMAIN +# +# The function suspends mail domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting symbolic link +rm -f /etc/exim/domains/$domain + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating config +update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' +sed -i "s/SUSPENDED='no'/SUSPENDED='yes'/g" $USER_DATA/mail/$domain.conf +increase_user_value "$user" '$SUSPENDED_MAIL' + + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-mail-domains b/bin/v-suspend-mail-domains index 244c9d5e..60fba66b 100755 --- a/bin/v-suspend-mail-domains +++ b/bin/v-suspend-mail-domains @@ -1,48 +1,48 @@ -#!/bin/bash -# info: suspend mail domains -# options: USER -# -# The function suspends all user's MAIL domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend mail domains +# options: USER +# +# The function suspends all user's MAIL domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-suspend-mail-domain "$user" "$domain" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-user b/bin/v-suspend-user index 69317c17..16c9569a 100755 --- a/bin/v-suspend-user +++ b/bin/v-suspend-user @@ -1,85 +1,85 @@ -#!/bin/bash -# info: suspend user -# options: USER [RESTART] -# -# The function suspends a certain user and all his objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding '!' in front of the password -/usr/sbin/usermod --lock $user - -# Suspending web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-suspend-web-domains $user $restart -fi - -# Suspending dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-suspend-dns-domains $user $restart -fi - -# Suspending mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-suspend-mail-domains $user -fi - -# Suspending datbabases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-suspend-databases $user -fi - -# Suspending cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-suspend-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" - $BIN/v-restart-dns "$EVENT" - $BIN/v-restart-cron "$EVENT" -fi - -# Changing suspend value -update_user_value "$user" '$SUSPENDED' 'yes' -increase_user_value 'admin' '$SUSPENDED_USERS' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend user +# options: USER [RESTART] +# +# The function suspends a certain user and all his objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding '!' in front of the password +/usr/sbin/usermod --lock $user + +# Suspending web domains +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + $BIN/v-suspend-web-domains $user $restart +fi + +# Suspending dns domains +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + $BIN/v-suspend-dns-domains $user $restart +fi + +# Suspending mail domains +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + $BIN/v-suspend-mail-domains $user +fi + +# Suspending datbabases +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-suspend-databases $user +fi + +# Suspending cron jobs +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + $BIN/v-suspend-cron-jobs $user $restart +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" + $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-cron "$EVENT" +fi + +# Changing suspend value +update_user_value "$user" '$SUSPENDED' 'yes' +increase_user_value 'admin' '$SUSPENDED_USERS' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-web-domain b/bin/v-suspend-web-domain index 3e951f05..de707089 100755 --- a/bin/v-suspend-web-domain +++ b/bin/v-suspend-web-domain @@ -1,96 +1,96 @@ -#!/bin/bash -# info: suspend web domain -# options: USER DOMAIN -# -# The function for suspending the site's operation. After blocking it all -# visitors will be redirected to a web page explaining the reason of suspend. -# By blocking the site the content of all its directories remains untouched. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -SUSPENDED='yes' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Check ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' -increase_user_value "$user" '$SUSPENDED_WEB' - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend web domain +# options: USER DOMAIN +# +# The function for suspending the site's operation. After blocking it all +# visitors will be redirected to a web page explaining the reason of suspend. +# By blocking the site the content of all its directories remains untouched. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +SUSPENDED='yes' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Check ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes' +increase_user_value "$user" '$SUSPENDED_WEB' + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-suspend-web-domains b/bin/v-suspend-web-domains index 027adf5d..7fa0d83b 100755 --- a/bin/v-suspend-web-domains +++ b/bin/v-suspend-web-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: suspend web domains -# options: USER [RESTART] -# -# The function of suspending all user's sites. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting suspend loop -for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do - $BIN/v-suspend-web-domain "$user" "$domain" 'no' -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: suspend web domains +# options: USER [RESTART] +# +# The function of suspending all user's sites. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting suspend loop +for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do + $BIN/v-suspend-web-domain "$user" "$domain" 'no' +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-cron-job b/bin/v-unsuspend-cron-job index 5bca0519..23c45bba 100755 --- a/bin/v-unsuspend-cron-job +++ b/bin/v-unsuspend-cron-job @@ -1,57 +1,57 @@ -#!/bin/bash -# info: unuspend cron job -# options: USER JOB [RESTART] -# -# The function unsuspen certain cron job. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -job=$2 -restart="${3-yes}" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER JOB [RESTART]' -validate_format 'user' 'job' 'restart' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'cron' 'JOB' "$job" -is_object_suspended 'cron' 'JOB' "$job" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspending job -update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_CRON' - -# Sync system cron with user -sync_cron_jobs - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unuspend cron job +# options: USER JOB [RESTART] +# +# The function unsuspen certain cron job. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +job=$2 +restart="${3-yes}" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER JOB [RESTART]' +validate_format 'user' 'job' 'restart' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'cron' 'JOB' "$job" +is_object_suspended 'cron' 'JOB' "$job" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Unsuspending job +update_object_value 'cron' 'JOB' "$job" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_CRON' + +# Sync system cron with user +sync_cron_jobs + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-cron-jobs b/bin/v-unsuspend-cron-jobs index 05868c19..066b6d62 100755 --- a/bin/v-unsuspend-cron-jobs +++ b/bin/v-unsuspend-cron-jobs @@ -1,52 +1,52 @@ -#!/bin/bash -# info: unuspend sys cron -# options: USER [RESTART] -# -# The function unsuspends all suspended cron jobs. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspendning jobs -for job in $(search_objects 'cron' 'SUSPENDED' 'yes' 'JOB'); do - $BIN/v-unsuspend-cron-job $user $job 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart crond -if [ "$restart" != 'no' ]; then - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unuspend sys cron +# options: USER [RESTART] +# +# The function unsuspends all suspended cron jobs. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Unsuspendning jobs +for job in $(search_objects 'cron' 'SUSPENDED' 'yes' 'JOB'); do + $BIN/v-unsuspend-cron-job $user $job 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart crond +if [ "$restart" != 'no' ]; then + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-database b/bin/v-unsuspend-database index 513925bb..b6229758 100755 --- a/bin/v-unsuspend-database +++ b/bin/v-unsuspend-database @@ -1,59 +1,59 @@ -#!/bin/bash -# info: unsuspend database -# options: USER DATABASE -# -# The function for unsuspending database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_suspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) unsuspend_mysql_database ;; - pgsql) unsuspend_pgsql_database ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating db value -update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_DB' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend database +# options: USER DATABASE +# +# The function for unsuspending database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_suspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) unsuspend_mysql_database ;; + pgsql) unsuspend_pgsql_database ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating db value +update_object_value 'db' 'DB' "$database" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_DB' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-database-server b/bin/v-unsuspend-database-server index 47a3b6ff..8c98945b 100755 --- a/bin/v-unsuspend-database-server +++ b/bin/v-unsuspend-database-server @@ -1,47 +1,47 @@ -#!/bin/bash -# info: unsuspend database server -# options: TYPE HOST -# -# The function for unsuspending a database server. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -type=$1 -host=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'TYPE HOST' -validate_format 'type' 'host' -is_system_enabled "$DB_SYSTEM" -is_object_valid "../../conf/$type" 'HOST' "$host" -is_object_suspended "../../conf/$type" 'HOST' "$host" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Unsuspend database creation on a server -update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'no' - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend database server +# options: TYPE HOST +# +# The function for unsuspending a database server. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +type=$1 +host=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'TYPE HOST' +validate_format 'type' 'host' +is_system_enabled "$DB_SYSTEM" +is_object_valid "../../conf/$type" 'HOST' "$host" +is_object_suspended "../../conf/$type" 'HOST' "$host" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Unsuspend database creation on a server +update_object_value "../../conf/$type" 'HOST' "$host" '$SUSPENDED' 'no' + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-databases b/bin/v-unsuspend-databases index 2219b5d7..d036cadb 100755 --- a/bin/v-unsuspend-databases +++ b/bin/v-unsuspend-databases @@ -1,48 +1,48 @@ -#!/bin/bash -# info: unsuspend databases -# options: USER -# -# The function for unsuspending all user's databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for database in $(search_objects 'db' 'SUSPENDED' "yes" 'DB'); do - $BIN/v-unsuspend-database "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend databases +# options: USER +# +# The function for unsuspending all user's databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for database in $(search_objects 'db' 'SUSPENDED' "yes" 'DB'); do + $BIN/v-unsuspend-database "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-dns-domain b/bin/v-unsuspend-dns-domain index 1795da41..eb0cabf7 100755 --- a/bin/v-unsuspend-dns-domain +++ b/bin/v-unsuspend-dns-domain @@ -1,62 +1,62 @@ -#!/bin/bash -# info: unsuspend dns domain -# options: USER DOMAIN -# -# The function unsuspends a certain user's domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_suspended 'dns' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Adding zone in named.conf -named="zone \"$domain_idn\" {type master; file" -named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" -echo "$named" >> /etc/named.conf - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Unsuspending domain in config -update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_DNS' -sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf - - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend dns domain +# options: USER DOMAIN +# +# The function unsuspends a certain user's domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_suspended 'dns' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Adding zone in named.conf +named="zone \"$domain_idn\" {type master; file" +named="$named \"$HOMEDIR/$user/conf/dns/$domain.db\";};" +echo "$named" >> /etc/named.conf + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Unsuspending domain in config +update_object_value 'dns' 'DOMAIN' "$domain" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_DNS' +sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/dns/$domain.conf + + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-dns-domain-record b/bin/v-unsuspend-dns-domain-record index 8b4a9ab4..66e1b93c 100755 --- a/bin/v-unsuspend-dns-domain-record +++ b/bin/v-unsuspend-dns-domain-record @@ -1,70 +1,70 @@ -#!/bin/bash -# info: unsuspend dns domain record -# options: USER DOMAIN ID [RESTART] -# -# The function unsuspends a certain domain record. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -id=$3 -restart="$4" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ID [RESTART]' -validate_format 'user' 'domain' 'id' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'dns' 'DOMAIN' "$domain" -is_object_unsuspended 'dns' 'DOMAIN' "$domain" -is_object_valid "dns/$domain" 'ID' "$id" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) -eval $line -sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf - -# Adding record -dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" -dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" -echo "$dns_rec" >> $USER_DATA/dns/$domain.conf - -# Sorting records -sort_dns_records - -# Updating zone -update_domain_zone - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart named -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend dns domain record +# options: USER DOMAIN ID [RESTART] +# +# The function unsuspends a certain domain record. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +id=$3 +restart="$4" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ID [RESTART]' +validate_format 'user' 'domain' 'id' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'dns' 'DOMAIN' "$domain" +is_object_unsuspended 'dns' 'DOMAIN' "$domain" +is_object_valid "dns/$domain" 'ID' "$id" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +line=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf) +eval $line +sed -i "/^ID='$id'/d" $USER_DATA/dns/$domain.conf + +# Adding record +dns_rec="ID='$id' RECORD='$RECORD' TYPE='$TYPE' PRIORITY='$PRIORITY'" +dns_rec="$dns_rec VALUE='$VALUE' SUSPENDED='no' TIME='$TIME' DATE='$DATE'" +echo "$dns_rec" >> $USER_DATA/dns/$domain.conf + +# Sorting records +sort_dns_records + +# Updating zone +update_domain_zone + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart named +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-dns-domains b/bin/v-unsuspend-dns-domains index ae72bc8e..54173de4 100755 --- a/bin/v-unsuspend-dns-domains +++ b/bin/v-unsuspend-dns-domains @@ -1,53 +1,53 @@ -#!/bin/bash -# info: unsuspend dns domains -# options: USER [RESTART] -# -# The function unsuspends all user's DNS domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$DNS_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'dns' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-dns-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart dns server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-dns "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend dns domains +# options: USER [RESTART] +# +# The function unsuspends all user's DNS domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$DNS_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for domain in $(search_objects 'dns' 'SUSPENDED' "yes" 'DOMAIN'); do + $BIN/v-unsuspend-dns-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart dns server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-dns "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-account b/bin/v-unsuspend-mail-account index 0d6e84df..8c2179d9 100755 --- a/bin/v-unsuspend-mail-account +++ b/bin/v-unsuspend-mail-account @@ -1,61 +1,61 @@ -#!/bin/bash -# info: unsuspend mail account -# options: USER DOMAIN ACCOUNT -# -# The function unsuspends mail account. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") -account=$3 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '3' "$#" 'USER DOMAIN ACCOUNT' -validate_format 'user' 'domain' 'account' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" -is_object_valid "mail/$domain" 'ACCOUNT' "$account" -is_object_suspended "mail/$domain" 'ACCOUNT' "$account" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') -quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') -sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd -str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" -echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'no' - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend mail account +# options: USER DOMAIN ACCOUNT +# +# The function unsuspends mail account. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") +account=$3 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '3' "$#" 'USER DOMAIN ACCOUNT' +validate_format 'user' 'domain' 'account' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" +is_object_valid "mail/$domain" 'ACCOUNT' "$account" +is_object_suspended "mail/$domain" 'ACCOUNT' "$account" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +md5=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$MD5') +quota=$(get_object_value "mail/$domain" 'ACCOUNT' "$account" '$QUOTA') +sed -i "/^$account:/d" $HOMEDIR/$user/conf/mail/$domain/passwd +str="$account:$md5:$user:mail::$HOMEDIR/$user:$quota" +echo $str >> $HOMEDIR/$user/conf/mail/$domain/passwd + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value "mail/$domain" 'ACCOUNT' "$account" '$SUSPENDED' 'no' + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-accounts b/bin/v-unsuspend-mail-accounts index 2793235b..f3deb175 100755 --- a/bin/v-unsuspend-mail-accounts +++ b/bin/v-unsuspend-mail-accounts @@ -1,53 +1,53 @@ -#!/bin/bash -# info: unsuspend all mail domain accounts -# options: USER DOMAIN -# -# The function unsuspends all mail domain accounts. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for account in $(search_objects "mail/$domain" 'SUSPENDED' 'yes' 'ACCOUNT'); do - $BIN/v-unsuspend-mail-account "$user" "$domain" "$account" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend all mail domain accounts +# options: USER DOMAIN +# +# The function unsuspends all mail domain accounts. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for account in $(search_objects "mail/$domain" 'SUSPENDED' 'yes' 'ACCOUNT'); do + $BIN/v-unsuspend-mail-account "$user" "$domain" "$account" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-domain b/bin/v-unsuspend-mail-domain index 42d3f619..c6374a0d 100755 --- a/bin/v-unsuspend-mail-domain +++ b/bin/v-unsuspend-mail-domain @@ -1,57 +1,57 @@ -#!/bin/bash -# info: unsuspend mail domain -# options: USER DOMAIN -# -# The function unsuspends mail domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled 'MAIL_SYSTEM' -is_object_valid 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_suspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Add symbolic link -ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating config -update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/mail/$domain.conf -decrease_user_value "$user" '$SUSPENDED_MAIL' - - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend mail domain +# options: USER DOMAIN +# +# The function unsuspends mail domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled 'MAIL_SYSTEM' +is_object_valid 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_suspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Add symbolic link +ln -s $HOMEDIR/$user/conf/mail/$domain /etc/exim/domains/ + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating config +update_object_value 'mail' 'DOMAIN' "$domain" '$SUSPENDED' 'no' +sed -i "s/SUSPENDED='yes'/SUSPENDED='no'/g" $USER_DATA/mail/$domain.conf +decrease_user_value "$user" '$SUSPENDED_MAIL' + + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-mail-domains b/bin/v-unsuspend-mail-domains index 538f427f..08161d4f 100755 --- a/bin/v-unsuspend-mail-domains +++ b/bin/v-unsuspend-mail-domains @@ -1,48 +1,48 @@ -#!/bin/bash -# info: unsuspend mail domains -# options: USER -# -# The function unsuspends all user's MAIL domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'mail' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-mail-domain "$user" "$domain" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend mail domains +# options: USER +# +# The function unsuspends all user's MAIL domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for domain in $(search_objects 'mail' 'SUSPENDED' "yes" 'DOMAIN'); do + $BIN/v-unsuspend-mail-domain "$user" "$domain" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-user b/bin/v-unsuspend-user index 445ee222..4a0b3e14 100755 --- a/bin/v-unsuspend-user +++ b/bin/v-unsuspend-user @@ -1,83 +1,83 @@ -#!/bin/bash -# info: unsuspend user -# options: USER [RESTART] -# -# The function unsuspends user and all his objects. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" -if [ "$user" = 'admin' ]; then - exit -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Deleting '!' in front of the password -/usr/sbin/usermod --unlock $user - -# Unsuspending web domains -if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-web-domains $user $restart -fi - -# Unsuspending dns domains -if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-dns-domains $user $restart -fi - -# Unsuspending mail domains -if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-mail-domains $user -fi - -# Unsuspending datbabases -if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-databases $user -fi - -# Unsuspending cron jobs -if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then - $BIN/v-unsuspend-cron-jobs $user $restart -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Changing suspend value -update_user_value "$user" '$SUSPENDED' 'no' -decrease_user_value 'admin' '$SUSPENDED_USERS' - -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" - $BIN/v-restart-dns "$EVENT" - $BIN/v-restart-cron "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend user +# options: USER [RESTART] +# +# The function unsuspends user and all his objects. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" +if [ "$user" = 'admin' ]; then + exit +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Deleting '!' in front of the password +/usr/sbin/usermod --unlock $user + +# Unsuspending web domains +if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-web-domains $user $restart +fi + +# Unsuspending dns domains +if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-dns-domains $user $restart +fi + +# Unsuspending mail domains +if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-mail-domains $user +fi + +# Unsuspending datbabases +if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-databases $user +fi + +# Unsuspending cron jobs +if [ ! -z "$CRON_SYSTEM" ] && [ "$CRON_SYSTEM" != 'no' ]; then + $BIN/v-unsuspend-cron-jobs $user $restart +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Changing suspend value +update_user_value "$user" '$SUSPENDED' 'no' +decrease_user_value 'admin' '$SUSPENDED_USERS' + +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" + $BIN/v-restart-dns "$EVENT" + $BIN/v-restart-cron "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-web-domain b/bin/v-unsuspend-web-domain index 857d99d0..b62fa1ae 100755 --- a/bin/v-unsuspend-web-domain +++ b/bin/v-unsuspend-web-domain @@ -1,93 +1,93 @@ -#!/bin/bash -# info: unsuspend web domain -# options: USER DOMAIN -# -# The function of unsuspending the domain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") -restart="$3" - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN [RESTART]' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_suspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Parsing domain values -get_domain_values 'web' -tpl_file="$WEBTPL/apache_$TPL.tpl" -conf="$HOMEDIR/$user/conf/web/httpd.conf" -SUSPENDED='no' - -# Preparing domain values for the template substitution -upd_web_domain_values - -# Recreating vhost -del_web_config -add_web_config - -# Check ssl -if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/apache_$TPL.stpl" - conf="$HOMEDIR/$user/conf/web/shttpd.conf" - del_web_config - add_web_config -fi - -# Checking nginx -if [ ! -z "$NGINX" ]; then - tpl_file="$WEBTPL/nginx_$NGINX.tpl" - conf="$HOMEDIR/$user/conf/web/nginx.conf" - del_web_config - add_web_config - - if [ "$SSL" = 'yes' ]; then - tpl_file="$WEBTPL/nginx_$NGINX.stpl" - conf="$HOMEDIR/$user/conf/web/snginx.conf" - del_web_config - add_web_config - fi -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Update config -update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no' -decrease_user_value "$user" '$SUSPENDED_WEB' - -# Restart web erver -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend web domain +# options: USER DOMAIN +# +# The function of unsuspending the domain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") +restart="$3" + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN [RESTART]' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_suspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Parsing domain values +get_domain_values 'web' +tpl_file="$WEBTPL/apache_$TPL.tpl" +conf="$HOMEDIR/$user/conf/web/httpd.conf" +SUSPENDED='no' + +# Preparing domain values for the template substitution +upd_web_domain_values + +# Recreating vhost +del_web_config +add_web_config + +# Check ssl +if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/apache_$TPL.stpl" + conf="$HOMEDIR/$user/conf/web/shttpd.conf" + del_web_config + add_web_config +fi + +# Checking nginx +if [ ! -z "$NGINX" ]; then + tpl_file="$WEBTPL/nginx_$NGINX.tpl" + conf="$HOMEDIR/$user/conf/web/nginx.conf" + del_web_config + add_web_config + + if [ "$SSL" = 'yes' ]; then + tpl_file="$WEBTPL/nginx_$NGINX.stpl" + conf="$HOMEDIR/$user/conf/web/snginx.conf" + del_web_config + add_web_config + fi +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Update config +update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'no' +decrease_user_value "$user" '$SUSPENDED_WEB' + +# Restart web erver +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-unsuspend-web-domains b/bin/v-unsuspend-web-domains index c899ed7c..dda4a09c 100755 --- a/bin/v-unsuspend-web-domains +++ b/bin/v-unsuspend-web-domains @@ -1,54 +1,54 @@ -#!/bin/bash -# info: unsuspend web domains -# options: USER [RESTART] -# -# The function of unsuspending all user's sites. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -restart=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER [RESTART]' -validate_format 'user' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting unsuspend loop -for domain in $(search_objects 'web' 'SUSPENDED' "yes" 'DOMAIN'); do - $BIN/v-unsuspend-web-domain "$user" "$domain" 'no' -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Restart web server -if [ "$restart" != 'no' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: unsuspend web domains +# options: USER [RESTART] +# +# The function of unsuspending all user's sites. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +restart=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER [RESTART]' +validate_format 'user' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting unsuspend loop +for domain in $(search_objects 'web' 'SUSPENDED' "yes" 'DOMAIN'); do + $BIN/v-unsuspend-web-domain "$user" "$domain" 'no' +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Restart web server +if [ "$restart" != 'no' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-database-disk b/bin/v-update-database-disk index 30bd5d2b..695fb8c2 100755 --- a/bin/v-update-database-disk +++ b/bin/v-update-database-disk @@ -1,60 +1,60 @@ -#!/bin/bash -# info: update database disk usage -# options: USER DATABASE -# -# The function recalculates disk usage for speciefic database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -database=$2 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/db.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DATABASE' -validate_format 'user' 'database' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'db' 'DB' "$database" -is_object_unsuspended 'db' 'DB' "$database" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get database values -get_database_values - -# Switching on db type -case $TYPE in - mysql) get_mysql_disk_usage ;; - pgsql) get_pgsql_disk_usage ;; -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating disk usage -update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update database disk usage +# options: USER DATABASE +# +# The function recalculates disk usage for speciefic database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +database=$2 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/db.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DATABASE' +validate_format 'user' 'database' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'db' 'DB' "$database" +is_object_unsuspended 'db' 'DB' "$database" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get database values +get_database_values + +# Switching on db type +case $TYPE in + mysql) get_mysql_disk_usage ;; + pgsql) get_pgsql_disk_usage ;; +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating disk usage +update_object_value 'db' 'DB' "$database" '$U_DISK' "$usage" +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-databases-disk b/bin/v-update-databases-disk index 86fe6aba..c434be05 100755 --- a/bin/v-update-databases-disk +++ b/bin/v-update-databases-disk @@ -1,47 +1,47 @@ -#!/bin/bash -# info: update databases disk usage -# options: USER -# -# The function recalculates disk usage for all user databases. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$DB_SYSTEM" -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting update loop -for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do - $BIN/v-update-database-disk "$user" "$database" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update databases disk usage +# options: USER +# +# The function recalculates disk usage for all user databases. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$DB_SYSTEM" +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting update loop +for database in $(search_objects 'db' 'SUSPENDED' "no" 'DB'); do + $BIN/v-update-database-disk "$user" "$database" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-mail-domain-disk b/bin/v-update-mail-domain-disk index 1bac15ad..6d82aed0 100755 --- a/bin/v-update-mail-domain-disk +++ b/bin/v-update-mail-domain-disk @@ -1,64 +1,64 @@ -#!/bin/bash -# info: update mail domain disk usage -# options: USER DOMAIN -# -# The function updates domain disk usage. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain=$(echo $domain | tr '[:upper:]' '[:lower:]') -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'mail' 'DOMAIN' "$domain" -is_object_unsuspended 'mail' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting loop -dom_diks=0 -for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do - home_dir=$HOMEDIR/$user/mail/$domain/$account - if [ -e "$home_dir" ]; then - udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) - else - udisk=0 - fi - update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" - dom_diks=$((dom_diks + udisk)) -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update mail domain disk usage +# options: USER DOMAIN +# +# The function updates domain disk usage. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain=$(echo $domain | tr '[:upper:]' '[:lower:]') +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'mail' 'DOMAIN' "$domain" +is_object_unsuspended 'mail' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting loop +dom_diks=0 +for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do + home_dir=$HOMEDIR/$user/mail/$domain/$account + if [ -e "$home_dir" ]; then + udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) + else + udisk=0 + fi + update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" + dom_diks=$((dom_diks + udisk)) +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-mail-domains-disk b/bin/v-update-mail-domains-disk index 1090fc58..f711dabe 100755 --- a/bin/v-update-mail-domains-disk +++ b/bin/v-update-mail-domains-disk @@ -1,63 +1,63 @@ -#!/bin/bash -# info: calculate disk usage for all mail domains -# options: USER -# -# The function calculates disk usage for all mail domains. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_system_enabled "$MAIL_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Starting loop -for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do - dom_diks=0 - accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') - for account in $accounts; do - home_dir=$HOMEDIR/$user/mail/$domain/$account - if [ -e "$home_dir" ]; then - udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) - else - udisk=0 - fi - update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" - dom_diks=$((dom_diks + udisk)) - done - update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - - -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: calculate disk usage for all mail domains +# options: USER +# +# The function calculates disk usage for all mail domains. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_system_enabled "$MAIL_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Starting loop +for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do + dom_diks=0 + accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT') + for account in $accounts; do + home_dir=$HOMEDIR/$user/mail/$domain/$account + if [ -e "$home_dir" ]; then + udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 ) + else + udisk=0 + fi + update_object_value "mail/$domain" 'ACCOUNT' "$account" '$U_DISK' "$udisk" + dom_diks=$((dom_diks + udisk)) + done + update_object_value 'mail' 'DOMAIN' "$domain" '$U_DISK' "$dom_diks" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + + +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-ip b/bin/v-update-sys-ip index 9ced5b1f..da5bca6f 100755 --- a/bin/v-update-sys-ip +++ b/bin/v-update-sys-ip @@ -1,93 +1,93 @@ -#!/bin/bash -# info: update system ip -# options: [USER] [IP_STATUS] -# -# The function scans configured ip in the system and register them with vesta -# internal database. This call is intended for use on vps servers, where ip is -# set by hypervizor. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=${1-admin} -ip_status=${2-shared} - -# Includes -source $VESTA/conf/vesta.conf # include for internal func -source $VESTA/func/main.sh -source $VESTA/func/ip.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" '[USER] [IP_STATUS]' -validate_format 'user' 'ip_status' -is_object_valid 'user' 'USER' "$user" "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Get ip list -ip_list=$(/sbin/ifconfig | grep 'inet addr:' | cut -f 2 -d : | \ - cut -f 1 -d ' '| grep -v 127.0.0.1) - -# Get vesta registered ip list -vesta_ip_list=$(ls $VESTA/data/ips/) - -# Defining config paths -conf='/etc/httpd/conf.d/vesta.conf' -nconf='/etc/nginx/conf.d/vesta_ip.conf' -iconf='/etc/sysconfig/network-scripts/ifcfg' -rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' - -# Comparing each ip -for ip in $ip_list; do - check_ip=$(echo $vesta_ip_list | grep -w "$ip") - - # Checking ip registered - if [ -z "$check_ip" ]; then - # Parsing additional params - iface=$(/sbin/ifconfig |grep -B1 -w $ip |head -n 1 |cut -f 1 -d ' ') - interface=$(echo "$iface" | cut -f 1 -d :) - mask=$(/sbin/ifconfig |grep -w $ip |awk -F "Mask:" '{print $2}') - - # Adding vesta ip - create_vesta_ip - - # Adding namehosting support - namehost_ip_support - - # Creating startup script - if [ ! -e "$iconf-$iface" ]; then - create_vesta_ip - fi - fi - - # TBD: revers comparation -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating user conf -increase_user_value "$user" '$IP_OWNED' - -# Restart web server -if [ "$web_restart" = 'yes' ]; then - $BIN/v-restart-web "$EVENT" -fi - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update system ip +# options: [USER] [IP_STATUS] +# +# The function scans configured ip in the system and register them with vesta +# internal database. This call is intended for use on vps servers, where ip is +# set by hypervizor. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=${1-admin} +ip_status=${2-shared} + +# Includes +source $VESTA/conf/vesta.conf # include for internal func +source $VESTA/func/main.sh +source $VESTA/func/ip.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" '[USER] [IP_STATUS]' +validate_format 'user' 'ip_status' +is_object_valid 'user' 'USER' "$user" "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Get ip list +ip_list=$(/sbin/ifconfig | grep 'inet addr:' | cut -f 2 -d : | \ + cut -f 1 -d ' '| grep -v 127.0.0.1) + +# Get vesta registered ip list +vesta_ip_list=$(ls $VESTA/data/ips/) + +# Defining config paths +conf='/etc/httpd/conf.d/vesta.conf' +nconf='/etc/nginx/conf.d/vesta_ip.conf' +iconf='/etc/sysconfig/network-scripts/ifcfg' +rconf='/etc/httpd/conf.d/mod_extract_forwarded.conf' + +# Comparing each ip +for ip in $ip_list; do + check_ip=$(echo $vesta_ip_list | grep -w "$ip") + + # Checking ip registered + if [ -z "$check_ip" ]; then + # Parsing additional params + iface=$(/sbin/ifconfig |grep -B1 -w $ip |head -n 1 |cut -f 1 -d ' ') + interface=$(echo "$iface" | cut -f 1 -d :) + mask=$(/sbin/ifconfig |grep -w $ip |awk -F "Mask:" '{print $2}') + + # Adding vesta ip + create_vesta_ip + + # Adding namehosting support + namehost_ip_support + + # Creating startup script + if [ ! -e "$iconf-$iface" ]; then + create_vesta_ip + fi + fi + + # TBD: revers comparation +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating user conf +increase_user_value "$user" '$IP_OWNED' + +# Restart web server +if [ "$web_restart" = 'yes' ]; then + $BIN/v-restart-web "$EVENT" +fi + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-queue b/bin/v-update-sys-queue index 0cb530c2..04868006 100755 --- a/bin/v-update-sys-queue +++ b/bin/v-update-sys-queue @@ -1,61 +1,61 @@ -#!/bin/bash -# info: update system queue -# options: PIPE -# -# This function is responsible queue processing. Restarts of services, -# scheduled backups, web log parsing and other heavy resource consuming -# operations are handled by this script. It helps to optimize system behaviour. -# In a nutshell Apache will be restarted only once even if 10 domains are -# added or deleted. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# -# Argument defenition -queue=$1 - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Export PATH for cron -PATH=$PATH:$BIN - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'QUEUE' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining pipe functions -case $queue in - restart) bash $VESTA/data/queue/restart.pipe; - rm $VESTA/data/queue/restart.pipe; - touch $VESTA/data/queue/restart.pipe;; - webstats) bash $VESTA/data/queue/webstats.pipe > /dev/null 2>&1 ;; - backup) bash $VESTA/data/queue/backup.pipe;; - disk) bash $VESTA/data/queue/disk.pipe;; - traffic) bash $VESTA/data/queue/traffic.pipe;; - *) check_args '1' '0' 'QUEUE' -esac - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update system queue +# options: PIPE +# +# This function is responsible queue processing. Restarts of services, +# scheduled backups, web log parsing and other heavy resource consuming +# operations are handled by this script. It helps to optimize system behaviour. +# In a nutshell Apache will be restarted only once even if 10 domains are +# added or deleted. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# +# Argument defenition +queue=$1 + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Export PATH for cron +PATH=$PATH:$BIN + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'QUEUE' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining pipe functions +case $queue in + restart) bash $VESTA/data/queue/restart.pipe; + rm $VESTA/data/queue/restart.pipe; + touch $VESTA/data/queue/restart.pipe;; + webstats) bash $VESTA/data/queue/webstats.pipe > /dev/null 2>&1 ;; + backup) bash $VESTA/data/queue/backup.pipe;; + disk) bash $VESTA/data/queue/disk.pipe;; + traffic) bash $VESTA/data/queue/traffic.pipe;; + *) check_args '1' '0' 'QUEUE' +esac + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-rrd b/bin/v-update-sys-rrd index 263409fc..8b6aba36 100755 --- a/bin/v-update-sys-rrd +++ b/bin/v-update-sys-rrd @@ -1,137 +1,137 @@ -#!/bin/bash -# info: update system rrd charts -# options: NONE -# -# The script is wrapper for all rrd functions. It updates all -# v-update-sys-rrd_* at once. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Importing system enviroment as we run this script -# mostly by cron wich do not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Another workaround for cron enviroment -PATH="$PATH:$BIN" -export PATH - -# Checking rrddir -if [ ! -d "$RRD" ]; then - mkdir -p $RRD -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Checking daily period -if [ -e "$RRD/daily.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/daily.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 5 minute - if [ "$dtime" -gt '290' ]; then - touch $RRD/daily.rrd - periods="$periods daily" - fi -else - touch $RRD/daily.rrd - periods="$periods daily" -fi - -# Checking weekly period -if [ -e "$RRD/weekly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/weekly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every hour - if [ "$dtime" -gt '3590' ]; then - touch $RRD/weekly.rrd - periods="$periods weekly" - fi -else - touch $RRD/weekly.rrd - periods="$periods weekly" -fi - -# Checking monthly period -if [ -e "$RRD/monthly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/monthly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 6 hours - if [ "$dtime" -gt '21590' ]; then - touch $RRD/monthly.rrd - periods="$periods monthly" - fi -else - touch $RRD/monthly.rrd - periods="$periods monthly" -fi - -# Checking yearly period -if [ -e "$RRD/yearly.rrd" ]; then - mtime=$(stat -c "%Y" $RRD/yearly.rrd) - ctime=$(date +%s) - dtime=$((ctime - mtime)) - # Update every 12 hours - if [ "$dtime" -gt '43190' ]; then - touch $RRD/yearly.rrd - periods="$periods yearly" - fi -else - touch $RRD/yearly.rrd - periods="$periods yearly" -fi - - -# Updateing system stats -for period in $periods; do - - $BIN/v-update-sys-rrd-la $period - $BIN/v-update-sys-rrd-net $period - $BIN/v-update-sys-rrd-mem $period - $BIN/v-update-sys-rrd-ssh $period - - # Updating web stats - if [ "$WEB_SYSTEM" = 'apache' ]; then - $BIN/v-update-sys-rrd-httpd $period - fi - - if [ "$PROXY_SYSTEM" = 'nginx' ]; then - $BIN/v-update-sys-rrd-nginx $period - fi - - # Updating ftp stats - if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then - $BIN/v-update-sys-rrd-ftp $period - fi - - # Updating db stats - if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then - for type in ${DB_SYSTEM//,/ }; do - # Switching on db type - case $type in - mysql) $BIN/v-update-sys-rrd-mysql $period ;; - pgsql) $BIN/v-update-sys-rrd-pgsql $period ;; - esac - done - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# No Logging -#log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update system rrd charts +# options: NONE +# +# The script is wrapper for all rrd functions. It updates all +# v-update-sys-rrd_* at once. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Importing system enviroment as we run this script +# mostly by cron wich do not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Another workaround for cron enviroment +PATH="$PATH:$BIN" +export PATH + +# Checking rrddir +if [ ! -d "$RRD" ]; then + mkdir -p $RRD +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Checking daily period +if [ -e "$RRD/daily.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/daily.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every 5 minute + if [ "$dtime" -gt '290' ]; then + touch $RRD/daily.rrd + periods="$periods daily" + fi +else + touch $RRD/daily.rrd + periods="$periods daily" +fi + +# Checking weekly period +if [ -e "$RRD/weekly.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/weekly.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every hour + if [ "$dtime" -gt '3590' ]; then + touch $RRD/weekly.rrd + periods="$periods weekly" + fi +else + touch $RRD/weekly.rrd + periods="$periods weekly" +fi + +# Checking monthly period +if [ -e "$RRD/monthly.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/monthly.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every 6 hours + if [ "$dtime" -gt '21590' ]; then + touch $RRD/monthly.rrd + periods="$periods monthly" + fi +else + touch $RRD/monthly.rrd + periods="$periods monthly" +fi + +# Checking yearly period +if [ -e "$RRD/yearly.rrd" ]; then + mtime=$(stat -c "%Y" $RRD/yearly.rrd) + ctime=$(date +%s) + dtime=$((ctime - mtime)) + # Update every 12 hours + if [ "$dtime" -gt '43190' ]; then + touch $RRD/yearly.rrd + periods="$periods yearly" + fi +else + touch $RRD/yearly.rrd + periods="$periods yearly" +fi + + +# Updateing system stats +for period in $periods; do + + $BIN/v-update-sys-rrd-la $period + $BIN/v-update-sys-rrd-net $period + $BIN/v-update-sys-rrd-mem $period + $BIN/v-update-sys-rrd-ssh $period + + # Updating web stats + if [ "$WEB_SYSTEM" = 'apache' ]; then + $BIN/v-update-sys-rrd-httpd $period + fi + + if [ "$PROXY_SYSTEM" = 'nginx' ]; then + $BIN/v-update-sys-rrd-nginx $period + fi + + # Updating ftp stats + if [ ! -z "$FTP_SYSTEM" ] && [ "$FTP_SYSTEM" != 'no' ]; then + $BIN/v-update-sys-rrd-ftp $period + fi + + # Updating db stats + if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'no' ]; then + for type in ${DB_SYSTEM//,/ }; do + # Switching on db type + case $type in + mysql) $BIN/v-update-sys-rrd-mysql $period ;; + pgsql) $BIN/v-update-sys-rrd-pgsql $period ;; + esac + done + fi +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# No Logging +#log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-sys-rrd-ftp b/bin/v-update-sys-rrd-ftp index 270f3975..4436f282 100755 --- a/bin/v-update-sys-rrd-ftp +++ b/bin/v-update-sys-rrd-ftp @@ -1,97 +1,97 @@ -#!/bin/bash -# info: update ftp rrd -# options: PERIOD -# -# The function is for updating ftpd rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/ftp" ]; then - mkdir $RRD/ftp -fi - -# Checking database -if [ ! -e "$RRD/ftp/ftp.rrd" ]; then - # Adding database - rrdtool create $RRD/ftp/ftp.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\ - grep -v root|wc -l) - - # Updating rrd database - rrdtool update $RRD/ftp/ftp.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/ftp/$period-ftp.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/ftp/ftp.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Users " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update ftp rrd +# options: PERIOD +# +# The function is for updating ftpd rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/ftp" ]; then + mkdir $RRD/ftp +fi + +# Checking database +if [ ! -e "$RRD/ftp/ftp.rrd" ]; then + # Adding database + rrdtool create $RRD/ftp/ftp.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + a=0 + a=$(ps aux |grep $FTP_SYSTEM |grep -v grep| grep -v nobody|\ + grep -v root|wc -l) + + # Updating rrd database + rrdtool update $RRD/ftp/ftp.rrd N:$a +fi + +# Updating rrd graph +rrdtool graph $RRD/ftp/$period-ftp.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/ftp/ftp.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Users " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-httpd b/bin/v-update-sys-rrd-httpd index bc490bf5..620631c6 100755 --- a/bin/v-update-sys-rrd-httpd +++ b/bin/v-update-sys-rrd-httpd @@ -1,103 +1,103 @@ -#!/bin/bash -# info: update httpd rrd -# options: PERIOD -# -# The function is for updating apache rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/httpd.rrd" ]; then - # Adding database - rrdtool create $RRD/web/httpd.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - server_status=$(wget -qO- http://localhost:8081/server-status |\ - grep 'currently being processed'| \ - cut -f 2 -d '>' |\ - sed 's/requests currently being processed, //' | \ - cut -f 1,2 -d ' ') - active=$(echo "$server_status"|cut -f 1 -d ' ') - idle=$(echo "$server_status"|cut -f 1 -d ' ') - a=$((active + idle)) - - # Updating rrd database - rrdtool update $RRD/web/httpd.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-httpd.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/httpd.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update httpd rrd +# options: PERIOD +# +# The function is for updating apache rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + + +# Checking directory +if [ ! -d "$RRD/web" ]; then + mkdir $RRD/web +fi + +# Checking database +if [ ! -e "$RRD/web/httpd.rrd" ]; then + # Adding database + rrdtool create $RRD/web/httpd.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + server_status=$(wget -qO- http://localhost:8081/server-status |\ + grep 'currently being processed'| \ + cut -f 2 -d '>' |\ + sed 's/requests currently being processed, //' | \ + cut -f 1,2 -d ' ') + active=$(echo "$server_status"|cut -f 1 -d ' ') + idle=$(echo "$server_status"|cut -f 1 -d ' ') + a=$((active + idle)) + + # Updating rrd database + rrdtool update $RRD/web/httpd.rrd N:$a +fi + +# Updating rrd graph +rrdtool graph $RRD/web/$period-httpd.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/web/httpd.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Connections " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-la b/bin/v-update-sys-rrd-la index 371fbeb4..da63024b 100755 --- a/bin/v-update-sys-rrd-la +++ b/bin/v-update-sys-rrd-la @@ -1,103 +1,103 @@ -#!/bin/bash -# info: update load average rrd -# options: PERIOD -# -# The function is for updating load average rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/la" ]; then - mkdir $RRD/la -fi - -# Checking database -if [ ! -e "$RRD/la/la.rrd" ]; then - # Adding database - rrdtool create $RRD/la/la.rrd --step $RRD_STEP \ - DS:LA:GAUGE:600:U:U \ - DS:PR:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - loadavg=$(cat /proc/loadavg ) - la=$(echo "$loadavg"|cut -f 2 -d ' ') - pr=$(ps auxh |wc -l) - - # Updating rrd database - rrdtool update $RRD/la/la.rrd N:${la//./}:$pr -fi - -# Updating graph -rrdtool graph $RRD/la/$period-la.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Points" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#484243" \ - -c "ARROW#FFFFFF" \ - DEF:la=$RRD/la/la.rrd:LA:AVERAGE \ - DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \ - COMMENT:'\r' \ - AREA:la#C8EA2E:"LA * 100"\ - GPRINT:la:'LAST: Current\:''%8.0lf' \ - GPRINT:la:'MIN: Min\:''%8.0lf' \ - GPRINT:la:'MAX: Max\:''%8.0lf\j' \ - LINE1:pr#1c74cd:"Procs # " \ - GPRINT:pr:'LAST:Current\:''%8.0lf' \ - GPRINT:pr:'MIN:Min\:''%8.0lf' \ - GPRINT:pr:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update load average rrd +# options: PERIOD +# +# The function is for updating load average rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/la" ]; then + mkdir $RRD/la +fi + +# Checking database +if [ ! -e "$RRD/la/la.rrd" ]; then + # Adding database + rrdtool create $RRD/la/la.rrd --step $RRD_STEP \ + DS:LA:GAUGE:600:U:U \ + DS:PR:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + loadavg=$(cat /proc/loadavg ) + la=$(echo "$loadavg"|cut -f 2 -d ' ') + pr=$(ps auxh |wc -l) + + # Updating rrd database + rrdtool update $RRD/la/la.rrd N:${la//./}:$pr +fi + +# Updating graph +rrdtool graph $RRD/la/$period-la.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Points" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#484243" \ + -c "ARROW#FFFFFF" \ + DEF:la=$RRD/la/la.rrd:LA:AVERAGE \ + DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \ + COMMENT:'\r' \ + AREA:la#C8EA2E:"LA * 100"\ + GPRINT:la:'LAST: Current\:''%8.0lf' \ + GPRINT:la:'MIN: Min\:''%8.0lf' \ + GPRINT:la:'MAX: Max\:''%8.0lf\j' \ + LINE1:pr#1c74cd:"Procs # " \ + GPRINT:pr:'LAST:Current\:''%8.0lf' \ + GPRINT:pr:'MIN:Min\:''%8.0lf' \ + GPRINT:pr:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-mem b/bin/v-update-sys-rrd-mem index 0ad3bf1b..85269b82 100755 --- a/bin/v-update-sys-rrd-mem +++ b/bin/v-update-sys-rrd-mem @@ -1,103 +1,103 @@ -#!/bin/bash -# info: update memory rrd -# options: PERIOD -# -# The function is for updating memory rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/mem" ]; then - mkdir $RRD/mem -fi - -# Checking database -if [ ! -e "$RRD/mem/mem.rrd" ]; then - # Adding database - rrdtool create $RRD/mem/mem.rrd --step $RRD_STEP \ - DS:RAM:GAUGE:600:U:U \ - DS:SWAP:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - mem=$(free -m) - ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1) - swap=$(echo "$mem" |awk '{print $3}'|tail -n1) - - # Updating rrd - rrdtool update $RRD/mem/mem.rrd N:$ram:$swap -fi - -# Updating rrd graph -rrdtool graph $RRD/mem/$period-mem.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Mbytes" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:ram=$RRD/mem/mem.rrd:RAM:AVERAGE \ - DEF:swap=$RRD/mem/mem.rrd:SWAP:AVERAGE \ - COMMENT:'\r' \ - AREA:ram#867995:"RAM "\ - GPRINT:ram:'LAST: Current\:''%8.0lf' \ - GPRINT:ram:'MIN: Min\:''%8.0lf' \ - GPRINT:ram:'MAX: Max\:''%8.0lf\j' \ - LINE1:swap#f57900:"SWAP" \ - GPRINT:swap:'LAST:Current\:''%8.0lf' \ - GPRINT:swap:'MIN:Min\:''%8.0lf' \ - GPRINT:swap:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update memory rrd +# options: PERIOD +# +# The function is for updating memory rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/mem" ]; then + mkdir $RRD/mem +fi + +# Checking database +if [ ! -e "$RRD/mem/mem.rrd" ]; then + # Adding database + rrdtool create $RRD/mem/mem.rrd --step $RRD_STEP \ + DS:RAM:GAUGE:600:U:U \ + DS:SWAP:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + mem=$(free -m) + ram=$(echo "$mem" |awk '{print $3}'|head -n2 |tail -n1) + swap=$(echo "$mem" |awk '{print $3}'|tail -n1) + + # Updating rrd + rrdtool update $RRD/mem/mem.rrd N:$ram:$swap +fi + +# Updating rrd graph +rrdtool graph $RRD/mem/$period-mem.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Mbytes" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:ram=$RRD/mem/mem.rrd:RAM:AVERAGE \ + DEF:swap=$RRD/mem/mem.rrd:SWAP:AVERAGE \ + COMMENT:'\r' \ + AREA:ram#867995:"RAM "\ + GPRINT:ram:'LAST: Current\:''%8.0lf' \ + GPRINT:ram:'MIN: Min\:''%8.0lf' \ + GPRINT:ram:'MAX: Max\:''%8.0lf\j' \ + LINE1:swap#f57900:"SWAP" \ + GPRINT:swap:'LAST:Current\:''%8.0lf' \ + GPRINT:swap:'MIN:Min\:''%8.0lf' \ + GPRINT:swap:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-mysql b/bin/v-update-sys-rrd-mysql index 02a5e5d3..bc74f504 100755 --- a/bin/v-update-sys-rrd-mysql +++ b/bin/v-update-sys-rrd-mysql @@ -1,141 +1,141 @@ -#!/bin/bash -# info: update MySQL rrd -# options: PERIOD -# -# The function is for updating mysql rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/db" ]; then - mkdir $RRD/db -fi - -# Parsing db hosts -conf="$VESTA/conf/mysql.conf" -fields='$HOST' -nohead=1 -hosts=$(shell_list) -check_row=$(echo "$hosts" |wc -l) -if [ 0 -eq "$check_row" ]; then - exit -fi - -# Parsing excludes -for exclude in $(echo ${RRD_MYSQL_EXCLUDE//,/ }); do - hosts=$(echo "$hosts" |grep -vw "$exclude" ) -done - -for host in $hosts; do - # Checking database - if [ ! -e "$RRD/db/mysql_$host.rrd" ]; then - # Adding database - rrdtool create $RRD/db/mysql_$host.rrd --step $RRD_STEP \ - DS:A:COUNTER:600:U:U \ - DS:S:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - if [ "$period" = 'daily' ]; then - # Defining host credentials - host_str=$(grep "HOST='$host'" $conf) - for key in $host_str; do - eval ${key%%=*}=${key#*=} - done - sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e" - - # Checking empty vars - if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ] - then - echo "Error: config is broken" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING - fi - - # Parsing data - status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?" - if [ '0' -ne "$code" ]; then - active=0 - slow=0 - else - active=$(echo "$status"|grep 'Queries'|cut -f 2) - slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2) - fi - - # Updating rrd - rrdtool update $RRD/db/mysql_$host.rrd N:$active:$slow - fi - - # Updating daily graph - rrdtool graph $RRD/db/$period-mysql_$host.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queries" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/db/mysql_$host.rrd:A:AVERAGE \ - DEF:s=$RRD/db/mysql_$host.rrd:S:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Queries"\ - GPRINT:a:'LAST: Current\:''%8.0lf' \ - GPRINT:a:'MIN: Min\:''%8.0lf' \ - GPRINT:a:'MAX: Max\:''%8.0lf\j' \ - AREA:s#f57900:"Slow " \ - GPRINT:s:'LAST:Current\:''%8.0lf' \ - GPRINT:s:'MIN:Min\:''%8.0lf' \ - GPRINT:s:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: update MySQL rrd +# options: PERIOD +# +# The function is for updating mysql rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/db" ]; then + mkdir $RRD/db +fi + +# Parsing db hosts +conf="$VESTA/conf/mysql.conf" +fields='$HOST' +nohead=1 +hosts=$(shell_list) +check_row=$(echo "$hosts" |wc -l) +if [ 0 -eq "$check_row" ]; then + exit +fi + +# Parsing excludes +for exclude in $(echo ${RRD_MYSQL_EXCLUDE//,/ }); do + hosts=$(echo "$hosts" |grep -vw "$exclude" ) +done + +for host in $hosts; do + # Checking database + if [ ! -e "$RRD/db/mysql_$host.rrd" ]; then + # Adding database + rrdtool create $RRD/db/mysql_$host.rrd --step $RRD_STEP \ + DS:A:COUNTER:600:U:U \ + DS:S:COUNTER:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 + fi + + if [ "$period" = 'daily' ]; then + # Defining host credentials + host_str=$(grep "HOST='$host'" $conf) + for key in $host_str; do + eval ${key%%=*}=${key#*=} + done + sql="mysql -h $HOST -u $USER -p$PASSWORD -P$PORT -e" + + # Checking empty vars + if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $PORT ] + then + echo "Error: config is broken" + log_event "$E_PARSING" "$EVENT" + exit $E_PARSING + fi + + # Parsing data + status=$($sql "SHOW GLOBAL STATUS" 2>/dev/null); code="$?" + if [ '0' -ne "$code" ]; then + active=0 + slow=0 + else + active=$(echo "$status"|grep 'Queries'|cut -f 2) + slow=$(echo "$status"|grep 'Slow_queries'|cut -f 2) + fi + + # Updating rrd + rrdtool update $RRD/db/mysql_$host.rrd N:$active:$slow + fi + + # Updating daily graph + rrdtool graph $RRD/db/$period-mysql_$host.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Queries" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/db/mysql_$host.rrd:A:AVERAGE \ + DEF:s=$RRD/db/mysql_$host.rrd:S:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Queries"\ + GPRINT:a:'LAST: Current\:''%8.0lf' \ + GPRINT:a:'MIN: Min\:''%8.0lf' \ + GPRINT:a:'MAX: Max\:''%8.0lf\j' \ + AREA:s#f57900:"Slow " \ + GPRINT:s:'LAST:Current\:''%8.0lf' \ + GPRINT:s:'MIN:Min\:''%8.0lf' \ + GPRINT:s:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + if [ "$result" -ne 0 ]; then + exit $E_RRD + fi + +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-sys-rrd-net b/bin/v-update-sys-rrd-net index 83cffa2e..0c2ead68 100755 --- a/bin/v-update-sys-rrd-net +++ b/bin/v-update-sys-rrd-net @@ -1,116 +1,116 @@ -#!/bin/bash -# info: update network rrd -# options: PERIOD -# -# The function is for updating network usage rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/net" ]; then - mkdir $RRD/net -fi - -# Parsing network interfaces -ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g") - -# Parsing excludes -for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do - ifaces=$(echo "$ifaces" |grep -vw "$exclude" ) -done - -for iface in $ifaces; do - # Checking database - if [ ! -e "$RRD/net/$iface.rrd" ]; then - # Adding database - rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \ - DS:RX:COUNTER:600:U:U \ - DS:TX:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - # Parsing device stats - if [ "$period" = 'daily' ]; then - raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /") - rx=$(echo "$raw_iface" |awk '{print $2}') - tx=$(echo "$raw_iface" |awk '{print $10}') - - # Updating rrd database - rrdtool update $RRD/net/$iface.rrd N:$rx:$tx - fi - - # Updating rrd graph - rrdtool graph $RRD/net/$period-$iface.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "KBytes" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \ - DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \ - "CDEF:in=inoctets,8,*" \ - "CDEF:out=outoctets,8,*" \ - COMMENT:'\r' \ - AREA:in#C8EA2E:"Input (rx) "\ - GPRINT:in:'LAST: Current\:''%8.0lf' \ - GPRINT:in:'MIN: Min\:''%8.0lf' \ - GPRINT:in:'MAX: Max\:''%8.0lf\j' \ - LINE1:out#1c74cd:"Output (tx)" \ - GPRINT:out:'LAST:Current\:''%8.0lf' \ - GPRINT:out:'MIN:Min\:''%8.0lf' \ - GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: update network rrd +# options: PERIOD +# +# The function is for updating network usage rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/net" ]; then + mkdir $RRD/net +fi + +# Parsing network interfaces +ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g") + +# Parsing excludes +for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do + ifaces=$(echo "$ifaces" |grep -vw "$exclude" ) +done + +for iface in $ifaces; do + # Checking database + if [ ! -e "$RRD/net/$iface.rrd" ]; then + # Adding database + rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \ + DS:RX:COUNTER:600:U:U \ + DS:TX:COUNTER:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 + fi + + # Parsing device stats + if [ "$period" = 'daily' ]; then + raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /") + rx=$(echo "$raw_iface" |awk '{print $2}') + tx=$(echo "$raw_iface" |awk '{print $10}') + + # Updating rrd database + rrdtool update $RRD/net/$iface.rrd N:$rx:$tx + fi + + # Updating rrd graph + rrdtool graph $RRD/net/$period-$iface.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "KBytes" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \ + DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \ + "CDEF:in=inoctets,8,*" \ + "CDEF:out=outoctets,8,*" \ + COMMENT:'\r' \ + AREA:in#C8EA2E:"Input (rx) "\ + GPRINT:in:'LAST: Current\:''%8.0lf' \ + GPRINT:in:'MIN: Min\:''%8.0lf' \ + GPRINT:in:'MAX: Max\:''%8.0lf\j' \ + LINE1:out#1c74cd:"Output (tx)" \ + GPRINT:out:'LAST:Current\:''%8.0lf' \ + GPRINT:out:'MIN:Min\:''%8.0lf' \ + GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + if [ "$result" -ne 0 ]; then + exit $E_RRD + fi + +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-sys-rrd-nginx b/bin/v-update-sys-rrd-nginx index aeef948d..6f2664e1 100755 --- a/bin/v-update-sys-rrd-nginx +++ b/bin/v-update-sys-rrd-nginx @@ -1,95 +1,95 @@ -#!/bin/bash -# info: update nginx rrd -# options: PERIOD -# -# The function is for updating nginx rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/web" ]; then - mkdir $RRD/web -fi - -# Checking database -if [ ! -e "$RRD/web/nginx.rrd" ]; then - # Adding database - rrdtool create $RRD/web/nginx.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') - - # Updating rrd database - rrdtool update $RRD/web/nginx.rrd N:$a -fi - -# Updating rrd graph -rrdtool graph $RRD/web/$period-nginx.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/web/nginx.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Connections " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update nginx rrd +# options: PERIOD +# +# The function is for updating nginx rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/web" ]; then + mkdir $RRD/web +fi + +# Checking database +if [ ! -e "$RRD/web/nginx.rrd" ]; then + # Adding database + rrdtool create $RRD/web/nginx.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + a=$(wget -qO- http://localhost:8084/|head -n1|cut -f 3 -d ' ') + + # Updating rrd database + rrdtool update $RRD/web/nginx.rrd N:$a +fi + +# Updating rrd graph +rrdtool graph $RRD/web/$period-nginx.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/web/nginx.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Connections " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-rrd-pgsql b/bin/v-update-sys-rrd-pgsql index e5b94632..8aec1a28 100755 --- a/bin/v-update-sys-rrd-pgsql +++ b/bin/v-update-sys-rrd-pgsql @@ -1,146 +1,146 @@ -#!/bin/bash -# info: update PostgreSQL rrd -# options: PERIOD -# -# The function is for updating postgresql rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/db" ]; then - mkdir $RRD/db -fi - -# Parsing db hosts -conf="$VESTA/conf/pgsql.conf" -fields='$HOST' -nohead=1 -hosts=$(shell_list) -check_row=$(echo "$hosts" |wc -l) -if [ 0 -eq "$check_row" ]; then - exit -fi - -# Parsing excludes -for exclude in $(echo ${RRD_PGSQL_EXCLUDE//,/ }); do - hosts=$(echo "$hosts" |grep -vw "$exclude" ) -done - -for host in $hosts; do - # Checking database - if [ ! -e "$RRD/db/pgsql_$host.rrd" ]; then - # Adding database - rrdtool create $RRD/db/pgsql_$host.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - DS:T:COUNTER:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 - fi - - if [ "$period" = 'daily' ]; then - # Defining host credentials - host_str=$(grep "HOST='$host'" $conf) - for key in $host_str; do - eval ${key%%=*}=${key#*=} - done - - export PGPASSWORD="$PASSWORD" - sql="psql -h $HOST -U $USER -p $PORT -c" - - # Checking empty vars - if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ] - then - echo "Error: config is broken" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING - fi - - # Parsing data - q='SELECT SUM(xact_commit + xact_rollback), SUM(numbackends) - FROM pg_stat_database;' - status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?" - if [ '0' -ne "$code" ]; then - active=0 - slow=0 - else - active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}') - trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}') - fi - - # Updating rrd - export PGPASSWORD='pgsql' - rrdtool update $RRD/db/pgsql_$host.rrd N:$active:$trans - fi - - # Updating rrd graph - rrdtool graph $RRD/db/$period-pgsql_$host.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Queries" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/db/pgsql_$host.rrd:A:AVERAGE \ - DEF:t=$RRD/db/pgsql_$host.rrd:T:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Queries "\ - GPRINT:a:'LAST: Current\:''%8.0lf' \ - GPRINT:a:'MIN: Min\:''%8.0lf' \ - GPRINT:a:'MAX: Max\:''%8.0lf\j' \ - LINE2:t#f57900:"Transactions" \ - GPRINT:t:'LAST:Current\:''%8.0lf' \ - GPRINT:t:'MIN:Min\:''%8.0lf' \ - GPRINT:t:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - if [ "$result" -ne 0 ]; then - exit $E_RRD - fi - -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -exit +#!/bin/bash +# info: update PostgreSQL rrd +# options: PERIOD +# +# The function is for updating postgresql rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/db" ]; then + mkdir $RRD/db +fi + +# Parsing db hosts +conf="$VESTA/conf/pgsql.conf" +fields='$HOST' +nohead=1 +hosts=$(shell_list) +check_row=$(echo "$hosts" |wc -l) +if [ 0 -eq "$check_row" ]; then + exit +fi + +# Parsing excludes +for exclude in $(echo ${RRD_PGSQL_EXCLUDE//,/ }); do + hosts=$(echo "$hosts" |grep -vw "$exclude" ) +done + +for host in $hosts; do + # Checking database + if [ ! -e "$RRD/db/pgsql_$host.rrd" ]; then + # Adding database + rrdtool create $RRD/db/pgsql_$host.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + DS:T:COUNTER:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 + fi + + if [ "$period" = 'daily' ]; then + # Defining host credentials + host_str=$(grep "HOST='$host'" $conf) + for key in $host_str; do + eval ${key%%=*}=${key#*=} + done + + export PGPASSWORD="$PASSWORD" + sql="psql -h $HOST -U $USER -p $PORT -c" + + # Checking empty vars + if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ] + then + echo "Error: config is broken" + log_event "$E_PARSING" "$EVENT" + exit $E_PARSING + fi + + # Parsing data + q='SELECT SUM(xact_commit + xact_rollback), SUM(numbackends) + FROM pg_stat_database;' + status=$($sql plsql -d postgres -c "$q" 2>/dev/null); code="$?" + if [ '0' -ne "$code" ]; then + active=0 + slow=0 + else + active=$(echo "$status"|head -n 3|tail -n 1|awk '{print $3}') + trans=$(echo "$status"|head -n 3 |tail -n 1|awk '{print $1}') + fi + + # Updating rrd + export PGPASSWORD='pgsql' + rrdtool update $RRD/db/pgsql_$host.rrd N:$active:$trans + fi + + # Updating rrd graph + rrdtool graph $RRD/db/$period-pgsql_$host.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Queries" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/db/pgsql_$host.rrd:A:AVERAGE \ + DEF:t=$RRD/db/pgsql_$host.rrd:T:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Queries "\ + GPRINT:a:'LAST: Current\:''%8.0lf' \ + GPRINT:a:'MIN: Min\:''%8.0lf' \ + GPRINT:a:'MAX: Max\:''%8.0lf\j' \ + LINE2:t#f57900:"Transactions" \ + GPRINT:t:'LAST:Current\:''%8.0lf' \ + GPRINT:t:'MIN:Min\:''%8.0lf' \ + GPRINT:t:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + if [ "$result" -ne 0 ]; then + exit $E_RRD + fi + +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +exit diff --git a/bin/v-update-sys-rrd-ssh b/bin/v-update-sys-rrd-ssh index 12e67904..814f3878 100755 --- a/bin/v-update-sys-rrd-ssh +++ b/bin/v-update-sys-rrd-ssh @@ -1,96 +1,96 @@ -#!/bin/bash -# info: update ssh rrd -# options: PERIOD -# -# The function is for updating ssh rrd database and graphic. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -period=${1-daily} - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Switching on time period -case $period in - daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; - weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; - monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; - yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; - *) exit $E_RRD ;; -esac - -# Checking directory -if [ ! -d "$RRD/ssh" ]; then - mkdir $RRD/ssh -fi - -# Checking database -if [ ! -e "$RRD/ssh/ssh.rrd" ]; then - # Adding database - rrdtool create $RRD/ssh/ssh.rrd --step $RRD_STEP \ - DS:A:GAUGE:600:U:U \ - RRA:AVERAGE:0.5:1:600 \ - RRA:AVERAGE:0.5:6:700 \ - RRA:AVERAGE:0.5:24:775 \ - RRA:AVERAGE:0.5:288:797 \ - RRA:MAX:0.5:1:600 \ - RRA:MAX:0.5:6:700 \ - RRA:MAX:0.5:24:775 \ - RRA:MAX:0.5:288:797 -fi - -# Parsing data -if [ "$period" = 'daily' ]; then - a=0 - a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) - - # Updating rrd database - rrdtool update $RRD/ssh/ssh.rrd N:$a -fi - -# Updating daily graph -rrdtool graph $RRD/ssh/$period-ssh.png \ - --imgformat PNG \ - --height="120" \ - --width="440" \ - --start "$start" \ - --end "$end" \ - --vertical-label "Connections" \ - --x-grid "$grid" \ - -c "BACK#7a766d" \ - -c "SHADEA#7a766d" \ - -c "SHADEB#7a766d" \ - -c "FONT#FFFFFF" \ - -c "CANVAS#302c2d" \ - -c "GRID#666666" \ - -c "MGRID#AAAAAA" \ - -c "FRAME#302c2d" \ - -c "ARROW#FFFFFF" \ - DEF:a=$RRD/ssh/ssh.rrd:A:AVERAGE \ - COMMENT:'\r' \ - LINE1:a#fefda0:"Users " \ - GPRINT:a:'LAST:Current\:''%8.0lf' \ - GPRINT:a:'MIN:Min\:''%8.0lf' \ - GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -if [ "$result" -ne 0 ]; then - exit $E_RRD -fi - -exit +#!/bin/bash +# info: update ssh rrd +# options: PERIOD +# +# The function is for updating ssh rrd database and graphic. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +period=${1-daily} + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Switching on time period +case $period in + daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';; + weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';; + monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';; + yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';; + *) exit $E_RRD ;; +esac + +# Checking directory +if [ ! -d "$RRD/ssh" ]; then + mkdir $RRD/ssh +fi + +# Checking database +if [ ! -e "$RRD/ssh/ssh.rrd" ]; then + # Adding database + rrdtool create $RRD/ssh/ssh.rrd --step $RRD_STEP \ + DS:A:GAUGE:600:U:U \ + RRA:AVERAGE:0.5:1:600 \ + RRA:AVERAGE:0.5:6:700 \ + RRA:AVERAGE:0.5:24:775 \ + RRA:AVERAGE:0.5:288:797 \ + RRA:MAX:0.5:1:600 \ + RRA:MAX:0.5:6:700 \ + RRA:MAX:0.5:24:775 \ + RRA:MAX:0.5:288:797 +fi + +# Parsing data +if [ "$period" = 'daily' ]; then + a=0 + a=$(ps auxf|grep sshd |grep -v grep |grep -v '/usr/sbin/'| wc -l) + + # Updating rrd database + rrdtool update $RRD/ssh/ssh.rrd N:$a +fi + +# Updating daily graph +rrdtool graph $RRD/ssh/$period-ssh.png \ + --imgformat PNG \ + --height="120" \ + --width="440" \ + --start "$start" \ + --end "$end" \ + --vertical-label "Connections" \ + --x-grid "$grid" \ + -c "BACK#7a766d" \ + -c "SHADEA#7a766d" \ + -c "SHADEB#7a766d" \ + -c "FONT#FFFFFF" \ + -c "CANVAS#302c2d" \ + -c "GRID#666666" \ + -c "MGRID#AAAAAA" \ + -c "FRAME#302c2d" \ + -c "ARROW#FFFFFF" \ + DEF:a=$RRD/ssh/ssh.rrd:A:AVERAGE \ + COMMENT:'\r' \ + LINE1:a#fefda0:"Users " \ + GPRINT:a:'LAST:Current\:''%8.0lf' \ + GPRINT:a:'MIN:Min\:''%8.0lf' \ + GPRINT:a:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$? + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +if [ "$result" -ne 0 ]; then + exit $E_RRD +fi + +exit diff --git a/bin/v-update-sys-vesta b/bin/v-update-sys-vesta index 1d047d4d..788fcf57 100755 --- a/bin/v-update-sys-vesta +++ b/bin/v-update-sys-vesta @@ -1,113 +1,113 @@ -#!/bin/bash -# info: update vesta after rpm update -# options: VERSION -# -# The function is runs as rpm update trigger. It pulls shell script from vesta -# server and runs it. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -version=$1 -updates='' - -# Importing system enviroment -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -# Checking arg number -check_args '1' "$#" 'VERSION' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Compare versions -if [ "$version" != "$VERSION" ]; then - # Downloading version tree - upd_host="yum.vestacp.com" - wget -O "/tmp/versions" http://$V_UPD_HOST/upd_scripts/version_tree.txt \ - &>/dev/null - - # Checking download result - if [ "$?" -ne "0" ]; then - echo "Error: version tree update failed" - log_event "$E_UPDATE" "$EVENT" - exit $E_UPDATE - fi - - # Deviding version - v1=$(echo "$version" |cut -f 1 -d '.') - v2=$(echo "$version" |cut -f 2 -d '.') - v3=$(echo "$version" |cut -f 3 -d '.') - V1=$(echo "$VERSION" |cut -f 1 -d '.') - V2=$(echo "$VERSION" |cut -f 2 -d '.') - V3=$(echo "$VERSION" |cut -f 3 -d '.') - - - # Checking difference between versions - # Too nested tests, sory about complexity - if [ "$V1" -lt "$v1" ]; then - for ver in $(seq $V1 $v1); do - updates="$updates $(grep "^$ver." /tmp/versions|grep ":1$"|\ - cut -f 1 -d :)" - done - else - if [ "$V2" -lt "$v2" ]; then - for ver in $(seq $V2 $v2); do - updates="$updates $(grep "^$v1.$ver." /tmp/versions |\ - grep ":1$"|cut -f 1 -d :)" - done - else - V4=$((V3 + 1)) - for ver in $(seq $V4 $v3); do - updates="$updates $(grep "^$v1.$v2.$ver" /tmp/versions |\ - grep ":1$"|cut -f 1 -d :)" - done - fi - fi - - # Executing update scripts - if [ ! -z "$updates" ]; then - mkdir $BIN/updates &>/dev/null - - for update in $updates; do - wget -O $BIN/updates/$update.sh \ - http://$V_UPD_HOST/upd_scripts/$update.sh &>/dev/null - - # Checking download result - if [ "$?" -ne "0" ]; then - echo "Error: version tree update failed" - log_event "$E_UPDATE" "$EVENT" - exit $E_UPDATE - fi - bash $BIN/updates/$update.sh - done - rm -rf $BIN/updates - fi - - # Updating config version - sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $VESTA/conf/vesta.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update vesta after rpm update +# options: VERSION +# +# The function is runs as rpm update trigger. It pulls shell script from vesta +# server and runs it. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +version=$1 +updates='' + +# Importing system enviroment +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +# Checking arg number +check_args '1' "$#" 'VERSION' + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Compare versions +if [ "$version" != "$VERSION" ]; then + # Downloading version tree + upd_host="yum.vestacp.com" + wget -O "/tmp/versions" http://$V_UPD_HOST/upd_scripts/version_tree.txt \ + &>/dev/null + + # Checking download result + if [ "$?" -ne "0" ]; then + echo "Error: version tree update failed" + log_event "$E_UPDATE" "$EVENT" + exit $E_UPDATE + fi + + # Deviding version + v1=$(echo "$version" |cut -f 1 -d '.') + v2=$(echo "$version" |cut -f 2 -d '.') + v3=$(echo "$version" |cut -f 3 -d '.') + V1=$(echo "$VERSION" |cut -f 1 -d '.') + V2=$(echo "$VERSION" |cut -f 2 -d '.') + V3=$(echo "$VERSION" |cut -f 3 -d '.') + + + # Checking difference between versions + # Too nested tests, sory about complexity + if [ "$V1" -lt "$v1" ]; then + for ver in $(seq $V1 $v1); do + updates="$updates $(grep "^$ver." /tmp/versions|grep ":1$"|\ + cut -f 1 -d :)" + done + else + if [ "$V2" -lt "$v2" ]; then + for ver in $(seq $V2 $v2); do + updates="$updates $(grep "^$v1.$ver." /tmp/versions |\ + grep ":1$"|cut -f 1 -d :)" + done + else + V4=$((V3 + 1)) + for ver in $(seq $V4 $v3); do + updates="$updates $(grep "^$v1.$v2.$ver" /tmp/versions |\ + grep ":1$"|cut -f 1 -d :)" + done + fi + fi + + # Executing update scripts + if [ ! -z "$updates" ]; then + mkdir $BIN/updates &>/dev/null + + for update in $updates; do + wget -O $BIN/updates/$update.sh \ + http://$V_UPD_HOST/upd_scripts/$update.sh &>/dev/null + + # Checking download result + if [ "$?" -ne "0" ]; then + echo "Error: version tree update failed" + log_event "$E_UPDATE" "$EVENT" + exit $E_UPDATE + fi + bash $BIN/updates/$update.sh + done + rm -rf $BIN/updates + fi + + # Updating config version + sed -i "s/VERSION='$VERSION'/VERSION='$version'/g" $VESTA/conf/vesta.conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-backups b/bin/v-update-user-backups index 9aad7140..3604ae5b 100755 --- a/bin/v-update-user-backups +++ b/bin/v-update-user-backups @@ -1,278 +1,278 @@ -#!/bin/bash -# info: update user backups -# options: USER -# -# The function rescan backup directory and updates backup database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - -# Argument defenition -user=$1 -type="${2-$BACKUP_SYSTEM}" - -# Defining tar parser function -get_backup_info() { - backup=$1 - backup_type="$2" - - backup_name=$(basename $backup ) - backup_date=$(echo $backup_name |cut -f 2 -d '.' ) - backup_time=$(stat --printf=%y $backup |cut -f 2 -d ' ' |cut -f 1 -d '.') - backup_size=$(du -sm $backup |cut -f 1 ) - backup_data=$(tar -tf $backup) - - vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$") - if [ -z "$vst_data" ]; then - vst='' - else - vst='yes' - fi - - pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$") - if [ -z "$pam_data" ]; then - pam='' - else - pam='yes' - fi - - web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort) - if [ -z "$web_data" ]; then - web='' - else - i=1 - for domain in $web_data; do - domain="$(basename $domain|sed -e 's/.tar.gz$//')" - if [ "$i" -eq 1 ]; then - web="$domain" - i=2 - else - web="$web,$domain" - fi - done - fi - - dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort) - if [ -z "$dns_data" ]; then - dns='' - else - i=1 - for domain in $dns_data; do - domain="$(basename $domain|sed -e 's/.db$//')" - if [ "$i" -eq 1 ]; then - dns="$domain" - i=2 - else - dns="$dns,$domain" - fi - done - fi - - mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort) - if [ -z "$mail_data" ]; then - ml='' - else - i=1 - for domain in $mail_data; do - domain="$(basename $domain|sed -e 's/.tar.gz$//')" - if [ "$i" -eq 1 ]; then - ml="$domain" - i=2 - else - ml="$ml,$domain" - fi - done - fi - - db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort) - if [ -z "$db_data" ]; then - db='' - else - i=1 - for dbase in $db_data; do - dbase=$(basename $dbase|sed -e "s/.\(my\|pg\)sql.sql.gz$//") - if [ "$i" -eq 1 ]; then - db="$dbase" - i=2 - else - db="$db,$dbase" - fi - done - fi - - ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort) - if [ -z "$ssl_data" ]; then - ssl='' - else - i=1 - for certificate in $ssl_data; do - certificate="$(basename $certificate|sed -e "s/.crt$//")" - if [ "$i" -eq 1 ]; then - ssl="$certificate" - i=2 - else - ssl="$ssl,$certificate" - fi - done - fi - - cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$") - if [ -z "$cron_data" ]; then - cron='' - else - cron='yes' - fi - - echo -n "DATE='$backup_date' TIME='$backup_time' RUNTIME='0'" - echo -n " SIZE='$backup_size' TYPE='$backup_type' VESTA='$vst' PAM='$pam'" - echo " WEB='$web' DNS='$dns' MAIL='$ml' DB='$db' SSL='$ssl' CRON='$cron'" -} - -# Defining ftp command function -ftpc() { - ftp -n $HOST $PORT <> $tmp_file - done -fi - -# Checking ftp -if [ "$type" = 'ftp' ]; then - tmpdir=$(mktemp -p $BACKUP -d) - ftmpdir=$(basename $tmpdir) - init_ftp_variables - check_ftp_connection - backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") - - for backup in $backups; do - cd $tmpdir - if [ ! -z "$(ftpc "get $backup")" ]; then - echo "Error: FTP transfer error" - log_event "$E_FTP" "$EVENT" - exit $E_FTP - fi - get_backup_info $tmpdir/$backup $type >> $tmp_file - rm -f $tmpdir/$backup - done - rm -rf $tmpdir -fi - -# Checking both local and ftp -if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then - - tmpdir=$(mktemp -p $BACKUP -d) - ftmpdir=$(basename $tmpdir) - init_ftp_variables - check_ftp_connection - ftp_backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") - local_backups=$(ls $BACKUP/ |grep "^$user." |sort) - backups=$(echo -e "$local_backups\n$ftp_backups" |\ - sort |uniq -c | awk '{print $1" "$2}') - - for backup in $(echo "$backups"|grep "^1 "|cut -f 2 -d ' '); do - check_ftp=$(echo $ftp_backups|grep -w $backup) - if [ ! -z "$check_ftp" ]; then - cd $tmpdir - if [ ! -z "$(ftpc "get $backup")" ]; then - echo "Error: FTP transfer error" - log_event "$E_FTP" "$EVENT" - exit $E_FTP - fi - get_backup_info $tmpdir/$backup ftp >> $tmp_file - rm -f $tmpdir/$backup - else - get_backup_info $BACKUP/$backup local >> $tmp_file - fi - done - - for backup in $(echo "$backups"|grep "^2 "|cut -f 2 -d ' '); do - get_backup_info $BACKUP/$backup $type >> $tmp_file - done - rm -rf $tmpdir -fi - -# Checking if there was any output -if [ -e "$tmp_file" ]; then - cat $tmp_file | sort > $USER_DATA/backup.conf - rm $tmp_file -else - rm $USER_DATA/backup.conf - touch $USER_DATA/backup.conf -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user backups +# options: USER +# +# The function rescan backup directory and updates backup database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + +# Argument defenition +user=$1 +type="${2-$BACKUP_SYSTEM}" + +# Defining tar parser function +get_backup_info() { + backup=$1 + backup_type="$2" + + backup_name=$(basename $backup ) + backup_date=$(echo $backup_name |cut -f 2 -d '.' ) + backup_time=$(stat --printf=%y $backup |cut -f 2 -d ' ' |cut -f 1 -d '.') + backup_size=$(du -sm $backup |cut -f 1 ) + backup_data=$(tar -tf $backup) + + vst_data=$(echo "$backup_data" |grep "^./vesta/" |grep -v "^./vesta/$") + if [ -z "$vst_data" ]; then + vst='' + else + vst='yes' + fi + + pam_data=$(echo "$backup_data" |grep "^./pam/" |grep -v "^./pam/$") + if [ -z "$pam_data" ]; then + pam='' + else + pam='yes' + fi + + web_data=$(echo "$backup_data" |grep "^./web/" |grep -v "^./web/$" |sort) + if [ -z "$web_data" ]; then + web='' + else + i=1 + for domain in $web_data; do + domain="$(basename $domain|sed -e 's/.tar.gz$//')" + if [ "$i" -eq 1 ]; then + web="$domain" + i=2 + else + web="$web,$domain" + fi + done + fi + + dns_data=$(echo "$backup_data" |grep "^./dns/" |grep ".db$" |sort) + if [ -z "$dns_data" ]; then + dns='' + else + i=1 + for domain in $dns_data; do + domain="$(basename $domain|sed -e 's/.db$//')" + if [ "$i" -eq 1 ]; then + dns="$domain" + i=2 + else + dns="$dns,$domain" + fi + done + fi + + mail_data=$(echo "$backup_data"|grep "^./mail/"|grep -v "^./mail/$"|sort) + if [ -z "$mail_data" ]; then + ml='' + else + i=1 + for domain in $mail_data; do + domain="$(basename $domain|sed -e 's/.tar.gz$//')" + if [ "$i" -eq 1 ]; then + ml="$domain" + i=2 + else + ml="$ml,$domain" + fi + done + fi + + db_data=$(echo "$backup_data"|grep "^./db/"|grep ".sql.gz$"|sort) + if [ -z "$db_data" ]; then + db='' + else + i=1 + for dbase in $db_data; do + dbase=$(basename $dbase|sed -e "s/.\(my\|pg\)sql.sql.gz$//") + if [ "$i" -eq 1 ]; then + db="$dbase" + i=2 + else + db="$db,$dbase" + fi + done + fi + + ssl_data=$(echo "$backup_data"|grep "^./ssl/"|grep ".crt$"|sort) + if [ -z "$ssl_data" ]; then + ssl='' + else + i=1 + for certificate in $ssl_data; do + certificate="$(basename $certificate|sed -e "s/.crt$//")" + if [ "$i" -eq 1 ]; then + ssl="$certificate" + i=2 + else + ssl="$ssl,$certificate" + fi + done + fi + + cron_data=$(echo "$backup_data" |grep "^./cron/" |grep -v "^./cron/$") + if [ -z "$cron_data" ]; then + cron='' + else + cron='yes' + fi + + echo -n "DATE='$backup_date' TIME='$backup_time' RUNTIME='0'" + echo -n " SIZE='$backup_size' TYPE='$backup_type' VESTA='$vst' PAM='$pam'" + echo " WEB='$web' DNS='$dns' MAIL='$ml' DB='$db' SSL='$ssl' CRON='$cron'" +} + +# Defining ftp command function +ftpc() { + ftp -n $HOST $PORT <> $tmp_file + done +fi + +# Checking ftp +if [ "$type" = 'ftp' ]; then + tmpdir=$(mktemp -p $BACKUP -d) + ftmpdir=$(basename $tmpdir) + init_ftp_variables + check_ftp_connection + backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") + + for backup in $backups; do + cd $tmpdir + if [ ! -z "$(ftpc "get $backup")" ]; then + echo "Error: FTP transfer error" + log_event "$E_FTP" "$EVENT" + exit $E_FTP + fi + get_backup_info $tmpdir/$backup $type >> $tmp_file + rm -f $tmpdir/$backup + done + rm -rf $tmpdir +fi + +# Checking both local and ftp +if [ "$type" = 'ftp,local' ] || [ "$type" = 'local,ftp' ]; then + + tmpdir=$(mktemp -p $BACKUP -d) + ftmpdir=$(basename $tmpdir) + init_ftp_variables + check_ftp_connection + ftp_backups=$(ftpc ls|awk '{print $9}'|grep "^$user.") + local_backups=$(ls $BACKUP/ |grep "^$user." |sort) + backups=$(echo -e "$local_backups\n$ftp_backups" |\ + sort |uniq -c | awk '{print $1" "$2}') + + for backup in $(echo "$backups"|grep "^1 "|cut -f 2 -d ' '); do + check_ftp=$(echo $ftp_backups|grep -w $backup) + if [ ! -z "$check_ftp" ]; then + cd $tmpdir + if [ ! -z "$(ftpc "get $backup")" ]; then + echo "Error: FTP transfer error" + log_event "$E_FTP" "$EVENT" + exit $E_FTP + fi + get_backup_info $tmpdir/$backup ftp >> $tmp_file + rm -f $tmpdir/$backup + else + get_backup_info $BACKUP/$backup local >> $tmp_file + fi + done + + for backup in $(echo "$backups"|grep "^2 "|cut -f 2 -d ' '); do + get_backup_info $BACKUP/$backup $type >> $tmp_file + done + rm -rf $tmpdir +fi + +# Checking if there was any output +if [ -e "$tmp_file" ]; then + cat $tmp_file | sort > $USER_DATA/backup.conf + rm $tmp_file +else + rm $USER_DATA/backup.conf + touch $USER_DATA/backup.conf +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-counters b/bin/v-update-user-counters index 4dde41a1..e81db53b 100755 --- a/bin/v-update-user-counters +++ b/bin/v-update-user-counters @@ -1,214 +1,214 @@ -#!/bin/bash -# info: update user usage counters -# options: USER -# -# Function updates usage counters like U_WEB_DOMAINS, U_MAIL_ACCOUNTS, etc. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'USER' -if [ ! -z "$user" ]; then - validate_format 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(ls $VESTA/data/users) -else - user_list="$user" -fi - -# Updating user stats -for user in $user_list; do - USER_DATA=$VESTA/data/users/$user - # Cleaning counters - SUSPENDED_USERS=0 - SUSPENDED_WEB=0 - SUSPENDED_DNS=0 - SUSPENDED_MAIL=0 - SUSPENDED_DB=0 - SUSPENDED_CRON=0 - IP_AVAIL=0 - IP_OWNED=0 - U_USERS=0 - U_DISK=0 - U_DISK_DIRS=$(get_user_value '$U_DISK_DIRS') - if [ -z "$U_DISK_DIRS" ]; then - U_DISK_DIRS=0 - fi - DISK=$((DISK + U_DISK_DIRS)) - U_DISK_WEB=0 - U_DISK_MAIL=0 - U_DISK_DB=0 - BANDWIDTH=0 - U_BANDWIDTH=0 - U_WEB_DOMAINS=0 - U_WEB_SSL=0 - U_WEB_ALIASES=0 - U_DNS_DOMAINS=0 - U_DNS_RECORDS=0 - U_MAIL_DOMAINS=0 - U_MAIL_DKIM=0 - U_MAIL_ACCOUNTS=0 - U_DATABASES=0 - U_CRON_JOBS=0 - U_BACKUPS=0 - - # New IFS - IFS=$'\n' - - # Checking users - if [ "$user" = 'admin' ]; then - SUSPENDED_USERS=$(grep "SUSPENDED='yes'" $VESTA/data/users/*/user.conf) - SUSPENDED_USERS=$(echo "$SUSPENDED_USERS" |wc -l) - U_USERS=$(ls $VESTA/data/users/|wc -l) - fi - - # Checking ip - for ip in $(ls $VESTA/data/ips) ;do - source $VESTA/data/ips/$ip - if [ "$OWNER" = "$user" ]; then - IP_OWNED=$((IP_OWNED + 1)) - IP_AVAIL=$((IP_AVAIL + 1)) - fi - if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then - IP_AVAIL=$((IP_AVAIL + 1)) - fi - done - if [ "$user" = 'admin' ]; then - IP_AVAIL=$(ls $VESTA/data/ips | wc -l) - fi - - # Checking web system - U_WEB_DOMAINS=0 - for domain_str in $(cat $USER_DATA/web.conf) ;do - eval $domain_str - U_DISK_WEB=$((U_DISK_WEB + U_DISK)) - U_WEB_DOMAINS=$((U_WEB_DOMAINS + 1)) - - if [ "$SSL" = 'yes' ]; then - U_WEB_SSL=$((U_WEB_SSL + 1)) - fi - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_WEB=$((SUSPENDED_WEB + 1)) - fi - if [ ! -z "$ALIAS" ]; then - aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) - U_WEB_ALIASES=$((U_WEB_ALIASES + aliases)) - fi - BANDWIDTH=$((BANDWIDTH + U_BANDWIDTH)) - done - DISK=$((DISK + U_DISK_WEB)) - - # Checking dns system - for domain_str in $(cat $USER_DATA/dns.conf); do - eval $domain_str - U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1)) - records=$(wc -l $USER_DATA/dns/$DOMAIN.conf| cut -f 1 -d ' ') - U_DNS_RECORDS=$((U_DNS_RECORDS + records)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DNS=$((SUSPENDED_DNS + 1)) - fi - done - - # Checking mail system - for domain_str in $(cat $USER_DATA/mail.conf); do - eval $domain_str - U_DISK_MAIL=$((U_DISK_MAIL + U_DISK)) - U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) - accounts=$(wc -l $USER_DATA/mail/$DOMAIN.conf| cut -f 1 -d ' ') - U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accounts)) - if [ "$DKIM" = 'yes' ]; then - U_MAIL_DKIM=$((U_MAIL_DKIM + 1)) - fi - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_MAIL=$((SUSPENDED_MAIL + 1)) - fi - done - DISK=$((DISK + U_DISK_MAIL)) - - # Checking db system - for db_str in $(cat $USER_DATA/db.conf); do - eval $db_str - U_DISK_DB=$((U_DISK_DB + U_DISK)) - U_DATABASES=$((U_DATABASES + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_DB=$((SUSPENDED_DB + 1)) - fi - done - DISK=$((DISK + U_DISK_DB)) - - # Checking cron system - for cron_str in $(cat $USER_DATA/cron.conf);do - eval $cron_str - U_CRON_JOBS=$((U_CRON_JOBS + 1)) - if [ "$SUSPENDED" = 'yes' ]; then - SUSPENDED_CRON=$((SUSPENDED_CRON + 1)) - fi - done - - # Checking backup - for backup_str in $(cat $USER_DATA/backup.conf); do - U_BACKUPS=$((U_BACKUPS +1)) - done - - U_DISK=$DISK - U_BANDWIDTH=$BANDWIDTH - update_user_value "$user" '$SUSPENDED_USERS' "$SUSPENDED_USERS" - update_user_value "$user" '$SUSPENDED_WEB' "$SUSPENDED_WEB" - update_user_value "$user" '$SUSPENDED_DNS' "$SUSPENDED_DNS" - update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" - update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB" - update_user_value "$user" '$SUSPENDED_CRON' "$SUSPENDED_CRON" - update_user_value "$user" '$IP_AVAIL' "$IP_AVAIL" - update_user_value "$user" '$IP_OWNED' "$IP_OWNED" - update_user_value "$user" '$U_USERS' "$U_USERS" - update_user_value "$user" '$U_DISK' "$U_DISK" - update_user_value "$user" '$U_DISK_DIRS' "$U_DISK_DIRS" - update_user_value "$user" '$U_DISK_WEB' "$U_DISK_WEB" - update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" - update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB" - update_user_value "$user" '$U_BANDWIDTH' "$U_BANDWIDTH" - update_user_value "$user" '$U_WEB_DOMAINS' "$U_WEB_DOMAINS" - update_user_value "$user" '$U_WEB_SSL' "$U_WEB_SSL" - update_user_value "$user" '$U_WEB_ALIASES' "$U_WEB_ALIASES" - update_user_value "$user" '$U_DNS_DOMAINS' "$U_DNS_DOMAINS" - update_user_value "$user" '$U_DNS_RECORDS' "$U_DNS_RECORDS" - update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" - update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM" - update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" - update_user_value "$user" '$U_DATABASES' "$U_DATABASES" - update_user_value "$user" '$U_CRON_JOBS' "$U_CRON_JOBS" - update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" -done - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user usage counters +# options: USER +# +# Function updates usage counters like U_WEB_DOMAINS, U_MAIL_ACCOUNTS, etc. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" 'USER' +if [ ! -z "$user" ]; then + validate_format 'user' + is_object_valid 'user' 'USER' "$user" +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Creating user_list +if [ -z "$user" ]; then + user_list=$(ls $VESTA/data/users) +else + user_list="$user" +fi + +# Updating user stats +for user in $user_list; do + USER_DATA=$VESTA/data/users/$user + # Cleaning counters + SUSPENDED_USERS=0 + SUSPENDED_WEB=0 + SUSPENDED_DNS=0 + SUSPENDED_MAIL=0 + SUSPENDED_DB=0 + SUSPENDED_CRON=0 + IP_AVAIL=0 + IP_OWNED=0 + U_USERS=0 + U_DISK=0 + U_DISK_DIRS=$(get_user_value '$U_DISK_DIRS') + if [ -z "$U_DISK_DIRS" ]; then + U_DISK_DIRS=0 + fi + DISK=$((DISK + U_DISK_DIRS)) + U_DISK_WEB=0 + U_DISK_MAIL=0 + U_DISK_DB=0 + BANDWIDTH=0 + U_BANDWIDTH=0 + U_WEB_DOMAINS=0 + U_WEB_SSL=0 + U_WEB_ALIASES=0 + U_DNS_DOMAINS=0 + U_DNS_RECORDS=0 + U_MAIL_DOMAINS=0 + U_MAIL_DKIM=0 + U_MAIL_ACCOUNTS=0 + U_DATABASES=0 + U_CRON_JOBS=0 + U_BACKUPS=0 + + # New IFS + IFS=$'\n' + + # Checking users + if [ "$user" = 'admin' ]; then + SUSPENDED_USERS=$(grep "SUSPENDED='yes'" $VESTA/data/users/*/user.conf) + SUSPENDED_USERS=$(echo "$SUSPENDED_USERS" |wc -l) + U_USERS=$(ls $VESTA/data/users/|wc -l) + fi + + # Checking ip + for ip in $(ls $VESTA/data/ips) ;do + source $VESTA/data/ips/$ip + if [ "$OWNER" = "$user" ]; then + IP_OWNED=$((IP_OWNED + 1)) + IP_AVAIL=$((IP_AVAIL + 1)) + fi + if [ "$OWNER" = 'admin' ] && [ "$STATUS" = 'shared' ]; then + IP_AVAIL=$((IP_AVAIL + 1)) + fi + done + if [ "$user" = 'admin' ]; then + IP_AVAIL=$(ls $VESTA/data/ips | wc -l) + fi + + # Checking web system + U_WEB_DOMAINS=0 + for domain_str in $(cat $USER_DATA/web.conf) ;do + eval $domain_str + U_DISK_WEB=$((U_DISK_WEB + U_DISK)) + U_WEB_DOMAINS=$((U_WEB_DOMAINS + 1)) + + if [ "$SSL" = 'yes' ]; then + U_WEB_SSL=$((U_WEB_SSL + 1)) + fi + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_WEB=$((SUSPENDED_WEB + 1)) + fi + if [ ! -z "$ALIAS" ]; then + aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l) + U_WEB_ALIASES=$((U_WEB_ALIASES + aliases)) + fi + BANDWIDTH=$((BANDWIDTH + U_BANDWIDTH)) + done + DISK=$((DISK + U_DISK_WEB)) + + # Checking dns system + for domain_str in $(cat $USER_DATA/dns.conf); do + eval $domain_str + U_DNS_DOMAINS=$((U_DNS_DOMAINS + 1)) + records=$(wc -l $USER_DATA/dns/$DOMAIN.conf| cut -f 1 -d ' ') + U_DNS_RECORDS=$((U_DNS_RECORDS + records)) + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_DNS=$((SUSPENDED_DNS + 1)) + fi + done + + # Checking mail system + for domain_str in $(cat $USER_DATA/mail.conf); do + eval $domain_str + U_DISK_MAIL=$((U_DISK_MAIL + U_DISK)) + U_MAIL_DOMAINS=$((U_MAIL_DOMAINS + 1)) + accounts=$(wc -l $USER_DATA/mail/$DOMAIN.conf| cut -f 1 -d ' ') + U_MAIL_ACCOUNTS=$((U_MAIL_ACCOUNTS + accounts)) + if [ "$DKIM" = 'yes' ]; then + U_MAIL_DKIM=$((U_MAIL_DKIM + 1)) + fi + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_MAIL=$((SUSPENDED_MAIL + 1)) + fi + done + DISK=$((DISK + U_DISK_MAIL)) + + # Checking db system + for db_str in $(cat $USER_DATA/db.conf); do + eval $db_str + U_DISK_DB=$((U_DISK_DB + U_DISK)) + U_DATABASES=$((U_DATABASES + 1)) + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_DB=$((SUSPENDED_DB + 1)) + fi + done + DISK=$((DISK + U_DISK_DB)) + + # Checking cron system + for cron_str in $(cat $USER_DATA/cron.conf);do + eval $cron_str + U_CRON_JOBS=$((U_CRON_JOBS + 1)) + if [ "$SUSPENDED" = 'yes' ]; then + SUSPENDED_CRON=$((SUSPENDED_CRON + 1)) + fi + done + + # Checking backup + for backup_str in $(cat $USER_DATA/backup.conf); do + U_BACKUPS=$((U_BACKUPS +1)) + done + + U_DISK=$DISK + U_BANDWIDTH=$BANDWIDTH + update_user_value "$user" '$SUSPENDED_USERS' "$SUSPENDED_USERS" + update_user_value "$user" '$SUSPENDED_WEB' "$SUSPENDED_WEB" + update_user_value "$user" '$SUSPENDED_DNS' "$SUSPENDED_DNS" + update_user_value "$user" '$SUSPENDED_MAIL' "$SUSPENDED_MAIL" + update_user_value "$user" '$SUSPENDED_DB' "$SUSPENDED_DB" + update_user_value "$user" '$SUSPENDED_CRON' "$SUSPENDED_CRON" + update_user_value "$user" '$IP_AVAIL' "$IP_AVAIL" + update_user_value "$user" '$IP_OWNED' "$IP_OWNED" + update_user_value "$user" '$U_USERS' "$U_USERS" + update_user_value "$user" '$U_DISK' "$U_DISK" + update_user_value "$user" '$U_DISK_DIRS' "$U_DISK_DIRS" + update_user_value "$user" '$U_DISK_WEB' "$U_DISK_WEB" + update_user_value "$user" '$U_DISK_MAIL' "$U_DISK_MAIL" + update_user_value "$user" '$U_DISK_DB' "$U_DISK_DB" + update_user_value "$user" '$U_BANDWIDTH' "$U_BANDWIDTH" + update_user_value "$user" '$U_WEB_DOMAINS' "$U_WEB_DOMAINS" + update_user_value "$user" '$U_WEB_SSL' "$U_WEB_SSL" + update_user_value "$user" '$U_WEB_ALIASES' "$U_WEB_ALIASES" + update_user_value "$user" '$U_DNS_DOMAINS' "$U_DNS_DOMAINS" + update_user_value "$user" '$U_DNS_RECORDS' "$U_DNS_RECORDS" + update_user_value "$user" '$U_MAIL_DOMAINS' "$U_MAIL_DOMAINS" + update_user_value "$user" '$U_MAIL_DKIM' "$U_MAIL_DKIM" + update_user_value "$user" '$U_MAIL_ACCOUNTS' "$U_MAIL_ACCOUNTS" + update_user_value "$user" '$U_DATABASES' "$U_DATABASES" + update_user_value "$user" '$U_CRON_JOBS' "$U_CRON_JOBS" + update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS" +done + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-disk b/bin/v-update-user-disk index 4a8f32f8..b567f124 100755 --- a/bin/v-update-user-disk +++ b/bin/v-update-user-disk @@ -1,65 +1,65 @@ -#!/bin/bash -# info: update user disk usage -# options: USER -# -# The functions recalculates disk usage and updates database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'USER' -validate_format 'user' -is_object_valid 'user' 'USER' "$user" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Saving old IFS -OLDIFS=$IFS -IFS=$(echo -en "\n\b") - -# Defining directory list -dir_list=$(ls $HOMEDIR/$user/ |grep -v '^web$' | grep -v '^mail$' |\ - grep -v '^conf$') - -# Starting update disk loop -disk_usage='0' -for dir in $dir_list; do - dir_disk=$(du -shm "$HOMEDIR/$user/$dir"|cut -f 1 ) - disk_usage=$((disk_usage + dir_disk)) -done - -# Restoring old IFS -IFS=$OLDIFS - -# Updating disk value in config -update_user_value "$user" '$U_DIR_DISK' "$disk_usage" - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Recalculating user disk space -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user disk usage +# options: USER +# +# The functions recalculates disk usage and updates database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'USER' +validate_format 'user' +is_object_valid 'user' 'USER' "$user" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Saving old IFS +OLDIFS=$IFS +IFS=$(echo -en "\n\b") + +# Defining directory list +dir_list=$(ls $HOMEDIR/$user/ |grep -v '^web$' | grep -v '^mail$' |\ + grep -v '^conf$') + +# Starting update disk loop +disk_usage='0' +for dir in $dir_list; do + dir_disk=$(du -shm "$HOMEDIR/$user/$dir"|cut -f 1 ) + disk_usage=$((disk_usage + dir_disk)) +done + +# Restoring old IFS +IFS=$OLDIFS + +# Updating disk value in config +update_user_value "$user" '$U_DIR_DISK' "$disk_usage" + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Recalculating user disk space +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-package b/bin/v-update-user-package index 803188a7..780d21b2 100755 --- a/bin/v-update-user-package +++ b/bin/v-update-user-package @@ -1,47 +1,47 @@ -#!/bin/bash -# info: update user package -# options: PACAKGE -# -# The function propogates package to connected users. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -package=$1 - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '1' "$#" 'PACKAGE' -validate_format 'package' -is_package_valid - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -for user in $(ls $VESTA/data/users); do - check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf) - if [ ! -z "$check_package" ]; then - $BIN/v-change-user-package $user $package 'yes' - fi -done - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user package +# options: PACAKGE +# +# The function propogates package to connected users. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +package=$1 + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '1' "$#" 'PACKAGE' +validate_format 'package' +is_package_valid + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +for user in $(ls $VESTA/data/users); do + check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf) + if [ ! -z "$check_package" ]; then + $BIN/v-change-user-package $user $package 'yes' + fi +done + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-user-stats b/bin/v-update-user-stats index 895359b4..366c4a5c 100755 --- a/bin/v-update-user-stats +++ b/bin/v-update-user-stats @@ -1,169 +1,169 @@ -#!/bin/bash -# info: update user statistics -# options: USER -# -# Function logs user parameters into statistics database. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 - -# Importing system enviroment as we run this script -# mostly by cron wich not read it by itself -source /etc/profile - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '0' "$#" 'USER' -if [ ! -z "$user" ]; then - validate_format 'user' - is_object_valid 'user' 'USER' "$user" -fi - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Creating user_list -if [ -z "$user" ]; then - user_list=$(ls $VESTA/data/users) -else - user_list="$user" -fi - -# Reset overal statistics -TOTAL_IP_OWNED=0 -TOTAL_U_DISK=0 -TOTAL_U_DISK_DIRS=0 -TOTAL_U_DISK_WEB=0 -TOTAL_U_DISK_MAIL=0 -TOTAL_U_DISK_DB=0 -TOTAL_U_BANDWIDTH=0 -TOTAL_U_WEB_DOMAINS=0 -TOTAL_U_WEB_SSL=0 -TOTAL_U_WEB_ALIASES=0 -TOTAL_U_DNS_DOMAINS=0 -TOTAL_U_DNS_RECORDS=0 -TOTAL_U_MAIL_DOMAINS=0 -TOTAL_U_MAIL_DKIM=0 -TOTAL_U_MAIL_ACCOUNTS=0 -TOTAL_U_DATABASES=0 -TOTAL_U_CRON_JOBS=0 -TOTAL_U_BACKUPS=0 - -# Updating user stats -for user in $user_list; do - USER_DATA=$VESTA/data/users/$user - source $USER_DATA/user.conf - next_month=$(date +'%m/01/%y' -d '+ 1 month') - DATE=$(date -d "$next_month -1day" +%F) - - # Compiling report string - s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" - s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'" - s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'" - s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'" - s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'" - s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'" - s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'" - s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'" - s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'" - s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'" - - # Updating user stats log - stats="$USER_DATA/stats.log" - if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi - else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats - fi - - # Increase overall counters - TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) - TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) - TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) - TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) - TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) - TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) - TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) - TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) - TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) - TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) - TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) - TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) - TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) - TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) - TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) - TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) - TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) - TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) - -done - -# Updating overall stats -stats="$VESTA/data/users/admin/overall_stats.log" - -s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" -s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" -s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" -s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" -s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" -s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" -s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" -s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" -s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" -s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" -s="$s U_DATABASES='$TOTAL_U_DATABASES'" -s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" - -if [ -e "$stats" ]; then - # Checking dublicates - check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) - if [ -z "$check_month" ]; then - # Updating as there no dublicates - echo "$s" >> $stats - chmod 660 $stats - else - # Replacing string with new data - sed -i "$check_month s/.*/$s/" $stats - fi -else - # Creating stats log - echo "$s" >$stats - chmod 660 $stats -fi - - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update user statistics +# options: USER +# +# Function logs user parameters into statistics database. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 + +# Importing system enviroment as we run this script +# mostly by cron wich not read it by itself +source /etc/profile + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '0' "$#" 'USER' +if [ ! -z "$user" ]; then + validate_format 'user' + is_object_valid 'user' 'USER' "$user" +fi + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Creating user_list +if [ -z "$user" ]; then + user_list=$(ls $VESTA/data/users) +else + user_list="$user" +fi + +# Reset overal statistics +TOTAL_IP_OWNED=0 +TOTAL_U_DISK=0 +TOTAL_U_DISK_DIRS=0 +TOTAL_U_DISK_WEB=0 +TOTAL_U_DISK_MAIL=0 +TOTAL_U_DISK_DB=0 +TOTAL_U_BANDWIDTH=0 +TOTAL_U_WEB_DOMAINS=0 +TOTAL_U_WEB_SSL=0 +TOTAL_U_WEB_ALIASES=0 +TOTAL_U_DNS_DOMAINS=0 +TOTAL_U_DNS_RECORDS=0 +TOTAL_U_MAIL_DOMAINS=0 +TOTAL_U_MAIL_DKIM=0 +TOTAL_U_MAIL_ACCOUNTS=0 +TOTAL_U_DATABASES=0 +TOTAL_U_CRON_JOBS=0 +TOTAL_U_BACKUPS=0 + +# Updating user stats +for user in $user_list; do + USER_DATA=$VESTA/data/users/$user + source $USER_DATA/user.conf + next_month=$(date +'%m/01/%y' -d '+ 1 month') + DATE=$(date -d "$next_month -1day" +%F) + + # Compiling report string + s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'" + s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'" + s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'" + s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'" + s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'" + s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'" + s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'" + s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'" + s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'" + s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'" + + # Updating user stats log + stats="$USER_DATA/stats.log" + if [ -e "$stats" ]; then + # Checking dublicates + check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) + if [ -z "$check_month" ]; then + # Updating as there no dublicates + echo "$s" >> $stats + chmod 660 $stats + else + # Replacing string with new data + sed -i "$check_month s/.*/$s/" $stats + fi + else + # Creating stats log + echo "$s" >$stats + chmod 660 $stats + fi + + # Increase overall counters + TOTAL_IP_OWNED=$((TOTAL_IP_OWNED + IP_OWNED)) + TOTAL_U_DISK=$((TOTAL_U_DISK + U_DISK)) + TOTAL_U_DISK_DIRS=$((TOTAL_U_DISK_DIRS + U_DISK_DIRS)) + TOTAL_U_DISK_WEB=$((TOTAL_U_DISK_WEB + U_DISK_WEB)) + TOTAL_U_DISK_MAIL=$((TOTAL_U_DISK_MAIL + U_DISK_MAIL)) + TOTAL_U_DISK_DB=$((TOTAL_U_DISK_DB + U_DISK_DB)) + TOTAL_U_BANDWIDTH=$((TOTAL_U_BANDWIDTH + U_BANDWIDTH)) + TOTAL_U_WEB_DOMAINS=$((TOTAL_U_WEB_DOMAINS + U_WEB_DOMAINS)) + TOTAL_U_WEB_SSL=$((TOTAL_U_WEB_SSL + U_WEB_SSL)) + TOTAL_U_WEB_ALIASES=$((TOTAL_U_WEB_ALIASES + U_WEB_ALIASES)) + TOTAL_U_DNS_DOMAINS=$((TOTAL_U_DNS_DOMAINS + U_DNS_DOMAINS)) + TOTAL_U_DNS_RECORDS=$((TOTAL_U_DNS_RECORDS + U_DNS_RECORDS)) + TOTAL_U_MAIL_DOMAINS=$((TOTAL_U_MAIL_DOMAINS + U_MAIL_DOMAINS)) + TOTAL_U_MAIL_DKIM=$((TOTAL_U_MAIL_DKIM + U_MAIL_DKIM)) + TOTAL_U_MAIL_ACCOUNTS=$((TOTAL_U_MAIL_ACCOUNTS + U_MAIL_ACCOUNTS)) + TOTAL_U_DATABASES=$((TOTAL_U_DATABASES + U_DATABASES)) + TOTAL_U_CRON_JOBS=$((TOTAL_U_CRON_JOBS + U_CRON_JOBS)) + TOTAL_U_BACKUPS=$((TOTAL_U_BACKUPS + U_BACKUPS)) + +done + +# Updating overall stats +stats="$VESTA/data/users/admin/overall_stats.log" + +s="DATE='$DATE' TIME='$TIME' PACKAGE='default' IP_OWNED='$TOTAL_IP_OWNED'" +s="$s DISK_QUOTA='0' U_DISK='$TOTAL_U_DISK' U_DISK_DIRS='$TOTAL_U_DISK_DIRS'" +s="$s U_DISK_WEB='$TOTAL_U_DISK_WEB' U_DISK_MAIL='$TOTAL_U_DISK_MAIL'" +s="$s U_DISK_DB='$TOTAL_U_DISK_DB' BANDWIDTH='0'" +s="$s U_BANDWIDTH='$TOTAL_U_BANDWIDTH' U_WEB_DOMAINS='$TOTAL_U_WEB_DOMAINS'" +s="$s U_WEB_SSL='$TOTAL_U_WEB_SSL' U_WEB_ALIASES='$TOTAL_U_WEB_ALIASES'" +s="$s U_DNS_DOMAINS='$TOTAL_U_DNS_DOMAINS'" +s="$s U_DNS_RECORDS='$TOTAL_U_DNS_RECORDS'" +s="$s U_MAIL_DOMAINS='$TOTAL_U_MAIL_DOMAINS' U_MAIL_DKIM='$TOTAL_U_MAIL_DKIM'" +s="$s U_MAIL_ACCOUNTS='$TOTAL_U_MAIL_ACCOUNTS'" +s="$s U_DATABASES='$TOTAL_U_DATABASES'" +s="$s U_CRON_JOBS='$TOTAL_U_CRON_JOBS' U_BACKUPS='$TOTAL_U_BACKUPS'" + +if [ -e "$stats" ]; then + # Checking dublicates + check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :) + if [ -z "$check_month" ]; then + # Updating as there no dublicates + echo "$s" >> $stats + chmod 660 $stats + else + # Replacing string with new data + sed -i "$check_month s/.*/$s/" $stats + fi +else + # Creating stats log + echo "$s" >$stats + chmod 660 $stats +fi + + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-web-domain-disk b/bin/v-update-web-domain-disk index 52617853..b820748f 100755 --- a/bin/v-update-web-domain-disk +++ b/bin/v-update-web-domain-disk @@ -1,60 +1,60 @@ -#!/bin/bash -# info: update disk usage for domain -# options: USER DOMAIN -# -# The function recalculates disk usage for speciefic webdomain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -# Defining home directory -home_dir="$HOMEDIR/$user/web/$domain/" - -# Checking home directory exist -if [ -e "$home_dir" ]; then - disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 ) -fi - - -#----------------------------------------------------------# -# Vesta # -#----------------------------------------------------------# - -# Updating disk value in config -update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage" -recalc_user_disk_usage - -# Logging -log_event "$OK" "$EVENT" - -exit +#!/bin/bash +# info: update disk usage for domain +# options: USER DOMAIN +# +# The function recalculates disk usage for speciefic webdomain. + + +#----------------------------------------------------------# +# Variable&Function # +#----------------------------------------------------------# + +# Argument defenition +user=$1 +domain=$(idn -t --quiet -u "$2" ) +domain_idn=$(idn -t --quiet -a "$domain") + +# Includes +source $VESTA/conf/vesta.conf +source $VESTA/func/main.sh +source $VESTA/func/domain.sh + + +#----------------------------------------------------------# +# Verifications # +#----------------------------------------------------------# + +check_args '2' "$#" 'USER DOMAIN' +validate_format 'user' 'domain' +is_system_enabled "$WEB_SYSTEM" +is_object_valid 'user' 'USER' "$user" +is_object_unsuspended 'user' 'USER' "$user" +is_object_valid 'web' 'DOMAIN' "$domain" +is_object_unsuspended 'web' 'DOMAIN' "$domain" + + +#----------------------------------------------------------# +# Action # +#----------------------------------------------------------# + +# Defining home directory +home_dir="$HOMEDIR/$user/web/$domain/" + +# Checking home directory exist +if [ -e "$home_dir" ]; then + disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 ) +fi + + +#----------------------------------------------------------# +# Vesta # +#----------------------------------------------------------# + +# Updating disk value in config +update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage" +recalc_user_disk_usage + +# Logging +log_event "$OK" "$EVENT" + +exit diff --git a/bin/v-update-web-domain-stat b/bin/v-update-web-domain-stat index 4692002e..cdaff937 100755 --- a/bin/v-update-web-domain-stat +++ b/bin/v-update-web-domain-stat @@ -1,144 +1,144 @@ -#!/bin/bash -# info: update domain statistics -# options: USER DOMAIN -# -# The function runs log analyzer for speciefic webdomain. - - -#----------------------------------------------------------# -# Variable&Function # -#----------------------------------------------------------# - -# Argument defenition -user=$1 -domain=$(idn -t --quiet -u "$2" ) -domain_idn=$(idn -t --quiet -a "$domain") - -# Includes -source $VESTA/conf/vesta.conf -source $VESTA/func/main.sh -source $VESTA/func/domain.sh - - -#----------------------------------------------------------# -# Verifications # -#----------------------------------------------------------# - -check_args '2' "$#" 'USER DOMAIN' -validate_format 'user' 'domain' -is_system_enabled "$WEB_SYSTEM" -is_object_valid 'user' 'USER' "$user" -is_object_unsuspended 'user' 'USER' "$user" -is_object_valid 'web' 'DOMAIN' "$domain" -is_object_unsuspended 'web' 'DOMAIN' "$domain" -is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS' - - -#----------------------------------------------------------# -# Action # -#----------------------------------------------------------# - -get_domain_values 'web' - -# Checking config -config="$HOMEDIR/$user/conf/web/$STATS.$domain.conf" -if [ ! -e "$config" ]; then - echo "Error: Parsing error" - log_event "$E_PARSING" "$EVENT" - exit $E_PARSING -fi - -# Checking statistics directory -dir="$HOMEDIR/$user/web/$domain/stats" -if [ ! -e "$dir" ]; then - mkdir -p $dir -fi - -# Defining functions -build_webalizer() { - /usr/bin/webalizer -c $config -} - -build_awstats() { - awstats="/usr/share/awstats/wwwroot/cgi-bin/awstats.pl" - wwwroot="/usr/share/awstats/wwwroot" - opts="-config=$domain -staticlinks -update -output" - month=$(date "+%Y-%m") - output='alldomains allhosts lasthosts unknownip allrobots lastrobots - urldetail urlentry urlexit osdetail browserdetail unknownbrowser - unknownos refererse refererpages keyphrases keywords errors404' - - # Checking statistics directory - if [ ! -e "$dir/$month" ]; then - mkdir -p $dir/$month - fi - - # Logo check - if [ ! -e "$dir/logo.png" ]; then - cp -r $VESTA/web/images/logo.png $dir/ - fi - - # Icon directory check - if [ ! -e "$dir/icon" ]; then - cp -r $wwwroot/icon $dir/ - fi - - # Creating main awstats page - $awstats $opts | sed -e "s%awstats.$domain.%%g" > $dir/$month/index.html - - # Creating suplemental awstats pages - for format in $output; do - $awstats $opts=$format |\ - sed -e "s%awstats.$domain.%%g" > $dir/$month/$format.html - done - - # Creating index page - cat $WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" >\ - $dir/index.html - - # Creating navigation page - months=$(find $dir -type d | sed -e "s%$dir/%%g" -e "s%$dir%%g" |\ - grep -v icon | sort -r ) - for link in $months; do - year=$(echo $link |cut -f 1 -d \-) - month=$(echo $link |cut -f 2 -d \-) - case "$month" in - 1) month='January';; - 2) month='February';; - 3) month='March';; - 4) month='April';; - 5) month='May';; - 6) month='June';; - 7) month='July';; - 8) month='August';; - 9) month='September';; - 10) month='October';; - 11) month='November';; - 12) month='December';; - esac - echo $month - - select_m="$select_m