web domain editing

This commit is contained in:
Serghey Rodin 2012-06-05 14:09:56 +03:00
commit 89197647fa
30 changed files with 979 additions and 79 deletions

View file

@ -15,8 +15,8 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
template=${3-default}
default_extentions="jpg,jpeg,gif,png,ico,css,zip,tgz,gz,rar,bz2,doc,xls,exe,\
pdf,ppt,txt,tar,wav,bmp,rtf,js,mp3,avi,mpeg,html,htm"
default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
extentions=${4-$default_extentions}
restart="$5"

View file

@ -37,7 +37,6 @@ is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
#----------------------------------------------------------#

View file

@ -14,6 +14,7 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
restart=$4
# Includes
source $VESTA/conf/vesta.conf
@ -53,7 +54,9 @@ update_domain_zone
#----------------------------------------------------------#
# Restart named
$BIN/v_restart_dns "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_dns "$EVENT"
fi
# Logging
log_history "$EVENT"

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: change web domain ip address
# options: user domain ip
# options: user domain ip [restart]
#
# The call is used for changing the site ip address. The ip change will be
# performed for a virtual apache host and for a configuration nginx file both.
@ -15,6 +15,7 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
restart=$4
# Includes
source $VESTA/conf/vesta.conf
@ -27,7 +28,7 @@ source $VESTA/func/ip.sh
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'user domain ip'
check_args '3' "$#" 'user domain ip [restart]'
validate_format 'user' 'domain' 'ip'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -84,7 +85,9 @@ decrease_ip_value "$old"
update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip"
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

102
bin/v_change_web_domain_nginx_tpl Executable file
View file

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

91
bin/v_change_web_domain_stats Executable file
View file

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

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: change web domain template
# options: user domain template
# options: user domain template [restart]
#
# The function changes template of httpd.conf configuration file. The content
# of webdomain directories remains untouched.
@ -15,6 +15,7 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
template=$3
restart=$4
# Includes
source $VESTA/conf/vesta.conf
@ -26,7 +27,7 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'user domain template'
check_args '3' "$#" 'user domain template [restart]'
validate_format 'user' 'domain' 'template'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -170,7 +171,9 @@ for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
done
# Restart web
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: delete web domain alias
# options: user domain alias
# options: user domain alias [restart]
#
# The function of deleting the alias domain (parked domain). By this call
# default www aliase can be removed as well.
@ -16,6 +16,7 @@ domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain" )
dom_alias=$(idn -t --quiet -u "$3" )
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4"
# Includes
source $VESTA/conf/vesta.conf
@ -27,7 +28,7 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'user domain dom_alias'
check_args '3' "$#" 'user domain dom_alias [restart]'
validate_format 'user' 'domain' 'dom_alias'
is_system_enabled 'WEB_SYSTEM'
is_object_valid 'user' 'USER' "$user"
@ -97,7 +98,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
decrease_user_value "$user" '$U_WEB_ALIASES'
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: delete web domain error loggin support
# options: user domain
# options: user domain [restart]
#
# The function of disabling error logging feature. It comments ErrorLog
# direcitve in apache or/and nginx configuration. The data already collected
@ -15,6 +15,7 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart=$3
# Includes
source $VESTA/conf/vesta.conf
@ -26,7 +27,7 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain'
check_args '2' "$#" 'user domain [restart]'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user" "$user"
@ -86,7 +87,9 @@ fi
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no'
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

View file

@ -13,6 +13,7 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart=$3
# Includes
source $VESTA/conf/vesta.conf
@ -75,7 +76,9 @@ if [ -z "$last_nginx" ]; then
fi
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

View file

@ -13,6 +13,7 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart=$3
# Includes
source $VESTA/conf/vesta.conf
@ -89,7 +90,9 @@ fi
decrease_user_value "$user" '$U_WEB_SSL'
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

View file

@ -76,7 +76,7 @@ conf=$USER_DATA/web.conf
# Defining fileds to select
fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG
$STATS $STATS_AUTH $SSL $SSL_HOME $NGINX $NGINX_EXT $SUSPENDED $DATE'
$STATS $STATS_USER $SSL $SSL_HOME $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE'
# Listing domains
case $format in

View file

@ -35,7 +35,7 @@ conf=$USER_DATA/web.conf
# Defining fileds to select
fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$PHP \$CGI"
fields="$fields \$ELOG \$STATS \$STATS_AUTH \$SSL \$SSL_HOME \$NGINX"
fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$NGINX"
fields="$fields \$NGINX_EXT \$SUSPENDED \$TIME \$DATE"
# Listing domains