improving template structure

This commit is contained in:
Serghey Rodin 2013-04-03 23:18:51 +03:00
parent fce5ddeddf
commit cd69b7bcdf
23 changed files with 135 additions and 88 deletions

View file

@ -83,7 +83,7 @@ group="$user"
email="$user@$domain" email="$user@$domain"
docroot="$HOMEDIR/$user/web/$domain/public_html" docroot="$HOMEDIR/$user/web/$domain/public_html"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
tpl_file="$WEBTPL/apache_$template.tpl" tpl_file="$WEBTPL/apache/$template.tpl"
# Adding domain to the httpd.conf # Adding domain to the httpd.conf
add_web_config add_web_config
@ -146,8 +146,8 @@ chmod 551 $HOMEDIR/$user/web/$domain/logs
chmod 640 /var/log/httpd/domains/$domain.* chmod 640 /var/log/httpd/domains/$domain.*
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache/$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot $WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $docroot
fi fi
# Checking main vesta httpd config # Checking main vesta httpd config

View file

@ -49,7 +49,7 @@ is_package_full 'WEB_ALIASES'
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -68,7 +68,7 @@ del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
@ -76,13 +76,13 @@ fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config

View file

@ -56,7 +56,7 @@ fi
get_domain_values 'web' get_domain_values 'web'
NGINX="$template" NGINX="$template"
NGINX_EXT="$extentions" NGINX_EXT="$extentions"
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -77,7 +77,7 @@ fi
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config add_web_config

View file

@ -63,7 +63,7 @@ chmod 660 $USER_DATA/ssl/$domain.*
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
SSL_HOME="$ssl_home" SSL_HOME="$ssl_home"
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -85,8 +85,8 @@ if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
fi fi
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache/$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $sdocroot $WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $sdocroot
fi fi
# Checking main vesta httpd config # Checking main vesta httpd config
@ -100,7 +100,7 @@ fi
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
# Adding domain to the snginx.conf # Adding domain to the snginx.conf
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf

View file

@ -51,7 +51,7 @@ get_domain_values 'web'
upd_web_domain_values upd_web_domain_values
# Adding statistic config # Adding statistic config
cat $WEBTPL/$type.tpl |\ cat $WEBTPL/$type/$type.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \

View file

@ -169,14 +169,14 @@ then
# Apache config # Apache config
if [ "$WEB_SYSTEM" = 'apache' ]; then if [ "$WEB_SYSTEM" = 'apache' ]; then
# Parsing httpd.conf # Parsing httpd.conf
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
get_web_config_brds get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf sed -n "$top_line,$bottom_line p" $conf > conf/httpd.conf
# SSL check # SSL check
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
get_web_config_brds get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf sed -n "$top_line,$bottom_line p" $conf > conf/shttpd.conf
@ -185,14 +185,14 @@ then
# Nginx config # Nginx config
if [ ! -z "$NGINX" ] ; then if [ ! -z "$NGINX" ] ; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
get_web_config_brds get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
# SSL check # SSL check
if [ "$SSL" = 'yes' ] ; then if [ "$SSL" = 'yes' ] ; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
get_web_config_brds get_web_config_brds
sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf

View file

@ -46,7 +46,7 @@ is_ip_avalable
# Define variable for replace # Define variable for replace
get_domain_values 'web' get_domain_values 'web'
ip=$(get_real_ip $ip) ip=$(get_real_ip $ip)
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
old=$(get_real_ip $IP) old=$(get_real_ip $IP)
new=$ip new=$ip
@ -54,21 +54,21 @@ replace_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
replace_web_config replace_web_config
fi fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
replace_web_config replace_web_config
fi fi
# Checking nginx # Checking nginx
if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
replace_web_config replace_web_config
fi fi

View file

@ -49,7 +49,7 @@ is_nginx_template_valid
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -58,7 +58,7 @@ del_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi
@ -66,7 +66,7 @@ fi
# Add new vhost # Add new vhost
NGINX="$template" NGINX="$template"
NGINX_EXT="$extentions" NGINX_EXT="$extentions"
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
upd_web_domain_values upd_web_domain_values
add_web_config add_web_config
@ -75,7 +75,7 @@ chmod 640 $conf
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf

View file

@ -39,7 +39,7 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
get_domain_values 'web' get_domain_values 'web'
old_ssl_home=$SSL_HOME old_ssl_home=$SSL_HOME
SSL_HOME=$ssl_home SSL_HOME=$ssl_home
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
# Parsing tpl_option # Parsing tpl_option
@ -56,8 +56,8 @@ replace_web_config
# Checking nginx config # Checking nginx config
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web//snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
replace_web_config replace_web_config
fi fi

View file

@ -63,7 +63,7 @@ rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
upd_web_domain_values upd_web_domain_values
# Adding statistic config # Adding statistic config
cat $WEBTPL/$type.tpl |\ cat $WEBTPL/$type/$type.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \

View file

@ -47,40 +47,40 @@ get_domain_values 'web'
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
# Deleting domain # Deleting domain
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
old_tpl=$TPL old_tpl=$TPL
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
del_web_config del_web_config
# Deleting ssl vhost # Deleting ssl vhost
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
fi fi
# Defining variables for new vhost config # Defining variables for new vhost config
upd_web_domain_values upd_web_domain_values
tpl_file="$WEBTPL/apache_$template.tpl" tpl_file="$WEBTPL/apache/$template.tpl"
# Adding domain to the httpd.conf # Adding domain to the httpd.conf
add_web_config add_web_config
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache/$template.sh ]; then
$WEBTPL/apache_$template.sh $user $domain $ip $HOMEDIR $docroot $WEBTPL/apache/$template.sh $user $domain $ip $HOMEDIR $docroot
fi fi
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$template.stpl" tpl_file="$WEBTPL/apache/$template.stpl"
add_web_config add_web_config
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$template.sh ]; then if [ -x $WEBTPL/apache/$template.sh ]; then
$WEBTPL/apache_$template.sh \ $WEBTPL/apache/$template.sh \
"$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot" "$user" "$domain" "$ip" "$HOMEDIR" "$sdocroot"
fi fi
fi fi

View file

@ -44,7 +44,7 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
# Get template name # Get template name
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -60,7 +60,7 @@ fi
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
@ -71,12 +71,12 @@ fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi

View file

@ -55,7 +55,7 @@ ALIAS=$(echo "$ALIAS" |\
sed -e "s/^$dom_alias$//g"|\ sed -e "s/^$dom_alias$//g"|\
sed -e "/^$/d"|\ sed -e "/^$/d"|\
sed -e ':a;N;$!ba;s/\n/,/g') sed -e ':a;N;$!ba;s/\n/,/g')
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
# Preparing domain values for the template substitution # Preparing domain values for the template substitution
@ -66,7 +66,7 @@ del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
@ -74,13 +74,13 @@ fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config

View file

@ -41,13 +41,13 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
# Defining domain parameters # Defining domain parameters
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
# Checking ssl # Checking ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi

View file

@ -42,14 +42,14 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
# Deleting domain # Deleting domain
del_web_config del_web_config
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
fi fi

View file

@ -17,8 +17,7 @@ source $VESTA/func/main.sh
# Json function # Json function
json_list_wtpl() { json_list_wtpl() {
templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ templates=$(ls -t $WEBTPL/apache | cut -f 1 -d '.' |sort -u )
|cut -f 1 -d '.')
t_counter=$(echo "$templates" | wc -w) t_counter=$(echo "$templates" | wc -w)
i=1 i=1
echo '[' echo '['
@ -35,8 +34,7 @@ json_list_wtpl() {
# Shell function # Shell function
shell_list_wtpl() { shell_list_wtpl() {
templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\ templates=$(ls -t $WEBTPL/apache | cut -f 1 -d '.' |sort -u )
|cut -f 1 -d '.')
if [ -z "$nohead" ]; then if [ -z "$nohead" ]; then
echo "Templates" echo "Templates"
echo "----------" echo "----------"

View file

@ -17,8 +17,7 @@ source $VESTA/func/main.sh
# Json function # Json function
json_list_wtpl() { json_list_wtpl() {
templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ templates=$(ls -t $WEBTPL/nginx | cut -f 1 -d '.' |sort -u )
|cut -f 1 -d '.')
t_counter=$(echo "$templates" | wc -w) t_counter=$(echo "$templates" | wc -w)
i=1 i=1
echo '[' echo '['
@ -35,8 +34,7 @@ json_list_wtpl() {
# Shell function # Shell function
shell_list_wtpl() { shell_list_wtpl() {
templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\ templates=$(ls -t $WEBTPL/nginx | cut -f 1 -d '.' |sort -u )
|cut -f 1 -d '.')
if [ -z "$nohead" ]; then if [ -z "$nohead" ]; then
echo "Templates" echo "Templates"
echo "----------" echo "----------"

View file

@ -42,7 +42,7 @@ is_object_unsuspended 'web' 'DOMAIN' "$domain"
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
SUSPENDED='yes' SUSPENDED='yes'
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -56,7 +56,7 @@ add_web_config
# Check ssl # Check ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
@ -64,13 +64,13 @@ fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config

View file

@ -40,7 +40,7 @@ is_object_suspended 'web' 'DOMAIN' "$domain"
# Parsing domain values # Parsing domain values
get_domain_values 'web' get_domain_values 'web'
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf" conf="$HOMEDIR/$user/conf/web/httpd.conf"
SUSPENDED='no' SUSPENDED='no'
ip=$(get_real_ip $IP) ip=$(get_real_ip $IP)
@ -54,7 +54,7 @@ add_web_config
# Check ssl # Check ssl
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
conf="$HOMEDIR/$user/conf/web/shttpd.conf" conf="$HOMEDIR/$user/conf/web/shttpd.conf"
del_web_config del_web_config
add_web_config add_web_config
@ -62,13 +62,13 @@ fi
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/nginx.conf" conf="$HOMEDIR/$user/conf/web/nginx.conf"
del_web_config del_web_config
add_web_config add_web_config
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/snginx.conf" conf="$HOMEDIR/$user/conf/web/snginx.conf"
del_web_config del_web_config
add_web_config add_web_config

View file

@ -93,7 +93,7 @@ build_awstats() {
done done
# Creating index page # Creating index page
cat $WEBTPL/awstats_index.tpl | sed -e "s/%month%/$month/g" >\ cat $WEBTPL/awstats/index.tpl | sed -e "s/%month%/$month/g" >\
$dir/index.html $dir/index.html
# Creating navigation page # Creating navigation page
@ -120,7 +120,7 @@ build_awstats() {
select_m="$select_m<option value=$link>$month $year<\/option>\n" select_m="$select_m<option value=$link>$month $year<\/option>\n"
done done
cat $WEBTPL/awstats_nav.tpl | sed -e "s/%select_month%/$select_m/" >\ cat $WEBTPL/awstats/nav.tpl | sed -e "s/%select_month%/$select_m/" >\
$dir/nav.html $dir/nav.html
} }

View file

@ -1,11 +1,11 @@
# Web template check # Web template check
is_apache_template_valid() { is_apache_template_valid() {
t="$WEBTPL/apache_$template.tpl" t="$WEBTPL/apache/$template.tpl"
s="$WEBTPL/apache_$template.stpl" s="$WEBTPL/apache/$template.stpl"
if [ ! -e $t ] || [ ! -e $s ]; then if [ ! -e $t ] || [ ! -e $s ]; then
template='default' template='default'
t="$WEBTPL/apache_$template.tpl" t="$WEBTPL/apache/$template.tpl"
s="$WEBTPL/apache_$template.stpl" s="$WEBTPL/apache/$template.stpl"
if [ ! -e $t ] || [ ! -e $s ]; then if [ ! -e $t ] || [ ! -e $s ]; then
echo "Error: template $template not found" echo "Error: template $template not found"
log_event "$E_NOTEXIST" "$EVENT" log_event "$E_NOTEXIST" "$EVENT"
@ -16,12 +16,12 @@ is_apache_template_valid() {
# Nginx template check # Nginx template check
is_nginx_template_valid() { is_nginx_template_valid() {
t="$WEBTPL/nginx_$template.tpl" t="$WEBTPL/nginx/$template.tpl"
s="$WEBTPL/nginx_$template.stpl" s="$WEBTPL/nginx/$template.stpl"
if [ ! -e $t ] || [ ! -e $s ]; then if [ ! -e $t ] || [ ! -e $s ]; then
template='default' template='default'
t="$WEBTPL/nginx_$template.tpl" t="$WEBTPL/nginx/$template.tpl"
s="$WEBTPL/nginx_$template.stpl" s="$WEBTPL/nginx/$template.stpl"
if [ ! -e $t ] || [ ! -e $s ]; then if [ ! -e $t ] || [ ! -e $s ]; then
echo "Error: nginx $template not found" echo "Error: nginx $template not found"
log_event "$E_NOTEXIST" "$EVENT" log_event "$E_NOTEXIST" "$EVENT"
@ -416,7 +416,7 @@ namehost_ip_support() {
sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
if [ "$PROXY_SYSTEM" = 'nginx' ]; then if [ "$PROXY_SYSTEM" = 'nginx' ]; then
cat $WEBTPL/ngingx.ip.tpl | sed -e "s/%ip%/$ip/g" \ cat $WEBTPL/nginx/ip.tpl | sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf -e "s/%proxy_port%/$PROXY_PORT/g" >>$nconf
@ -434,8 +434,8 @@ namehost_ip_disable() {
sed -i "/Listen $ip:/d" $conf sed -i "/Listen $ip:/d" $conf
if [ "$PROXY_SYSTEM" = 'nginx' ]; then if [ "$PROXY_SYSTEM" = 'nginx' ]; then
tpl_ln=$(wc -l $WEBTPL/ngingx.ip.tpl | cut -f 1 -d ' ') tpl_ln=$(wc -l $WEBTPL/nginx/ip.tpl | cut -f 1 -d ' ')
ip_line=$(grep -n "%ip%" $WEBTPL/ngingx.ip.tpl |head -n1 |\ ip_line=$(grep -n "%ip%" $WEBTPL/nginx/ip.tpl |head -n1 |\
cut -f 1 -d :) cut -f 1 -d :)
conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :) conf_line=$(grep -n -w $ip $nconf|head -n1|cut -f 1 -d :)
if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ] if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]

View file

@ -190,15 +190,15 @@ rebuild_web_domain_conf() {
# Adding tmp_httpd.conf # Adding tmp_httpd.conf
tpl_file="$WEBTPL/apache_$TPL.tpl" tpl_file="$WEBTPL/apache/$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf" conf="$HOMEDIR/$user/conf/web/tmp_httpd.conf"
add_web_config add_web_config
chown root:apache $conf chown root:apache $conf
chmod 640 $conf chmod 640 $conf
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$TPL.sh ]; then if [ -x $WEBTPL/apache/$TPL.sh ]; then
$WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $docroot $WEBTPL/apache/$TPL.sh $user $domain $ip $HOMEDIR $docroot
fi fi
# Checking aliases # Checking aliases
@ -209,7 +209,7 @@ rebuild_web_domain_conf() {
# Checking stats # Checking stats
if [ ! -z "$STATS" ]; then if [ ! -z "$STATS" ]; then
cat $WEBTPL/$STATS.tpl |\ cat $WEBTPL/$STATS/$STATS.tpl |\
sed -e "s/%ip%/$ip/g" \ sed -e "s/%ip%/$ip/g" \
-e "s/%web_port%/$WEB_PORT/g" \ -e "s/%web_port%/$WEB_PORT/g" \
-e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \ -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
@ -254,7 +254,7 @@ rebuild_web_domain_conf() {
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
# Adding domain to the shttpd.conf # Adding domain to the shttpd.conf
conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf" conf="$HOMEDIR/$user/conf/web/tmp_shttpd.conf"
tpl_file="$WEBTPL/apache_$TPL.stpl" tpl_file="$WEBTPL/apache/$TPL.stpl"
add_web_config add_web_config
chown root:apache $conf chown root:apache $conf
chmod 640 $conf chmod 640 $conf
@ -271,8 +271,8 @@ rebuild_web_domain_conf() {
fi fi
# Running template trigger # Running template trigger
if [ -x $WEBTPL/apache_$TPL.sh ]; then if [ -x $WEBTPL/apache/$TPL.sh ]; then
$WEBTPL/apache_$TPL.sh $user $domain $ip $HOMEDIR $sdocroot $WEBTPL/apache/$TPL.sh $user $domain $ip $HOMEDIR $sdocroot
fi fi
user_ssl=$((user_ssl + 1)) user_ssl=$((user_ssl + 1))
@ -281,14 +281,14 @@ rebuild_web_domain_conf() {
# Checking nginx # Checking nginx
if [ ! -z "$NGINX" ]; then if [ ! -z "$NGINX" ]; then
tpl_file="$WEBTPL/nginx_$NGINX.tpl" tpl_file="$WEBTPL/nginx/$NGINX.tpl"
conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf" conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf
chmod 640 $conf chmod 640 $conf
if [ "$SSL" = 'yes' ]; then if [ "$SSL" = 'yes' ]; then
tpl_file="$WEBTPL/nginx_$NGINX.stpl" tpl_file="$WEBTPL/nginx/$NGINX.stpl"
conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf" conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
add_web_config add_web_config
chown root:nginx $conf chown root:nginx $conf

51
upd/convert-templates.sh Executable file
View file

@ -0,0 +1,51 @@
#!/bin/bash
# Define data path
TPL='/usr/local/vesta/data/templates/web'
# Check for new template structure
if [ -e "$TPL/apache" ]; then
exit
fi
# Remove unused email template
rm -f $TPL/email_reset_password.tpl
# Apache
mkdir -p $TPL/apache
if [ ! -z "$(ls $TPL/| grep apache_)" ];then
mv $TPL/apache_* $TPL/apache/
for template in $(ls $TPL/apache/); do
new_name=$(echo $template |sed -e "s/apache_//")
mv -f $TPL/apache/$template $TPL/apache/$new_name
done
fi
# Nginx
mkdir -p $TPL/nginx
if [ ! -z "$(ls $TPL/| grep nginx_)" ];then
mv $TPL/nginx_* $TPL/nginx/
for template in $(ls $TPL/nginx/); do
new_name=$(echo $template |sed -e "s/nginx_//")
mv -f $TPL/nginx/$template $TPL/nginx/$new_name
done
fi
if [ -e "$TPL/ngingx.ip.tpl" ]; then
mv $TPL/ngingx.ip.tpl $TPL/nginx/ip.tpl
fi
# Awstats
mkdir -p $TPL/awstats
if [ -e "$TPL/awstats.tpl" ]; then
mv $TPL/awstats.tpl $TPL/awstats
mv $TPL/awstats_index.tpl $TPL/awstats/index.tpl
mv $TPL/awstats_nav.tpl $TPL/awstats/nav.tpl
fi
# Webalizer
mkdir -p $TPL/webalizer
if [ -e "$TPL/webalizer.tpl" ]; then
mv $TPL/webalizer.tpl $TPL/webalizer
fi
exit