mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
web function refactoring
This commit is contained in:
parent
73b63016d4
commit
872cd3ac45
20 changed files with 744 additions and 1239 deletions
|
@ -1,31 +1,47 @@
|
|||
#!/bin/bash
|
||||
# info: add web domain
|
||||
# options: USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]
|
||||
# options: USER DOMAIN [IP] [ALIASES] [PROXY_EXTENTIONS] [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
|
||||
# associated 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.
|
||||
# The function adds virtual host to a server. In cases when ip is
|
||||
# undefined in the script, "default" template will be used. The alias of
|
||||
# www.domain.tld type will be automatically assigned to the domain unless
|
||||
# "none" is transmited as argument. If ip have associated 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 server yet.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
|
||||
# Argument definition
|
||||
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; IP=$3
|
||||
restart=$4
|
||||
domain=$2
|
||||
ip=$3
|
||||
restart=$4 # will be moved to the end soon
|
||||
aliases=$5
|
||||
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=${6-$default_extentions}
|
||||
proxy_ext=$6
|
||||
|
||||
# Additional argument formatting
|
||||
if [[ "$domain" =~ [[:upper:]] ]]; then
|
||||
domain=$(echo "$domain" |tr '[:upper:]' '[:lower:]')
|
||||
fi
|
||||
if [[ "$domain" =~ ^www\..* ]]; then
|
||||
domain=$(echo "$domain" |sed -e "s/^www.//")
|
||||
fi
|
||||
if [[ "$domain" =~ .*\.$ ]]; then
|
||||
domain=$(echo "$domain" |sed -e "s/\.$//")
|
||||
fi
|
||||
domain_idn="$domain"
|
||||
if [[ "$domain" = *[![:ascii:]]* ]]; then
|
||||
domain_idn=$(idn -t --quiet -a $domain)
|
||||
fi
|
||||
if [ ! -z "$aliases" ] && [ "$aliases" != 'none' ]; then
|
||||
aliases=$(echo $aliases |tr '[:upper:]' '[:lower:]' |tr ',' '\n')
|
||||
aliases=$(echo "$aliases" |sed -e "s/\.$//" |sort -u |grep -v www.$domain)
|
||||
aliases=$(echo "$aliases" |sed -e "/^$/d" |tr '\n' ',' |sed -e "s/,$//")
|
||||
fi
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -38,76 +54,24 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]'
|
||||
validate_format 'user' 'domain' 'ip'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
check_args '2' "$#" 'USER DOMAIN [IP] [ALIASES] [PROXY_EXTENTIONS] [RESTART]'
|
||||
is_format_valid 'user' 'domain' 'aliases' 'ip' 'proxy_ext'
|
||||
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'
|
||||
template=$(get_user_value '$WEB_TEMPLATE')
|
||||
is_web_template_valid
|
||||
if [ ! -z "$aliases" ]; then
|
||||
for domain_alias in $(echo "${aliases//,/ }"); do
|
||||
is_domain_new 'web' "$domain_alias" 'alias'
|
||||
done
|
||||
fi
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
validate_format 'extentions'
|
||||
proxy=$(get_user_value '$PROXY_TEMPLATE')
|
||||
is_proxy_template_valid $proxy
|
||||
fi
|
||||
is_package_full 'WEB_DOMAINS' 'WEB_ALIASES'
|
||||
is_domain_new 'web' "$domain,$aliases"
|
||||
is_ip_valid "$ip"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Checking domain backend in case PHP-FPM is configured
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
is_web_backend_pool_valid
|
||||
$BIN/v-add-web-domain-backend $user $domain
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
exit $rc
|
||||
fi
|
||||
get_domain_backend_values
|
||||
backend=$(get_user_value '$BACKEND_TEMPLATE')
|
||||
if [ -z "$backend" ]; then
|
||||
backend='default'
|
||||
fi
|
||||
fi
|
||||
# Reading user values
|
||||
source $USER_DATA/user.conf
|
||||
|
||||
# Defining variables for add_config function
|
||||
ip=$(get_real_ip $ip)
|
||||
group="$user"
|
||||
email="info@$domain"
|
||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
|
||||
# Defining domain aliases
|
||||
ip_name=$(get_ip_name)
|
||||
if [ -z "$aliases" ]; then
|
||||
if [ -z "$ip_name" ]; then
|
||||
aliases="www.$domain"
|
||||
else
|
||||
aliases="www.$domain,${domain//./-}.$ip_name"
|
||||
fi
|
||||
else
|
||||
if [ ! -z "$ip_name" ]; then
|
||||
aliases="$aliases,${domain//./-}.$ip_name"
|
||||
fi
|
||||
fi
|
||||
aliases_idn=$(idn -t --quiet -a $aliases)
|
||||
alias_string="ServerAlias ${aliases_idn//,/ }"
|
||||
|
||||
# Adding web config
|
||||
add_web_config
|
||||
|
||||
# Building directory tree
|
||||
# Creating domain directories
|
||||
mkdir -p $HOMEDIR/$user/web/$domain \
|
||||
$HOMEDIR/$user/web/$domain/public_html \
|
||||
$HOMEDIR/$user/web/$domain/public_shtml \
|
||||
|
@ -117,83 +81,49 @@ mkdir -p $HOMEDIR/$user/web/$domain \
|
|||
$HOMEDIR/$user/web/$domain/stats \
|
||||
$HOMEDIR/$user/web/$domain/logs
|
||||
|
||||
# Adding domain logs
|
||||
# Creating domain logs
|
||||
touch /var/log/$WEB_SYSTEM/domains/$domain.bytes \
|
||||
/var/log/$WEB_SYSTEM/domains/$domain.log \
|
||||
/var/log/$WEB_SYSTEM/domains/$domain.error.log
|
||||
|
||||
# Adding symlink for logs
|
||||
ln -f -s /var/log/$WEB_SYSTEM/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
|
||||
cp -r $WEBTPL/skel/* $HOMEDIR/$user/web/$domain/ >/dev/null 2>&1
|
||||
for file in $(find "$HOMEDIR/$user/web/$domain/" -type f); do
|
||||
sed -i "s/%domain%/$domain/g" $file
|
||||
done
|
||||
|
||||
# Changing file owner
|
||||
# Changing file owner & permission
|
||||
chown -R $user:$user $HOMEDIR/$user/web/$domain
|
||||
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.* $conf
|
||||
chmod 640 /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||
chmod 751 $HOMEDIR/$user/web/$domain $HOMEDIR/$user/web/$domain/*
|
||||
chmod 551 $HOMEDIR/$user/web/$domain/stats $HOMEDIR/$user/web/$domain/logs
|
||||
|
||||
# Changing file permissions
|
||||
chmod 640 $conf /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||
chmod 551 $HOMEDIR/$user/web/$domain
|
||||
chmod 751 $HOMEDIR/$user/web/$domain/private \
|
||||
$HOMEDIR/$user/web/$domain/cgi-bin \
|
||||
$HOMEDIR/$user/web/$domain/public_html \
|
||||
$HOMEDIR/$user/web/$domain/public_shtml \
|
||||
$HOMEDIR/$user/web/$domain/document_errors
|
||||
chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* \
|
||||
$HOMEDIR/$user/web/$domain/public_html/* \
|
||||
$HOMEDIR/$user/web/$domain/document_errors/* \
|
||||
chmod 551 $HOMEDIR/$user/web/$domain/stats \
|
||||
$HOMEDIR/$user/web/$domain/logs
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||
$user $domain $ip $HOMEDIR $docroot
|
||||
# Addding PHP-FPM backend
|
||||
if [ ! -z "$BACKEND_SYSTEM" ]; then
|
||||
$BIN/v-add-web-domain-backend "$user" "$domain" $BACKEND_TEMPLATE
|
||||
check_result $? "Backend error" >/dev/null
|
||||
fi
|
||||
|
||||
# Checking web config include
|
||||
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
||||
web_include=$(grep "$conf" $web_conf )
|
||||
if [ -z "$web_include" ] && [ "$WEB_SYSTEM" != 'nginx' ]; then
|
||||
echo "Include $conf" >> $web_conf
|
||||
fi
|
||||
if [ -z "$web_include" ] && [ "$WEB_SYSTEM" = 'nginx' ]; then
|
||||
echo "include $conf;" >> $web_conf
|
||||
# Preparing domain aliases
|
||||
if [ "$aliases" != 'none' ]; then
|
||||
prepare_web_aliases "www.$domain,$aliases,$(get_ip_alias $domain)"
|
||||
fi
|
||||
|
||||
# Checking proxy system
|
||||
# Adding web server config
|
||||
add_web_config "$WEB_SYSTEM" "$WEB_TEMPLATE.tpl"
|
||||
|
||||
# Adding proxy config
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
PROXY_EXT="$extentions"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
if [ -x $WEBTPL/$PROXY_SYSTEM/$proxy.sh ]; then
|
||||
$WEBTPL/$PROXY_SYSTEM/$proxy.sh $user $domain $ip $HOMEDIR $docroot
|
||||
PROXY_EXT="$proxy_ext"
|
||||
if [ -z "$proxy_ext" ]; then
|
||||
PROXY_EXT="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
|
||||
PROXY_EXT="$PROXY_EXT,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp"
|
||||
PROXY_EXT="$PROXY_EXT,rtf,js,mp3,avi,mpeg,flv,html,htm"
|
||||
fi
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY_TEMPLATE.tpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -202,25 +132,28 @@ fi
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Increasing counters
|
||||
increase_ip_value "$ip"
|
||||
increase_user_value "$user" '$U_WEB_DOMAINS'
|
||||
increase_ip_value "$local_ip"
|
||||
increase_user_value "$user" '$U_WEB_DOMAINS' "$alias_number"
|
||||
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||
|
||||
# Defining domain variables
|
||||
str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
|
||||
str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5='' BACKEND='$backend'"
|
||||
str="$str PROXY='$proxy' PROXY_EXT='$extentions' STATS='' STATS_USER=''"
|
||||
str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
|
||||
str="$str TIME='$TIME' DATE='$DATE'"
|
||||
# Generating timestamp
|
||||
time_n_date=$(date +'%T %F')
|
||||
time=$(echo "$time_n_date" |cut -f 1 -d \ )
|
||||
date=$(echo "$time_n_date" |cut -f 2 -d \ )
|
||||
|
||||
# Registering domain
|
||||
echo "$str" >> $USER_DATA/web.conf
|
||||
# Adding domain in web.conf
|
||||
echo "DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$WEB_TEMPLATE' \
|
||||
SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5='' BACKEND='$BACKEND_TEMPLATE' \
|
||||
PROXY='$PROXY_TEMPLATE' PROXY_EXT='$PROXY_EXT' STATS='' STATS_USER='' \
|
||||
STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no' \
|
||||
TIME='$time' DATE='$date'" >> $USER_DATA/web.conf
|
||||
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
# Restarting proxy server
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
|
@ -229,6 +162,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "added web domain $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: add web domain alias
|
||||
# options: USER DOMAIN ALIAS [RESTART]
|
||||
# options: USER DOMAIN ALIASES [RESTART]
|
||||
#
|
||||
# The call is intended for adding aliases to a domain (it is also called
|
||||
# "domain parking"). The function supports wildcards *.domain.tpl.
|
||||
|
@ -32,14 +32,14 @@ source $VESTA/conf/vesta.conf
|
|||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]'
|
||||
validate_format 'user' 'domain' 'dom_alias'
|
||||
check_args '3' "$#" 'USER DOMAIN ALIASES [RESTART]'
|
||||
is_format_valid 'user' 'domain' 'dom_alias'
|
||||
is_system_enabled "$WEB_SYSTEM" '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" 'alias'
|
||||
is_domain_new 'web' "$dom_alias"
|
||||
is_package_full 'WEB_ALIASES'
|
||||
|
||||
|
||||
|
@ -49,43 +49,30 @@ is_package_full 'WEB_ALIASES'
|
|||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
ip=$(get_real_ip $IP)
|
||||
|
||||
# Parsing domain aliases
|
||||
# Preparing domain values for the template substitution
|
||||
if [ -z "$ALIAS" ]; then
|
||||
ALIAS="$dom_alias"
|
||||
else
|
||||
ALIAS="$ALIAS,$dom_alias"
|
||||
fi
|
||||
prepare_web_domain_values
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
|
||||
# Recreating vhost
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
# Rebuilding vhost
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
# Rebuilding proxy configuration
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -96,8 +83,6 @@ fi
|
|||
|
||||
# Adding new alias
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
||||
|
||||
# Update counters
|
||||
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||
|
||||
# Restarting web server
|
||||
|
@ -112,6 +97,6 @@ if [ "$restart" != 'no' ]; then
|
|||
fi
|
||||
|
||||
log_history "added $dom_alias as alias for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -32,7 +32,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN [TEMPLATE] [EXTENTIONS] [RESTART]'
|
||||
validate_format 'user' 'domain' 'extentions'
|
||||
is_format_valid 'user' 'domain' 'extentions'
|
||||
is_system_enabled "$PROXY_SYSTEM" 'PROXY_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -51,44 +51,15 @@ is_proxy_template_valid $template
|
|||
|
||||
# Defining domain parameters
|
||||
get_domain_values 'web'
|
||||
PROXY="$template"
|
||||
PROXY_EXT="$extentions"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
ip=$(get_real_ip $IP)
|
||||
local_ip=$(get_real_ip $IP)
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
add_web_config
|
||||
PROXY_EXT="$extentions"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
|
||||
# Set permission and ownership
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
|
||||
# Checking proxy config
|
||||
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
|
||||
# Checking ssl
|
||||
# Adding proxy for ssl
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
add_web_config
|
||||
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
|
||||
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$(grep "$conf" $proxy_conf)" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$PROXY_SYSTEM/$template.sh ]; then
|
||||
$WEBTPL/$PROXY_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -107,6 +78,6 @@ if [ "$restart" != 'no' ]; then
|
|||
fi
|
||||
|
||||
log_history "enabled proxy support for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -34,7 +34,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_DIR [SSL_HOME] [RESTART]'
|
||||
validate_format 'user' 'domain' 'ssl_dir'
|
||||
is_format_valid 'user' 'domain' 'ssl_dir'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_system_enabled "$WEB_SSL" 'SSL_SUPPORT'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -60,22 +60,6 @@ if [ -e "$ssl_dir/$domain.ca" ]; then
|
|||
fi
|
||||
chmod 660 $USER_DATA/ssl/$domain.*
|
||||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
SSL_HOME="$ssl_home"
|
||||
ip=$(get_real_ip $IP)
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
|
||||
# Adding domain to the web config
|
||||
add_web_config
|
||||
|
||||
chown root:$user $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
|
||||
|
@ -84,32 +68,20 @@ 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/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||
$user $domain $ip $HOMEDIR $sdocroot
|
||||
fi
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
local_ip=$(get_real_ip $IP)
|
||||
|
||||
# Checking web config
|
||||
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$(grep "$conf" $web_conf)" ]; then
|
||||
echo "Include $conf" >> $web_conf
|
||||
fi
|
||||
# Preparing domain values for the template substitution
|
||||
SSL_HOME="$ssl_home"
|
||||
prepare_web_domain_values
|
||||
|
||||
# Checking proxy
|
||||
# Adding domain to the web config
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
|
||||
# Checking proxy config
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
add_web_config
|
||||
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
|
||||
# Checking proxy config
|
||||
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$(grep "$conf" $proxy_conf )" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -137,6 +109,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "enabled ssl support for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -30,7 +30,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN TYPE'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_type_valid "$STATS_SYSTEM" "$type"
|
||||
is_object_valid 'user' 'USER' "$user" "$user"
|
||||
|
@ -47,10 +47,8 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS'
|
|||
# Parse aliases
|
||||
get_domain_values 'web'
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
|
||||
# Adding statistic config
|
||||
prepare_web_domain_values
|
||||
cat $WEBTPL/$type/$type.tpl |\
|
||||
sed -e "s|%ip%|$ip|g" \
|
||||
-e "s|%web_port%|$WEB_PORT|g" \
|
||||
|
@ -90,7 +88,7 @@ update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
|
|||
|
||||
# Logging
|
||||
log_history "enabled web log analyzer for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
# Build stats
|
||||
exec $BIN/v-update-web-domain-stat $user $domain
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
# info: change web domain ip address
|
||||
# options: USER DOMAIN IP [RESTART]
|
||||
# info: change web domain ip
|
||||
# options: USER DOMAIN DOMAIN [RESTART]
|
||||
#
|
||||
# The call is used for changing the site ip address.
|
||||
# The call is used for changing domain ip
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -13,7 +13,7 @@
|
|||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ip=$3
|
||||
new_domain=$(echo $3 |tr '[:upper:]' '[:lower:]')
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
|
@ -28,7 +28,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
|
||||
validate_format 'user' 'domain' 'ip'
|
||||
is_format_valid 'user' 'domain' 'ip'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -42,33 +42,22 @@ is_ip_avalable
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Define variable for replace
|
||||
# Preparing variables for vhost replace
|
||||
get_domain_values 'web'
|
||||
ip=$(get_real_ip $ip)
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
old=$(get_real_ip $IP)
|
||||
new=$ip
|
||||
replace_web_config
|
||||
|
||||
# Checking SSL
|
||||
# Replacing vhost
|
||||
replace_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
replace_web_config
|
||||
replace_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
# Replacing proxy vhost
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
replace_web_config
|
||||
|
||||
# Checking SSL proxy
|
||||
if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
replace_web_config
|
||||
replace_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
replace_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -97,6 +86,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "changed web domain $domain ip to $3"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -32,7 +32,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN TEMPLATE [EXTENTIONS] [RESTART]'
|
||||
validate_format 'user' 'domain' 'template'
|
||||
is_format_valid 'user' 'domain' 'template'
|
||||
is_system_enabled "$PROXY_SYSTEM" 'PROXY_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -48,38 +48,21 @@ is_proxy_template_valid $template
|
|||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
old_tpl=$PROXY
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
ip=$(get_real_ip $IP)
|
||||
|
||||
# Delete old vhost
|
||||
del_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
# Add new vhost
|
||||
PROXY="$template"
|
||||
PROXY_EXT="$extentions"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$template.tpl"
|
||||
upd_web_domain_values
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
|
||||
# Checking SSL
|
||||
prepare_web_domain_values
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$old_tpl.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$template.stpl"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
fi
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$PROXY_SYSTEM/$template.sh ]; then
|
||||
$WEBTPL/$PROXY_SYSTEM/$template.sh $user $domain $ip $HOMEDIR $docroot
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -99,6 +82,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "changed proxy template for $domain to $template"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -28,7 +28,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
|
||||
validate_format 'user' 'domain' 'ssl_dir'
|
||||
is_format_valid 'user' 'domain' 'ssl_dir'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -83,6 +83,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "changed ssl certificate for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -23,7 +23,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -40,8 +40,6 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
|||
get_domain_values 'web'
|
||||
old_ssl_home=$SSL_HOME
|
||||
SSL_HOME=$ssl_home
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
|
||||
# Parsing tpl_option
|
||||
case $SSL_HOME in
|
||||
|
@ -53,13 +51,11 @@ case $SSL_HOME in
|
|||
esac
|
||||
|
||||
# Changing sslhome directory
|
||||
replace_web_config
|
||||
replace_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
|
||||
# Checking proxy config
|
||||
# Changing proxy vhost
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
replace_web_config
|
||||
replace_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -83,6 +79,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "changed ssl home for $domain to $ssl_home"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -27,7 +27,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN TYPE'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_type_valid "$STATS_SYSTEM" "$type"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
@ -46,7 +46,7 @@ get_domain_values 'web'
|
|||
|
||||
# Comparing stats types
|
||||
if [ "$STATS" == $type ]; then
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
@ -59,10 +59,8 @@ 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
|
||||
prepare_web_domain_values
|
||||
cat $WEBTPL/$type/$type.tpl |\
|
||||
sed -e "s/%ip%/$ip/g" \
|
||||
-e "s/%web_port%/$WEB_PORT/g" \
|
||||
|
@ -98,7 +96,7 @@ update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
|
|||
|
||||
# Logging
|
||||
log_history "changed web log stats for $domain to $type"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
# Build stats
|
||||
exec $BIN/v-update-web-domain-stat $user $domain
|
||||
|
|
|
@ -29,7 +29,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
|
||||
validate_format 'user' 'domain' 'template'
|
||||
is_format_valid 'user' 'domain' 'template'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -47,42 +47,17 @@ get_domain_values 'web'
|
|||
ip=$(get_real_ip $IP)
|
||||
|
||||
# Deleting domain
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
old_tpl=$TPL
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
|
||||
# Deleting ssl vhost
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
# Defining variables for new vhost config
|
||||
upd_web_domain_values
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||
|
||||
# Adding domain to the web conf
|
||||
add_web_config
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||
$user $domain $ip $HOMEDIR $docroot
|
||||
fi
|
||||
|
||||
# Checking SSL
|
||||
TPL=$template
|
||||
prepare_web_domain_values
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.stpl"
|
||||
add_web_config
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
|
||||
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh \
|
||||
"$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
|
||||
fi
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -101,6 +76,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "changed web domain template for $domain to $template" '' 'admin'
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -14,10 +14,18 @@
|
|||
|
||||
# Argument definition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
domain=$2
|
||||
restart=$3
|
||||
|
||||
# Additional argument formatting
|
||||
if [[ "$domain" =~ [[:upper:]] ]]; then
|
||||
domain=$(echo "$domain" |tr '[:upper:]' '[:lower:]')
|
||||
fi
|
||||
domain_idn="$domain"
|
||||
if [[ "$domain" = *[![:ascii:]]* ]]; then
|
||||
domain_idn=$(idn -t --quiet -a $tmp_alias)
|
||||
fi
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
|
@ -30,7 +38,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -42,58 +50,40 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Get template name
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
ip=$(get_real_ip $IP)
|
||||
|
||||
# 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/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
|
||||
# Deleting SSL certificates
|
||||
rm -f $HOMEDIR/$user/conf/web/ssl.$domain.*
|
||||
rm -f $USER_DATA/ssl/$domain.*
|
||||
fi
|
||||
|
||||
# Checking backend
|
||||
# Deleting web backend
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
$BIN/v-delete-web-domain-backend $user $domain $restart
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
local_ip=$(get_real_ip $IP)
|
||||
|
||||
# Deleting domain from web.conf
|
||||
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
|
||||
|
||||
# Deleting vhost configuration
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
|
||||
# Deleting SSL configuration and certificates
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
rm -f $HOMEDIR/$user/conf/web/ssl.$domain.*
|
||||
rm -f $USER_DATA/ssl/$domain.*
|
||||
fi
|
||||
|
||||
# Deleting proxy
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
# Deleting domain from proxy cache pool
|
||||
pool="/etc/$PROXY_SYSTEM/conf.d/01_caching_pool.conf"
|
||||
if [ -e "$pool" ]; then
|
||||
sed -i "/=$domain:/d" $pool
|
||||
if [ -e "/etc/$PROXY_SYSTEM/conf.d/01_caching_pool.conf" ]; then
|
||||
sed -i "/=$domain:/d" /etc/$PROXY_SYSTEM/conf.d/01_caching_pool.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checking stats
|
||||
# Deleting web 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
|
||||
|
@ -111,68 +101,36 @@ if [ ! -z "$FTP_USER" ]; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Deleting directory
|
||||
rm -rf $HOMEDIR/$user/web/$domain
|
||||
|
||||
# Deleting logs
|
||||
rm -f /var/log/$WEB_SYSTEM/domains/$domain.log*
|
||||
rm -f /var/log/$WEB_SYSTEM/domains/$domain.bytes
|
||||
rm -f /var/log/$WEB_SYSTEM/domains/$domain.error*
|
||||
|
||||
# Deleting directory
|
||||
rm -rf $HOMEDIR/$user/web/$domain
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Deleting domain
|
||||
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
|
||||
|
||||
# Checking last SSL domain
|
||||
conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
||||
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l)
|
||||
if [ "$ssl_dom" -eq '0' ]; then
|
||||
sed -i "/.*\/$user\/.*s$WEB_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf
|
||||
fi
|
||||
|
||||
# Checking last domain
|
||||
domains=$(wc -l $USER_DATA/web.conf | cut -f1 -d ' ')
|
||||
if [ "$domains" -eq '0' ]; then
|
||||
sed -i "/.*\/$user\/.*$WEB_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf
|
||||
fi
|
||||
|
||||
# Proxy
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
# Checking last SSL proxy
|
||||
conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
last_sproxy=$(grep "SSL='yes'" $USER_DATA/web.conf)
|
||||
if [ -z "$last_sproxy" ]; then
|
||||
sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
|
||||
fi
|
||||
|
||||
# Checking last proxy
|
||||
last_proxy=$(grep -v "PROXY=''" $USER_DATA/web.conf)
|
||||
if [ -z "$last_proxy" ]; then
|
||||
sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Decrease counters
|
||||
decrease_ip_value "$ip"
|
||||
# Decreasing user counters
|
||||
decrease_ip_value "$local_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
|
||||
if [ ! -z "$ALIAS" ]; then
|
||||
aliases=$(echo $ALIAS | tr ',' '\n' | wc -l )
|
||||
decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases"
|
||||
fi
|
||||
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-web
|
||||
check_result $? "Web restart failed" >/dev/null
|
||||
|
||||
# Restartinh proxy server
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
$BIN/v-restart-proxy
|
||||
check_result $? "Proxy restart failed" >/dev/null
|
||||
|
@ -181,6 +139,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "deleted web domain $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -12,11 +12,9 @@
|
|||
|
||||
# Argument definition
|
||||
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"
|
||||
domain=$2
|
||||
dom_alias=$3
|
||||
restart=$4
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
@ -30,7 +28,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'USER DOMAIN DOM_ALIAS [RESTART]'
|
||||
validate_format 'user' 'domain' 'dom_alias'
|
||||
is_format_valid 'user' 'domain' 'dom_alias'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -40,7 +38,7 @@ get_domain_values 'web'
|
|||
ip=$(get_real_ip $IP)
|
||||
if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then
|
||||
echo "Error: alias $dom_alias doesn't exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
log_event "$E_NOTEXIST" "$ARGUMENTS"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
|
@ -49,41 +47,29 @@ fi
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining new alias string
|
||||
# Preparing domain values for the template substitution
|
||||
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/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
|
||||
# Recreating vhost
|
||||
del_web_config
|
||||
add_web_config
|
||||
prepare_web_domain_values
|
||||
|
||||
# Rebuilding vhost
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
# Rebuilding proxy configuration
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -94,8 +80,6 @@ fi
|
|||
|
||||
# Update config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
||||
|
||||
# Update counters
|
||||
decrease_user_value "$user" '$U_WEB_ALIASES'
|
||||
|
||||
# Restarting web server
|
||||
|
@ -111,6 +95,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "deleted alias $dom_alias on $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -26,8 +26,8 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$PROXY_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
|
@ -41,19 +41,11 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
|
|||
|
||||
# Defining domain parameters
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
del_web_config
|
||||
fi
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
|
||||
# Checking SSL
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
del_web_config
|
||||
fi
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
|
||||
|
@ -65,25 +57,6 @@ fi
|
|||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' ''
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' ''
|
||||
|
||||
if [ -z "$PROXY_SYSTEM" ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Checking last SSL proxy
|
||||
conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
last_sproxy=$(grep "SSL='yes'" $USER_DATA/web.conf)
|
||||
if [ -z "$last_sproxy" ]; then
|
||||
sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
|
||||
fi
|
||||
|
||||
# Checking last proxy
|
||||
last_proxy=$(grep -v "PROXY=''" $USER_DATA/web.conf)
|
||||
if [ -z "$last_proxy" ]; then
|
||||
sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
|
||||
fi
|
||||
|
||||
# Restart proxy server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v-restart-proxy
|
||||
|
@ -92,6 +65,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "disabled proxy support for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -26,7 +26,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -41,17 +41,13 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
|||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
|
||||
# Deleting domain
|
||||
del_web_config
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
del_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
|
||||
# Deleting old certificate
|
||||
|
@ -68,24 +64,6 @@ chown -R $user:$user $tmpdir
|
|||
# Update config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no'
|
||||
|
||||
# Checking last SSL domain
|
||||
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
|
||||
conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$ssl_dom" ]; then
|
||||
sed -i "/.*\/$user\/.*s$WEB_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf
|
||||
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
if [ -z "$ssl_dom" ]; then
|
||||
sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Decreasing domain value
|
||||
decrease_user_value "$user" '$U_WEB_SSL'
|
||||
|
||||
|
@ -102,6 +80,6 @@ fi
|
|||
|
||||
# Logging
|
||||
log_history "disabled ssl support for $domain"
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -26,7 +26,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'USER [RESTART]'
|
||||
validate_format 'user'
|
||||
is_format_valid 'user'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -36,128 +36,43 @@ is_object_unsuspended 'user' 'USER' "$user"
|
|||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
user_domains=0
|
||||
user_ssl=0
|
||||
user_aliases=0
|
||||
suspended_web=0
|
||||
conf=$USER_DATA/web.conf
|
||||
fields='$DOMAIN'
|
||||
nohead=1
|
||||
domain_counter=0
|
||||
# Deleting old configs
|
||||
sed -i "/.*\/$user\//d" /etc/$WEB_SYSTEM/conf.d/vesta.conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
sed -i "/.*\/$user\//d" /etc/$PROXY_SYSTEM/conf.d/vesta.conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
|
||||
fi
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
if [ "$WEB_BACKEND_POOL" = 'user' ]; then
|
||||
prepare_web_backend
|
||||
rm -f $pool/$backend_type.conf
|
||||
else
|
||||
for domain in $(v-list-web-domains $user plain |cut -f 1); do
|
||||
prepare_web_backend
|
||||
rm -f $pool/$backend_type.conf
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
# Adding log directory
|
||||
mkdir -p /var/log/$WEB_SYSTEM/domains
|
||||
chmod 771 /var/log/$WEB_SYSTEM/domains
|
||||
|
||||
# Clean up old config
|
||||
rm -f $HOMEDIR/$user/conf/tmp_*.conf
|
||||
|
||||
|
||||
# Starting loop
|
||||
for domain in $(shell_list); do
|
||||
template=$(get_object_value 'web' 'DOMAIN' "$domain" '$BACKEND')
|
||||
# Starting rebuild loop for each web domain
|
||||
for domain in $(v-list-web-domains $user plain |cut -f 1); do
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
template=$(get_object_value 'web' 'DOMAIN' "$domain" '$BACKEND')
|
||||
$BIN/v-add-web-domain-backend $user $domain $template
|
||||
fi
|
||||
|
||||
((++ domain_counter))
|
||||
rebuild_web_domain_conf
|
||||
done
|
||||
|
||||
# Touch vesta configs
|
||||
web_conf="/etc/$WEB_SYSTEM/conf.d/vesta.conf"
|
||||
touch $web_conf
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
|
||||
touch $proxy_conf
|
||||
fi
|
||||
|
||||
# Checking if there is at least 1 domain
|
||||
if [ "$domain_counter" -lt 1 ]; then
|
||||
# Deleting web configs
|
||||
rm -f $HOMEDIR/$user/conf/web/*
|
||||
sed -i "/.*\/$user\/.*$WEB_SYSTEM.conf/d" $web_conf
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $proxy_conf
|
||||
fi
|
||||
else
|
||||
# Clean web configs
|
||||
sed -i "/.*\/$user\/.*.conf/d" $web_conf
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
sed -i "/.*\/$user\/.*.conf/d" $proxy_conf
|
||||
fi
|
||||
|
||||
# Renaming tmp config
|
||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_$WEB_SYSTEM.conf"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
mv $tmp_conf $conf
|
||||
|
||||
# Checking include
|
||||
web_include=$(grep "$conf" $web_conf )
|
||||
if [ -z "$web_include" ] && [ "$WEB_SYSTEM" != 'nginx' ]; then
|
||||
echo "Include $conf" >> $web_conf
|
||||
fi
|
||||
if [ -z "$web_include" ] && [ "$WEB_SYSTEM" = 'nginx' ]; then
|
||||
echo "include $conf;" >> $web_conf
|
||||
fi
|
||||
|
||||
# Checking SSL
|
||||
if [ "$ssl_change" = 'yes' ]; then
|
||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_s$WEB_SYSTEM.conf"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
mv $tmp_conf $conf
|
||||
ssl_include=$(grep "$conf" $web_conf )
|
||||
if [ -z "$ssl_include" ] && [ "$WEB_SYSTEM" != 'nginx' ]; then
|
||||
echo "Include $conf" >> $web_conf
|
||||
fi
|
||||
if [ -z "$ssl_include" ] && [ "$WEB_SYSTEM" = 'nginx' ]; then
|
||||
echo "include $conf;" >> $web_conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
if [ "$proxy_change" = 'yes' ]; then
|
||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_$PROXY_SYSTEM.conf"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
mv $tmp_conf $conf
|
||||
proxy_include=$(grep "$conf" $proxy_conf )
|
||||
if [ -z "$proxy_include" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
else
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
sed -i "/.*\/$user\/.*$PROXY_SYSTEM.conf/d" $proxy_conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf
|
||||
fi
|
||||
|
||||
# Checking SSL proxy
|
||||
if [ "$proxy_change" = 'yes' ] && [ "$ssl_change" = 'yes' ]; then
|
||||
tmp_conf="$HOMEDIR/$user/conf/web/tmp_s$PROXY_SYSTEM.conf"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
mv $tmp_conf $conf
|
||||
proxy_include=$(grep "$conf" $proxy_conf )
|
||||
if [ -z "$proxy_include" ]; then
|
||||
echo "include $conf;" >> $proxy_conf
|
||||
fi
|
||||
else
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
sed -i "/.*\/$user\/.*s$PROXY_SYSTEM.conf/d" $proxy_conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Updating counters
|
||||
update_user_value "$user" '$SUSPENDED_WEB' "$suspended_web"
|
||||
update_user_value "$user" '$U_WEB_DOMAINS' "$user_domains"
|
||||
update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
|
||||
update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
|
||||
# Updating user counters
|
||||
$BIN/v-update-user-counters $user
|
||||
|
||||
# Restarting web server
|
||||
if [ "$restart" != 'no' ]; then
|
||||
|
@ -171,6 +86,6 @@ if [ "$restart" != 'no' ]; then
|
|||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -29,7 +29,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
|
@ -42,44 +42,31 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
|||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
SUSPENDED='yes'
|
||||
ip=$(get_real_ip $IP)
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
prepare_web_domain_values
|
||||
|
||||
# Recreating vhost
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
# Check SSL
|
||||
# Rebuilding vhost
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
# Rebuilding proxy configuration
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
# Checking proxy SSL
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
@ -100,6 +87,6 @@ if [ "$restart" != 'no' ]; then
|
|||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
|
@ -27,7 +27,7 @@ source $VESTA/conf/vesta.conf
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'USER DOMAIN [RESTART]'
|
||||
validate_format 'user' 'domain'
|
||||
is_format_valid 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
|
@ -40,39 +40,27 @@ is_object_suspended 'web' 'DOMAIN' "$domain"
|
|||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
SUSPENDED='no'
|
||||
ip=$(get_real_ip $IP)
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
prepare_web_domain_values
|
||||
|
||||
# Recreating vhost
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
# Checking SSL
|
||||
# Rebuilding vhost
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
# Rebuilding proxy configuration
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
# Checking proxy SSL
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
del_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -97,6 +85,6 @@ if [ "$restart" != 'no' ]; then
|
|||
fi
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
log_event "$OK" "$ARGUMENTS"
|
||||
|
||||
exit
|
||||
|
|
804
func/domain.sh
804
func/domain.sh
|
@ -1,216 +1,378 @@
|
|||
#----------------------------------------------------------#
|
||||
# WEB #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Web template check
|
||||
is_web_template_valid() {
|
||||
t="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||
s="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.stpl"
|
||||
if [ ! -e $t ] || [ ! -e $s ]; then
|
||||
echo "Error: web template $template not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
template=$1
|
||||
if [ -z "$template" ]; then
|
||||
template=$(grep WEB_TEMPLATE $USER_DATA/user.conf |cut -f2 -d \')
|
||||
if [ -z "$template" ]; then
|
||||
template="default"
|
||||
fi
|
||||
fi
|
||||
tpl="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
|
||||
stpl="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.stpl"
|
||||
if [ ! -e "$tpl" ] || [ ! -e "$stpl" ]; then
|
||||
check_result $E_NOTEXIST "$template web template doesn't exist"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Proxy template check
|
||||
is_proxy_template_valid() {
|
||||
proxy=$1
|
||||
t="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
|
||||
s="$WEBTPL/$PROXY_SYSTEM/$proxy.stpl"
|
||||
if [ ! -e $t ] || [ ! -e $s ]; then
|
||||
echo "Error: proxy template $proxy not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
if [ ! -z "$PROXY_SYSTEM" ]; then
|
||||
proxy=$1
|
||||
if [ -z "$proxy" ]; then
|
||||
proxy=$(grep PROXY_TEMPLATE $USER_DATA/user.conf |cut -f2 -d \')
|
||||
if [ -z "$proxy" ]; then
|
||||
proxy="default"
|
||||
fi
|
||||
fi
|
||||
tpl="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
|
||||
stpl="$WEBTPL/$PROXY_SYSTEM/$proxy.stpl"
|
||||
if [ ! -e "$tpl" ] || [ ! -e "$stpl" ]; then
|
||||
check_result $E_NOTEXIST "$proxy proxy template doesn't exist"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Backend template check
|
||||
is_web_backend_template_valid() {
|
||||
if [ ! -z "$1" ]; then
|
||||
template=$1
|
||||
else
|
||||
template=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf)
|
||||
is_backend_template_valid() {
|
||||
if [ ! -e "$WEBTPL/$WEB_BACKEND/$1.tpl" ]; then
|
||||
check_result $E_NOTEXIST "$backend backend template doesn't exist"
|
||||
fi
|
||||
if [ -z "$template" ]; then
|
||||
if [ -e "$WEBTPL/$WEB_BACKEND/default.tpl" ]; then
|
||||
sed -i "s/^WEB_DOMAINS/BACKEND_TEMPLATE='default'\nWEB_DOMAINS/g" \
|
||||
$USER_DATA/user.conf
|
||||
template='default'
|
||||
else
|
||||
echo "Error: backend template default not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
}
|
||||
|
||||
# Web domain existence check
|
||||
is_web_domain_new() {
|
||||
web=$(grep -F -H "DOMAIN='$1'" $VESTA/data/users/*/web.conf)
|
||||
if [ ! -z "$web" ]; then
|
||||
if [ "$type" == 'web' ]; then
|
||||
check_result $E_EXISTS "Web domain $1 exist"
|
||||
fi
|
||||
else
|
||||
template=$(echo "$template"|cut -f 2 -d \'|head -n1)
|
||||
if [ ! -e "$WEBTPL/$WEB_BACKEND/$template.tpl" ]; then
|
||||
echo "Error: backend template $template not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
web_user=$(echo "$web" |cut -f 7 -d /)
|
||||
if [ "$web_user" != "$user" ]; then
|
||||
check_result $E_EXISTS "Web domain $1 exist"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Backend pool check
|
||||
is_web_backend_pool_valid(){
|
||||
# Web alias existence check
|
||||
is_web_alias_new() {
|
||||
web_alias=$(grep -wH "$1" $VESTA/data/users/*/web.conf)
|
||||
if [ ! -z "$web_alias" ]; then
|
||||
a1=$(echo "$web_alias" |grep -F "'$1'" |cut -f 7 -d /)
|
||||
if [ ! -z "$a1" ] && [ "$2" == "web" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
if [ ! -z "$a1" ] && [ "$a1" != "$user" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
a2=$(echo "$web_alias" |grep -F "'$1," |cut -f 7 -d /)
|
||||
if [ ! -z "$a2" ] && [ "$2" == "web" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
if [ ! -z "$a2" ] && [ "$a2" != "$user" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
a3=$(echo "$web_alias" |grep -F ",$1," |cut -f 7 -d /)
|
||||
if [ ! -z "$a3" ] && [ "$2" == "web" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
if [ ! -z "$a3" ] && [ "$a3" != "$user" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
a4=$(echo "$web_alias" |grep -F ",$1'" |cut -f 7 -d /)
|
||||
if [ ! -z "$a4" ] && [ "$2" == "web" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
if [ ! -z "$a4" ] && [ "$a4" != "$user" ]; then
|
||||
check_result $E_EXISTS "Web alias $1 exists"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Prepare web backend
|
||||
prepare_web_backend() {
|
||||
if [ -d "/etc/php-fpm.d" ]; then
|
||||
pool="/etc/php-fpm.d"
|
||||
fi
|
||||
if [ -d "/etc/php5/fpm/pool.d" ]; then
|
||||
pool="/etc/php5/fpm/pool.d"
|
||||
fi
|
||||
if [ -d "/etc/php-fpm-5.5.d" ]; then
|
||||
pool="/etc/php-fpm-5.5.d"
|
||||
fi
|
||||
if [ ! -e "$pool" ]; then
|
||||
echo "Error: backend pool directory not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
pool=$(find /etc/php* -type d \( -name "pool.d" -o -name "*fpm.d" \))
|
||||
if [ ! -e "$pool" ]; then
|
||||
check_result $E_NOTEXIST "php-fpm pool doesn't exist"
|
||||
fi
|
||||
fi
|
||||
|
||||
backend_type="$domain"
|
||||
if [ "$WEB_BACKEND_POOL" = 'user' ]; then
|
||||
backend_type="$user"
|
||||
fi
|
||||
if [ -e "$pool/$backend_type.conf" ]; then
|
||||
backend_lsnr=$(grep "listen =" $pool/$backend_type.conf)
|
||||
backend_lsnr=$(echo "$backend_lsnr" |cut -f 2 -d = |sed "s/ //")
|
||||
if [ ! -z "$(echo $backend_lsnr |grep /)" ]; then
|
||||
backend_lsnr="unix:$backend_lsnr"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Prepare web aliases
|
||||
prepare_web_aliases() {
|
||||
i=1
|
||||
for tmp_alias in ${1//,/ }; do
|
||||
tmp_alias_idn="$tmp_alias"
|
||||
if [[ "$tmp_alias" = *[![:ascii:]]* ]]; then
|
||||
tmp_alias_idn=$(idn -t --quiet -a $tmp_alias)
|
||||
fi
|
||||
if [[ $i -eq 1 ]]; then
|
||||
aliases="$tmp_alias"
|
||||
aliases_idn="$tmp_alias_idn"
|
||||
alias_string="ServerAlias $tmp_alias_idn"
|
||||
else
|
||||
aliases="$aliases,$tmp_alias"
|
||||
aliases_idn="$aliases_idn,$tmp_alias_idn"
|
||||
if (( $i % 100 == 0 )); then
|
||||
alias_string="$alias_string\n ServerAlias $tmp_alias_idn"
|
||||
else
|
||||
alias_string="$alias_string $tmp_alias_idn"
|
||||
fi
|
||||
fi
|
||||
alias_number=$i
|
||||
((i++))
|
||||
done
|
||||
}
|
||||
|
||||
# Update web domain values
|
||||
prepare_web_domain_values() {
|
||||
if [[ "$domain" = *[![:ascii:]]* ]]; then
|
||||
domain_idn=$(idn -t --quiet -a $domain)
|
||||
else
|
||||
domain_idn=$domain
|
||||
fi
|
||||
group="$user"
|
||||
email="info@$domain"
|
||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
sdocroot="$docroot"
|
||||
if [ "$SSL_HOME" = 'single' ]; then
|
||||
sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ;
|
||||
fi
|
||||
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
prepare_web_backend
|
||||
fi
|
||||
|
||||
server_alias=''
|
||||
alias_string=''
|
||||
aliases_idn=''
|
||||
prepare_web_aliases $ALIAS
|
||||
|
||||
ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
|
||||
ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
|
||||
ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
|
||||
ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
|
||||
if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then
|
||||
ssl_ca_str='#'
|
||||
fi
|
||||
if [ "$SUSPENDED" = 'yes' ]; then
|
||||
docroot="$VESTA/data/templates/web/suspend"
|
||||
sdocroot="$VESTA/data/templates/web/suspend"
|
||||
fi
|
||||
}
|
||||
|
||||
# Add web config
|
||||
add_web_config() {
|
||||
conf="$HOMEDIR/$user/conf/web/$1.conf"
|
||||
if [[ "$2" =~ stpl$ ]]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$1.conf"
|
||||
fi
|
||||
|
||||
cat $WEBTPL/$1/$WEB_BACKEND/$2 | \
|
||||
sed -e "s|%ip%|$local_ip|g" \
|
||||
-e "s|%domain%|$domain|g" \
|
||||
-e "s|%domain_idn%|$domain_idn|g" \
|
||||
-e "s|%alias%|${aliases//,/ }|g" \
|
||||
-e "s|%alias_idn%|${aliases_idn//,/ }|g" \
|
||||
-e "s|%alias_string%|$alias_string|g" \
|
||||
-e "s|%email%|info@$domain|g" \
|
||||
-e "s|%web_system%|$WEB_SYSTEM|g" \
|
||||
-e "s|%web_port%|$WEB_PORT|g" \
|
||||
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
|
||||
-e "s|%backend_lsnr%|$backend_lsnr|g" \
|
||||
-e "s|%rgroups%|$WEB_RGROUPS|g" \
|
||||
-e "s|%proxy_system%|$PROXY_SYSTEM|g" \
|
||||
-e "s|%proxy_port%|$PROXY_PORT|g" \
|
||||
-e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \
|
||||
-e "s/%proxy_extentions%/${PROXY_EXT//,/|}/g" \
|
||||
-e "s|%user%|$user|g" \
|
||||
-e "s|%group%|$group|g" \
|
||||
-e "s|%home%|$HOMEDIR|g" \
|
||||
-e "s|%docroot%|$HOMEDIR/$user/web/$domain/public_html|g" \
|
||||
-e "s|%sdocroot%|$HOMEDIR/$user/web/$domain/public_html|g" \
|
||||
-e "s|%ssl_crt%|$ssl_crt|g" \
|
||||
-e "s|%ssl_key%|$ssl_key|g" \
|
||||
-e "s|%ssl_pem%|$ssl_pem|g" \
|
||||
-e "s|%ssl_ca_str%|$ssl_ca_str|g" \
|
||||
-e "s|%ssl_ca%|$ssl_ca|g" \
|
||||
>> $conf
|
||||
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
|
||||
if [ -z "$(grep "$conf" /etc/$1/conf.d/vesta.conf)" ]; then
|
||||
if [ "$WEB_SYSTEM" != 'nginx' ]; then
|
||||
echo "Include $conf" >> /etc/$1/conf.d/vesta.conf
|
||||
else
|
||||
echo "include $conf;" >> /etc/$1/conf.d/vesta.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
trigger="${2/.*pl/.sh}"
|
||||
if [ -x "$WEBTPL/$1/$WEB_BACKEND/$trigger" ]; then
|
||||
$WEBTPL/$1/$WEB_BACKEND/$trigger \
|
||||
$user $domain $ip $HOMEDIR $HOMEDIR/$user/web/$domain/public_html
|
||||
fi
|
||||
}
|
||||
|
||||
# Get config top and bottom line number
|
||||
get_web_config_lines() {
|
||||
tpl_lines=$(egrep -ni "name %domain_idn%" $1 |grep -w %domain_idn%)
|
||||
tpl_lines=$(echo "$tpl_lines" |cut -f 1 -d :)
|
||||
tpl_last_line=$(wc -l $1 |cut -f 1 -d ' ')
|
||||
if [ -z "$tpl_lines" ]; then
|
||||
check_result $E_PARSING "can't parse template $1"
|
||||
fi
|
||||
|
||||
vhost_lines=$(grep -niF "name $domain_idn" $2)
|
||||
vhost_lines=$(echo "$vhost_lines" |egrep "$domain_idn$|$domain_idn ")
|
||||
vhost_lines=$(echo "$vhost_lines" |cut -f 1 -d :)
|
||||
if [ -z "$vhost_lines" ]; then
|
||||
check_result $E_PARSING "can't parse config $2"
|
||||
fi
|
||||
|
||||
top_line=$((vhost_lines + 1 - tpl_lines))
|
||||
bottom_line=$((top_line - 1 + tpl_last_line))
|
||||
multi=$(sed -n "$top_line,$bottom_line p" $2 |grep ServerAlias |wc -l)
|
||||
if [ "$multi" -ge 2 ]; then
|
||||
bottom_line=$((bottom_line + multi -1))
|
||||
fi
|
||||
}
|
||||
|
||||
# Replace web config
|
||||
replace_web_config() {
|
||||
get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
|
||||
sed -i "$top_line,$bottom_line s|$old|$new|g" $conf
|
||||
}
|
||||
|
||||
# Delete web configuartion
|
||||
del_web_config() {
|
||||
conf="$HOMEDIR/$user/conf/web/$1.conf"
|
||||
if [[ "$2" =~ stpl$ ]]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$1.conf"
|
||||
fi
|
||||
|
||||
get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
|
||||
sed -i "$top_line,$bottom_line d" $conf
|
||||
|
||||
web_domains=$(grep DOMAIN $USER_DATA/web.conf |wc -l)
|
||||
if [ "$web_domains" -eq '0' ]; then
|
||||
sed -i "/.*\/$user\/.*$WEB_SYSTEM.conf/d" /etc/$1/conf.d/vesta.conf
|
||||
rm -f $HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf
|
||||
rm -f $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf
|
||||
fi
|
||||
}
|
||||
|
||||
# SSL certificate verification
|
||||
is_web_domain_cert_valid() {
|
||||
if [ ! -e "$ssl_dir/$domain.crt" ]; then
|
||||
echo "Error: $ssl_dir/$domain.crt not found"
|
||||
log_event "$E_NOTEXIST" "$ARGUMENTS"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
backend="$domain"
|
||||
if [ "$WEB_BACKEND_POOL" = 'user' ]; then
|
||||
backend="$user"
|
||||
if [ ! -e "$ssl_dir/$domain.key" ]; then
|
||||
echo "Error: $ssl_dir/$domain.key not found"
|
||||
log_event "$E_NOTEXIST" "$ARGUMENTS"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1)
|
||||
if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then
|
||||
echo "Error: SSL Certificate is not valid"
|
||||
log_event "$E_INVALID" "$ARGUMENTS"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
|
||||
if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then
|
||||
if [ ! -e "$ssl_dir/$domain.ca" ]; then
|
||||
echo "Error: Certificate Authority not found"
|
||||
log_event "$E_NOTEXIST" "$ARGUMENTS"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$ssl_dir/$domain.ca" ]; then
|
||||
s1=$(openssl x509 -text -in $ssl_dir/$domain.crt 2>/dev/null)
|
||||
s1=$(echo "$s1" |grep Issuer |awk -F = '{print $6}' |head -n1)
|
||||
s2=$(openssl x509 -text -in $ssl_dir/$domain.ca 2>/dev/null)
|
||||
s2=$(echo "$s2" |grep Subject |awk -F = '{print $6}' |head -n1)
|
||||
if [ "$s1" != "$s2" ]; then
|
||||
echo "Error: SSL intermediate chain is not valid"
|
||||
log_event "$E_NOTEXIST" "$ARGUMENTS"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
fi
|
||||
|
||||
key_vrf=$(grep 'PRIVATE KEY' $ssl_dir/$domain.key | wc -l)
|
||||
if [ "$key_vrf" -ne 2 ]; then
|
||||
echo "Error: SSL Key is not valid"
|
||||
log_event "$E_INVALID" "$ARGUMENTS"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
|
||||
openssl s_server -quiet -cert $ssl_dir/$domain.crt \
|
||||
-key $ssl_dir/$domain.key >> /dev/null 2>&1 &
|
||||
pid=$!
|
||||
sleep 0.5
|
||||
disown &> /dev/null
|
||||
kill $pid &> /dev/null
|
||||
if [ "$?" -ne '0' ]; then
|
||||
echo "Error: ssl certificate key pair is not valid"
|
||||
log_event "$E_INVALID" "$ARGUMENTS"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# DNS #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# DNS template check
|
||||
is_dns_template_valid() {
|
||||
t="$DNSTPL/$template.tpl"
|
||||
if [ ! -e $t ]; then
|
||||
echo "Error: dns template $template not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result $E_NOTEXIST "dns template $template doesn't exist"
|
||||
fi
|
||||
}
|
||||
|
||||
# Checking domain existance
|
||||
is_domain_new() {
|
||||
type="$1"
|
||||
dom=${2-$domain}
|
||||
object=${3-domain}
|
||||
|
||||
# Check web domain
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
web=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/web.conf)
|
||||
fi
|
||||
if [ ! -z "$web" ] && [ "$type" == 'web' ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
if [ ! -z "$web" ]; then
|
||||
web_user=$(echo "$web" |cut -f 7 -d /)
|
||||
if [ "$web_user" != "$user" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check dns domain
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
dns=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/dns.conf)
|
||||
fi
|
||||
if [ ! -z "$dns" ] && [ "$type" == 'dns' ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
# DNS domain existence check
|
||||
is_dns_domain_new() {
|
||||
dns=$(ls $VESTA/data/users/*/dns/$1.conf 2>/dev/null)
|
||||
if [ ! -z "$dns" ]; then
|
||||
if [ "$2" == 'dns' ]; then
|
||||
check_result $E_EXISTS "DNS domain $1 exists"
|
||||
fi
|
||||
dns_user=$(echo "$dns" |cut -f 7 -d /)
|
||||
if [ "$dns_user" != "$user" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
check_result $E_EXISTS "DNS domain $1 exists"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check mail domain
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
mail=$(grep -F -H "DOMAIN='$dom'" $VESTA/data/users/*/mail.conf)
|
||||
fi
|
||||
if [ ! -z "$mail" ] && [ "$type" == 'mail' ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
if [ ! -z "$mail" ]; then
|
||||
mail_user=$(echo "$mail" |cut -f 7 -d /)
|
||||
if [ "$mail_user" != "$user" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check web aliases
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
web_alias=$(grep -w $dom $VESTA/data/users/*/web.conf)
|
||||
fi
|
||||
if [ ! -z "$web_alias" ]; then
|
||||
c1=$(grep -HF "'$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
||||
c2=$(grep -HF "'$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
||||
c3=$(grep -HF ",$dom," $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
||||
c4=$(grep -HF ",$dom'" $VESTA/data/users/*/web.conf | cut -f 7 -d /)
|
||||
if [ ! -z "$c1" ] && [ "$type" == "web" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
if [ ! -z "$c1" ] && [ "$c1" != "$user" ]; then
|
||||
echo "Error: domain $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
if [ ! -z "$c2" ] && [ "$type" == "web" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
if [ ! -z "$c2" ] && [ "$c2" != "$user" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
if [ ! -z "$c3" ] && [ "$type" == "web" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
if [ ! -z "$c3" ] && [ "$c3" != "$user" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
|
||||
if [ ! -z "$c4" ] && [ "$type" == "web" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
if [ ! -z "$c4" ] && [ "$c4" != "$user" ]; then
|
||||
echo "Error: $object $dom exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Checking mail account existance
|
||||
is_mail_new() {
|
||||
check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf)
|
||||
if [ ! -z "$check_acc" ]; then
|
||||
echo "Error: mail account $1 exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
|
||||
check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
|
||||
if [ ! -z "$check_als" ]; then
|
||||
echo "Error: mail alias $1 exist"
|
||||
log_event "$E_EXISTS" "$EVENT"
|
||||
exit $E_EXISTS
|
||||
fi
|
||||
}
|
||||
|
||||
# Update domain zone
|
||||
|
@ -289,238 +451,6 @@ sort_dns_records() {
|
|||
mv -f $conf.tmp $conf
|
||||
}
|
||||
|
||||
# Add web config
|
||||
add_web_config() {
|
||||
cat $tpl_file | \
|
||||
sed -e "s|%ip%|$ip|g" \
|
||||
-e "s|%web_system%|$WEB_SYSTEM|g" \
|
||||
-e "s|%web_port%|$WEB_PORT|g" \
|
||||
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
|
||||
-e "s|%backend_lsnr%|$backend_lsnr|g" \
|
||||
-e "s|%rgroups%|$WEB_RGROUPS|g" \
|
||||
-e "s|%proxy_system%|$PROXY_SYSTEM|g" \
|
||||
-e "s|%proxy_port%|$PROXY_PORT|g" \
|
||||
-e "s|%proxy_ssl_port%|$PROXY_SSL_PORT|g" \
|
||||
-e "s/%proxy_extentions%/${PROXY_EXT//,/|}/g" \
|
||||
-e "s|%domain_idn%|$domain_idn|g" \
|
||||
-e "s|%domain%|$domain|g" \
|
||||
-e "s|%user%|$user|g" \
|
||||
-e "s|%group%|$group|g" \
|
||||
-e "s|%home%|$HOMEDIR|g" \
|
||||
-e "s|%docroot%|$docroot|g" \
|
||||
-e "s|%sdocroot%|$sdocroot|g" \
|
||||
-e "s|%email%|$email|g" \
|
||||
-e "s|%alias_string%|$alias_string|g" \
|
||||
-e "s|%alias_idn%|${aliases_idn//,/ }|g" \
|
||||
-e "s|%alias%|${aliases//,/ }|g" \
|
||||
-e "s|%ssl_crt%|$ssl_crt|g" \
|
||||
-e "s|%ssl_key%|$ssl_key|g" \
|
||||
-e "s|%ssl_pem%|$ssl_pem|g" \
|
||||
-e "s|%ssl_ca_str%|$ssl_ca_str|g" \
|
||||
-e "s|%ssl_ca%|$ssl_ca|g" \
|
||||
>> $conf
|
||||
}
|
||||
|
||||
# Get config top and bottom line numbers
|
||||
get_web_config_brds() {
|
||||
|
||||
serv_line=$(egrep -ni "Name %domain_idn%($| )" $tpl_file |cut -f 1 -d :)
|
||||
if [ -z "$serv_line" ]; then
|
||||
log_event "$E_PARSING" "$EVENT"
|
||||
return $E_PARSING
|
||||
fi
|
||||
|
||||
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
|
||||
bfr_line=$((serv_line - 1))
|
||||
aftr_line=$((last_line - serv_line - 1))
|
||||
|
||||
str=$(grep -niF "Name $domain_idn" $conf |egrep "$domain_idn$|$domain_idn ")
|
||||
str=$(echo "$str" |cut -f 1 -d :)
|
||||
top_line=$((str - serv_line + 1))
|
||||
bottom_line=$((top_line + last_line -1))
|
||||
multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
|
||||
if [ "$multi" -ge 2 ]; then
|
||||
bottom_line=$((bottom_line + multi -1))
|
||||
fi
|
||||
}
|
||||
|
||||
# Replace web config
|
||||
replace_web_config() {
|
||||
get_web_config_brds || exit $?
|
||||
clean_new=$(echo "$new" | sed \
|
||||
-e 's/\\/\\\\/g' \
|
||||
-e 's/&/\\&/g' \
|
||||
-e 's/\//\\\//g')
|
||||
clean_old=$(echo "$old" | sed \
|
||||
-e 's/\\/\\\\/g' \
|
||||
-e 's/&/\\&/g' \
|
||||
-e 's/\//\\\//g')
|
||||
|
||||
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
|
||||
}
|
||||
|
||||
# Get domain variables
|
||||
get_domain_values() {
|
||||
for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
|
||||
eval $line
|
||||
done
|
||||
}
|
||||
|
||||
# Get backend values
|
||||
get_domain_backend_values() {
|
||||
lsnr=$(grep "listen =" $pool/$backend.conf |cut -f 2 -d = |sed "s/ //")
|
||||
backend_lsnr="$lsnr"
|
||||
if [ ! -z "$(echo $lsnr |grep /)" ]; then
|
||||
backend_lsnr="unix:$backend_lsnr"
|
||||
fi
|
||||
}
|
||||
|
||||
# SSL certificate verification
|
||||
is_web_domain_cert_valid() {
|
||||
if [ ! -e "$ssl_dir/$domain.crt" ]; then
|
||||
echo "Error: $ssl_dir/$domain.crt not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
if [ ! -e "$ssl_dir/$domain.key" ]; then
|
||||
echo "Error: $ssl_dir/$domain.key not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
|
||||
crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1)
|
||||
if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then
|
||||
echo "Error: SSL Certificate is not valid"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
|
||||
if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then
|
||||
if [ ! -e "$ssl_dir/$domain.ca" ]; then
|
||||
echo "Error: Certificate Authority not found"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e "$ssl_dir/$domain.ca" ]; then
|
||||
s1=$(openssl x509 -text -in $ssl_dir/$domain.crt 2>/dev/null)
|
||||
s1=$(echo "$s1" |grep Issuer |awk -F = '{print $6}' |head -n1)
|
||||
s2=$(openssl x509 -text -in $ssl_dir/$domain.ca 2>/dev/null)
|
||||
s2=$(echo "$s2" |grep Subject |awk -F = '{print $6}' |head -n1)
|
||||
if [ "$s1" != "$s2" ]; then
|
||||
echo "Error: SSL intermediate chain is not valid"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
fi
|
||||
fi
|
||||
|
||||
key_vrf=$(grep 'PRIVATE KEY' $ssl_dir/$domain.key | wc -l)
|
||||
if [ "$key_vrf" -ne 2 ]; then
|
||||
echo "Error: SSL Key is not valid"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
|
||||
openssl s_server -quiet -cert $ssl_dir/$domain.crt \
|
||||
-key $ssl_dir/$domain.key >> /dev/null 2>&1 &
|
||||
pid=$!
|
||||
sleep 0.5
|
||||
disown &> /dev/null
|
||||
kill $pid &> /dev/null
|
||||
if [ "$?" -ne '0' ]; then
|
||||
echo "Error: ssl certificate key pair is not valid"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
}
|
||||
|
||||
# Delete web configuartion
|
||||
del_web_config() {
|
||||
get_web_config_brds || exit $?
|
||||
sed -i "$top_line,$bottom_line d" $conf
|
||||
}
|
||||
|
||||
# Update web domain values
|
||||
upd_web_domain_values() {
|
||||
group="$user"
|
||||
email="info@$domain"
|
||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
sdocroot=$docroot
|
||||
if [ "$SSL_HOME" = 'single' ]; then
|
||||
sdocroot="$HOMEDIR/$user/web/$domain/public_shtml" ;
|
||||
fi
|
||||
if [ ! -z "$WEB_BACKEND" ]; then
|
||||
is_web_backend_pool_valid
|
||||
get_domain_backend_values
|
||||
fi
|
||||
i=1
|
||||
j=1
|
||||
OLD_IFS="$IFS"
|
||||
IFS=','
|
||||
server_alias=''
|
||||
alias_string=''
|
||||
aliases_idn=''
|
||||
|
||||
for dalias in $ALIAS; do
|
||||
dalias=$(idn -t --quiet -a $dalias)
|
||||
check_8k="$server_alias $dalias"
|
||||
if [ "${#check_8k}" -ge '8100' ]; then
|
||||
if [ "$j" -eq 1 ]; then
|
||||
alias_string="ServerAlias $server_alias"
|
||||
else
|
||||
alias_string="$alias_string\n ServerAlias $server_alias"
|
||||
fi
|
||||
j=2
|
||||
server_alias=''
|
||||
fi
|
||||
if [ "$i" -eq 1 ]; then
|
||||
aliases_idn="$dalias"
|
||||
server_alias="$dalias"
|
||||
alias_string="ServerAlias $server_alias"
|
||||
else
|
||||
aliases_idn="$aliases_idn,$dalias"
|
||||
server_alias="$server_alias $dalias"
|
||||
fi
|
||||
i=2
|
||||
done
|
||||
|
||||
if [ $j -gt 1 ]; then
|
||||
alias_string="$alias_string\n ServerAlias $server_alias"
|
||||
else
|
||||
alias_string="ServerAlias $server_alias"
|
||||
fi
|
||||
|
||||
IFS=$OLD_IFS
|
||||
if [ "$ELOG" = 'no' ]; then
|
||||
elog='#'
|
||||
else
|
||||
elog=''
|
||||
fi
|
||||
|
||||
if [ "$CGI" != 'yes' ]; then
|
||||
cgi='#'
|
||||
cgi_option='-ExecCGI'
|
||||
else
|
||||
cgi=''
|
||||
cgi_option='+ExecCGI'
|
||||
fi
|
||||
|
||||
ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
|
||||
ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
|
||||
ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
|
||||
ssl_ca="$HOMEDIR/$user/conf/web/ssl.$domain.ca"
|
||||
if [ ! -e "$USER_DATA/ssl/$domain.ca" ]; then
|
||||
ssl_ca_str='#'
|
||||
fi
|
||||
|
||||
if [ "$SUSPENDED" = 'yes' ]; then
|
||||
docroot="$VESTA/data/templates/web/suspend"
|
||||
sdocroot="$VESTA/data/templates/web/suspend"
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if this is a last record
|
||||
is_dns_record_critical() {
|
||||
str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
|
||||
|
@ -529,7 +459,7 @@ is_dns_record_critical() {
|
|||
records=$(grep "TYPE='$TYPE'" $USER_DATA/dns/$domain.conf| wc -l)
|
||||
if [ $records -le 1 ]; then
|
||||
echo "Error: at least one $TYPE record should remain active"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
log_event "$E_INVALID" "$ARGUMENTS"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
fi
|
||||
|
@ -551,7 +481,7 @@ is_dns_fqnd() {
|
|||
r=$(echo $r|sed -e "s/\.$//")
|
||||
msg="$t record $r should be a fully qualified domain name (FQDN)"
|
||||
echo "Error: $msg"
|
||||
log_event "$E_INVALID" "$EVENT"
|
||||
log_event "$E_INVALID" "$ARGUMENTS"
|
||||
exit $E_INVALID
|
||||
fi
|
||||
fi
|
||||
|
@ -569,10 +499,68 @@ is_dns_nameserver_valid() {
|
|||
a_record=$(echo $r |cut -f 1 -d '.')
|
||||
n_record=$(grep "RECORD='$a_record'" $zone| grep "TYPE='A'")
|
||||
if [ -z "$n_record" ]; then
|
||||
echo "Error: corresponding A record $a_record.$d does not exist"
|
||||
log_event "$E_NOTEXIST" "$EVENT"
|
||||
exit $E_NOTEXIST
|
||||
check_result $E_NOTEXIST "IN A $a_record.$d does not exist"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# MAIL #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Mail domain existence check
|
||||
is_mail_domain_new() {
|
||||
mail=$(ls $VESTA/data/users/*/mail/$1.conf 2>/dev/null)
|
||||
if [ ! -z "$mail" ]; then
|
||||
if [ "$2" == 'mail' ]; then
|
||||
check_result $E_EXISTS "Mail domain $1 exists"
|
||||
fi
|
||||
mail_user=$(echo "$mail" |cut -f 7 -d /)
|
||||
if [ "$mail_user" != "$user" ]; then
|
||||
check_result $E_EXISTS "Mail domain $1 exists"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Checking mail account existance
|
||||
is_mail_new() {
|
||||
check_acc=$(grep "ACCOUNT='$1'" $USER_DATA/mail/$domain.conf)
|
||||
if [ ! -z "$check_acc" ]; then
|
||||
check_result $E_EXIST "mail account $1 is already exists"
|
||||
fi
|
||||
check_als=$(awk -F "ALIAS='" '{print $2}' $USER_DATA/mail/$domain.conf )
|
||||
check_als=$(echo "$check_als" | cut -f 1 -d "'" | grep -w $1)
|
||||
if [ ! -z "$check_als" ]; then
|
||||
check_result $E_EXIST "mail alias $1 is already exists"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# CMN #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Checking domain existance
|
||||
is_domain_new() {
|
||||
type=$1
|
||||
for object in ${2//,/ }; do
|
||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||
is_web_domain_new $object $type
|
||||
is_web_alias_new $object $type
|
||||
fi
|
||||
if [ ! -z "$DNS_SYSTEM" ]; then
|
||||
is_dns_domain_new $object $type
|
||||
fi
|
||||
if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||
is_mail_domain_new $object $type
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Get domain variables
|
||||
get_domain_values() {
|
||||
eval $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf)
|
||||
}
|
||||
|
|
192
func/rebuild.sh
192
func/rebuild.sh
|
@ -141,15 +141,11 @@ rebuild_user_conf() {
|
|||
# WEB domain rebuild
|
||||
rebuild_web_domain_conf() {
|
||||
|
||||
# Get domain values
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
get_domain_values 'web'
|
||||
ip=$(get_real_ip $IP)
|
||||
is_ip_valid $IP
|
||||
prepare_web_domain_values
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
upd_web_domain_values
|
||||
|
||||
# Rebuilding directories
|
||||
# Rebuilding domain directories
|
||||
mkdir -p $HOMEDIR/$user/web/$domain \
|
||||
$HOMEDIR/$user/web/$domain/public_html \
|
||||
$HOMEDIR/$user/web/$domain/public_shtml \
|
||||
|
@ -159,18 +155,22 @@ rebuild_web_domain_conf() {
|
|||
$HOMEDIR/$user/web/$domain/stats \
|
||||
$HOMEDIR/$user/web/$domain/logs
|
||||
|
||||
# Create domain logs
|
||||
# Creating domain logs
|
||||
if [ ! -e "/var/log/$WEB_SYSTEM/domains" ]; then
|
||||
mkdir -p /var/log/$WEB_SYSTEM/domains
|
||||
chmod 771 /var/log/$WEB_SYSTEM/domains
|
||||
fi
|
||||
touch /var/log/$WEB_SYSTEM/domains/$domain.bytes \
|
||||
/var/log/$WEB_SYSTEM/domains/$domain.log \
|
||||
/var/log/$WEB_SYSTEM/domains/$domain.error.log
|
||||
|
||||
# Create symlinks
|
||||
# Creating symlinks
|
||||
cd $HOMEDIR/$user/web/$domain/logs/
|
||||
ln -f -s /var/log/$WEB_SYSTEM/domains/$domain.log .
|
||||
ln -f -s /var/log/$WEB_SYSTEM/domains/$domain.error.log .
|
||||
cd - > /dev/null
|
||||
cd /
|
||||
|
||||
# Propagate html skeleton
|
||||
# Propagating html skeleton
|
||||
if [ ! -e "$WEBTPL/skel/document_errors/" ]; then
|
||||
cp -r $WEBTPL/skel/document_errors/ $HOMEDIR/$user/web/$domain/
|
||||
fi
|
||||
|
@ -195,35 +195,41 @@ rebuild_web_domain_conf() {
|
|||
chown -R $user:$user $HOMEDIR/$user/web/$domain/document_errors
|
||||
chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.*
|
||||
|
||||
# Adding tmp conf
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/tmp_$WEB_SYSTEM.conf"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
# Adding vhost configuration
|
||||
conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.tpl"
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.sh ]; then
|
||||
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.sh \
|
||||
$user $domain $ip $HOMEDIR $docroot
|
||||
# Adding SSL vhost configuration
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.conf"
|
||||
add_web_config "$WEB_SYSTEM" "$TPL.stpl"
|
||||
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
|
||||
fi
|
||||
|
||||
# Checking aliases
|
||||
if [ ! -z "$ALIAS" ]; then
|
||||
aliases=$(echo "$ALIAS"|tr ',' '\n'| wc -l)
|
||||
user_aliases=$((user_aliases + aliases))
|
||||
# Adding proxy configuration
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.tpl"
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
|
||||
add_web_config "$PROXY_SYSTEM" "$PROXY.stpl"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checking stats
|
||||
# Adding web stats parser
|
||||
if [ ! -z "$STATS" ]; then
|
||||
cat $WEBTPL/$STATS/$STATS.tpl |\
|
||||
sed -e "s|%ip%|$ip|g" \
|
||||
sed -e "s|%ip%|$local_ip|g" \
|
||||
-e "s|%web_system%|$WEB_SYSTEM|g" \
|
||||
-e "s|%web_port%|$WEB_PORT|g" \
|
||||
-e "s|%web_ssl_port%|$WEB_SSL_PORT|g" \
|
||||
-e "s|%backend_lsnr%|$backend_lsnr|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" \
|
||||
|
@ -231,7 +237,6 @@ rebuild_web_domain_conf() {
|
|||
-e "s|%alias%|${aliases//,/ }|g" \
|
||||
-e "s|%alias_idn%|${aliases_idn//,/ }|g" \
|
||||
> $HOMEDIR/$user/conf/web/$STATS.$domain.conf
|
||||
|
||||
if [ "$STATS" == 'awstats' ]; then
|
||||
if [ ! -e "/etc/awstats/$STATS.$domain_idn.conf" ]; then
|
||||
ln -f -s $HOMEDIR/$user/conf/web/$STATS.$domain.conf \
|
||||
|
@ -247,82 +252,15 @@ rebuild_web_domain_conf() {
|
|||
|
||||
if [ ! -z "$STATS_USER" ]; then
|
||||
stats_dir="$HOMEDIR/$user/web/$domain/stats"
|
||||
|
||||
# Adding htaccess file
|
||||
echo "AuthUserFile $stats_dir/.htpasswd" > $stats_dir/.htaccess
|
||||
echo "AuthName \"Web Statistics\"" >> $stats_dir/.htaccess
|
||||
echo "AuthType Basic" >> $stats_dir/.htaccess
|
||||
echo "Require valid-user" >> $stats_dir/.htaccess
|
||||
|
||||
# Generating htaccess user and password
|
||||
echo "$STATS_USER:$STATS_CRYPT" > $stats_dir/.htpasswd
|
||||
fi
|
||||
fi
|
||||
|
||||
# Checking SSL
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
|
||||
# Adding domain to the web conf
|
||||
conf="$HOMEDIR/$user/conf/web/tmp_s$WEB_SYSTEM.conf"
|
||||
tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.stpl"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
|
||||
cp -f $USER_DATA/ssl/$domain.crt \
|
||||
$HOMEDIR/$user/conf/web/ssl.$domain.crt
|
||||
cp -f $USER_DATA/ssl/$domain.key \
|
||||
$HOMEDIR/$user/conf/web/ssl.$domain.key
|
||||
cp -f $USER_DATA/ssl/$domain.pem \
|
||||
$HOMEDIR/$user/conf/web/ssl.$domain.pem
|
||||
if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
|
||||
cp -f $USER_DATA/ssl/$domain.ca \
|
||||
$HOMEDIR/$user/conf/web/ssl.$domain.ca
|
||||
fi
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.sh ]; then
|
||||
$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$TPL.sh \
|
||||
$user $domain $ip $HOMEDIR $sdocroot
|
||||
fi
|
||||
|
||||
user_ssl=$((user_ssl + 1))
|
||||
ssl_change='yes'
|
||||
fi
|
||||
|
||||
# Checking proxy
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/tmp_$PROXY_SYSTEM.conf"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
proxy_change='yes'
|
||||
fi
|
||||
|
||||
if [ ! -z "$PROXY_SYSTEM" ] && [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
|
||||
if [ -z "$PROXY" ]; then
|
||||
tpl_file="$WEBTPL/$PROXY_SYSTEM/default.stpl"
|
||||
fi
|
||||
conf="$HOMEDIR/$user/conf/web/tmp_s$PROXY_SYSTEM.conf"
|
||||
add_web_config
|
||||
chown root:$user $conf
|
||||
chmod 640 $conf
|
||||
proxy_change='yes'
|
||||
fi
|
||||
|
||||
if [ "$SUSPENDED" = 'yes' ]; then
|
||||
suspended_web=$((suspended_web + 1))
|
||||
fi
|
||||
user_domains=$((user_domains + 1))
|
||||
|
||||
# Running template trigger
|
||||
if [ -x $WEBTPL/$PROXY_SYSTEM/$PROXY.sh ]; then
|
||||
$WEBTPL/$PROXY_SYSTEM/$PROXY.sh $user $domain $ip $HOMEDIR $docroot
|
||||
fi
|
||||
|
||||
# Defining ftp user shell
|
||||
# Adding ftp users
|
||||
if [ -z "$FTP_SHELL" ]; then
|
||||
shell='/sbin/nologin'
|
||||
if [ -e "/usr/bin/rssh" ]; then
|
||||
|
@ -331,19 +269,15 @@ rebuild_web_domain_conf() {
|
|||
else
|
||||
shell=$FTP_SHELL
|
||||
fi
|
||||
|
||||
# Checking ftp users
|
||||
for ftp_user in ${FTP_USER//:/ }; do
|
||||
if [ -z "$(grep ^$ftp_user: /etc/passwd)" ]; then
|
||||
# Parsing ftp user variables
|
||||
position=$(echo $FTP_USER | tr ':' '\n' | grep -n '' |\
|
||||
grep ":$ftp_user$" | cut -f 1 -d:)
|
||||
ftp_path=$(echo $FTP_PATH | tr ':' '\n' | grep -n '' |\
|
||||
grep "^$position:" | cut -f 2 -d :)
|
||||
ftp_md5=$(echo $FTP_MD5 | tr ':' '\n' | grep -n '' |\
|
||||
grep "^$position:" | cut -f 2 -d :)
|
||||
position=$(echo $FTP_USER |tr ':' '\n' |grep -n '' |\
|
||||
grep ":$ftp_user$" |cut -f 1 -d:)
|
||||
ftp_path=$(echo $FTP_PATH |tr ':' '\n' |grep -n '' |\
|
||||
grep "^$position:" |cut -f 2 -d :)
|
||||
ftp_md5=$(echo $FTP_MD5 | tr ':' '\n' |grep -n '' |\
|
||||
grep "^$position:" |cut -f 2 -d :)
|
||||
|
||||
# Adding ftp user
|
||||
/usr/sbin/useradd $ftp_user \
|
||||
-s $shell \
|
||||
-o -u $(id -u $user) \
|
||||
|
@ -352,13 +286,13 @@ rebuild_web_domain_conf() {
|
|||
|
||||
# Updating ftp user password
|
||||
shadow=$(grep "^$ftp_user:" /etc/shadow)
|
||||
shdw3=$(echo "$shadow" | cut -f3 -d :)
|
||||
shdw4=$(echo "$shadow" | cut -f4 -d :)
|
||||
shdw5=$(echo "$shadow" | cut -f5 -d :)
|
||||
shdw6=$(echo "$shadow" | cut -f6 -d :)
|
||||
shdw7=$(echo "$shadow" | cut -f7 -d :)
|
||||
shdw8=$(echo "$shadow" | cut -f8 -d :)
|
||||
shdw9=$(echo "$shadow" | cut -f9 -d :)
|
||||
shdw3=$(echo "$shadow" |cut -f3 -d :)
|
||||
shdw4=$(echo "$shadow" |cut -f4 -d :)
|
||||
shdw5=$(echo "$shadow" |cut -f5 -d :)
|
||||
shdw6=$(echo "$shadow" |cut -f6 -d :)
|
||||
shdw7=$(echo "$shadow" |cut -f7 -d :)
|
||||
shdw8=$(echo "$shadow" |cut -f8 -d :)
|
||||
shdw9=$(echo "$shadow" |cut -f9 -d :)
|
||||
shadow_str="$ftp_user:$ftp_md5:$shdw3:$shdw4:$shdw5:$shdw6"
|
||||
shadow_str="$shadow_str:$shdw7:$shdw8:$shdw9"
|
||||
chmod u+w /etc/shadow
|
||||
|
@ -374,10 +308,10 @@ rebuild_web_domain_conf() {
|
|||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
for auth_user in ${AUTH_USER//:/ }; do
|
||||
# Parsing auth user variables
|
||||
position=$(echo $AUTH_USER | tr ':' '\n' | grep -n '' |\
|
||||
grep ":$auth_user$" | cut -f 1 -d:)
|
||||
auth_hash=$(echo $AUTH_HASH | tr ':' '\n' | grep -n '' |\
|
||||
grep "^$position:" | cut -f 2 -d :)
|
||||
position=$(echo $AUTH_USER |tr ':' '\n' |grep -n '' |\
|
||||
grep ":$auth_user$" |cut -f 1 -d:)
|
||||
auth_hash=$(echo $AUTH_HASH |tr ':' '\n' |grep -n '' |\
|
||||
grep "^$position:" |cut -f 2 -d :)
|
||||
|
||||
# Adding http auth user
|
||||
touch $htpasswd
|
||||
|
@ -397,9 +331,9 @@ rebuild_web_domain_conf() {
|
|||
echo "auth_basic \"$domain password access\";" > $htaccess
|
||||
echo "auth_basic_user_file $htpasswd;" >> $htaccess
|
||||
fi
|
||||
chmod 640 $htpasswd $htaccess >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
chmod 640 $htpasswd $htaccess >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# DNS domain rebuild
|
||||
|
@ -595,7 +529,7 @@ rebuild_mysql_database() {
|
|||
if [ ! -z "$send_mail" ]; then
|
||||
echo "Can't parse MySQL DB config" | $send_mail -s "$subj" $email
|
||||
fi
|
||||
log_event "$E_PARSING" "$EVENT"
|
||||
log_event "$E_PARSING" "$ARGUMENTS"
|
||||
exit $E_PARSING
|
||||
fi
|
||||
|
||||
|
@ -607,7 +541,7 @@ rebuild_mysql_database() {
|
|||
echo "Database connection to MySQL host $HOST failed" |\
|
||||
$send_mail -s "$subj" $email
|
||||
fi
|
||||
log_event "$E_CONNECT" "$EVENT"
|
||||
log_event "$E_CONNECT" "$ARGUMENTS"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
|
@ -638,7 +572,7 @@ rebuild_pgsql_database() {
|
|||
if [ ! -z "$send_mail" ]; then
|
||||
echo "Can't parse PostgreSQL config" | $send_mail -s "$subj" $email
|
||||
fi
|
||||
log_event "$E_PARSING" "$EVENT"
|
||||
log_event "$E_PARSING" "$ARGUMENTS"
|
||||
exit $E_PARSING
|
||||
fi
|
||||
|
||||
|
@ -650,7 +584,7 @@ rebuild_pgsql_database() {
|
|||
echo "Database connection to PostgreSQL host $HOST failed" |\
|
||||
$send_mail -s "$subj" $email
|
||||
fi
|
||||
log_event "$E_CONNECT" "$EVENT"
|
||||
log_event "$E_CONNECT" "$ARGUMENTS"
|
||||
exit $E_CONNECT
|
||||
fi
|
||||
|
||||
|
@ -683,7 +617,7 @@ import_mysql_database() {
|
|||
eval $host_str
|
||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ]; then
|
||||
echo "Error: mysql config parsing failed"
|
||||
log_event "$E_PARSING" "$EVENT"
|
||||
log_event "$E_PARSING" "$ARGUMENTS"
|
||||
exit $E_PARSING
|
||||
fi
|
||||
|
||||
|
@ -699,7 +633,7 @@ import_pgsql_database() {
|
|||
export PGPASSWORD="$PASSWORD"
|
||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
||||
echo "Error: postgresql config parsing failed"
|
||||
log_event "$E_PARSING" "$EVENT"
|
||||
log_event "$E_PARSING" "$ARGUMENTS"
|
||||
exit $E_PARSING
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue