mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 18:49:17 -07:00
dox2unix fix after merge
This commit is contained in:
parent
6e0aba66e0
commit
b8b28120fd
231 changed files with 20776 additions and 20776 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
200
bin/v-add-sys-ip
200
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
|
||||
|
|
436
bin/v-add-user
436
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
1046
bin/v-backup-user
1046
bin/v-backup-user
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue