mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 10:37:42 -07:00
improved template logic
This commit is contained in:
parent
3cec339748
commit
ef33765d31
56 changed files with 710 additions and 282 deletions
|
@ -19,7 +19,7 @@ domain=$(idn -t --quiet -u "$2" )
|
|||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ip=$3
|
||||
template=${4-default}
|
||||
template=$4
|
||||
next_year=$(date +%F -d "+ 1 year")
|
||||
exp=${5-$next_year}
|
||||
soa=$6
|
||||
|
@ -36,13 +36,19 @@ source $VESTA/func/domain.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'user domain ip [template] [exp] [soa] [ttl]'
|
||||
validate_format 'user' 'domain' 'ip' 'template' 'exp' 'ttl'
|
||||
validate_format 'user' 'domain' 'ip' 'exp' 'ttl'
|
||||
is_system_enabled "$DNS_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_domain_new 'dns'
|
||||
is_package_full 'DNS_DOMAINS'
|
||||
is_dns_template_valid
|
||||
if [ ! -z "$template" ]; then
|
||||
validate_format 'template'
|
||||
is_dns_template_valid
|
||||
else
|
||||
template=$(get_user_value '$TEMPLATE')
|
||||
is_dns_template_valid
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
|
|
@ -20,7 +20,7 @@ domain=$(idn -t --quiet -u "$2" )
|
|||
domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
ip=$3
|
||||
template=${4-default}
|
||||
template=$4
|
||||
restart=$5
|
||||
|
||||
# Includes
|
||||
|
@ -35,7 +35,7 @@ source $VESTA/func/ip.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '3' "$#" 'user domain ip [template] [restart]'
|
||||
validate_format 'user' 'domain' 'ip' 'template'
|
||||
validate_format 'user' 'domain' 'ip'
|
||||
is_system_enabled "$WEB_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
|
@ -43,7 +43,13 @@ is_domain_new 'web'
|
|||
is_ip_valid
|
||||
is_ip_avalable
|
||||
is_package_full 'WEB_DOMAINS'
|
||||
is_apache_template_valid
|
||||
if [ ! -z "$template" ]; then
|
||||
validate_format 'template'
|
||||
is_apache_template_valid
|
||||
else
|
||||
template=$(get_user_value '$TEMPLATE')
|
||||
is_apache_template_valid
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -74,28 +80,9 @@ email="$user@$domain"
|
|||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||
conf="$HOMEDIR/$user/conf/web/httpd.conf"
|
||||
tpl_file="$WEBTPL/apache_$template.tpl"
|
||||
|
||||
# Parsing template keys
|
||||
template_data=$(cat $WEBTPL/apache_$template.descr|grep -v '#')
|
||||
for keys in $template_data; do
|
||||
eval ${keys%%=*}=${keys#*=}
|
||||
done
|
||||
|
||||
# Checking error log status
|
||||
if [ "$ELOG" = 'no' ]; then
|
||||
elog='#'
|
||||
else
|
||||
elog=''
|
||||
fi
|
||||
|
||||
# Checking cgi
|
||||
if [ "$CGI" != 'yes' ]; then
|
||||
cgi='#'
|
||||
cgi_option='-ExecCGI'
|
||||
else
|
||||
cgi=''
|
||||
cgi_option='+ExecCGI'
|
||||
fi
|
||||
elog=''
|
||||
cgi=''
|
||||
cgi_option='+ExecCGI'
|
||||
|
||||
# Adding domain to the httpd.conf
|
||||
add_web_config
|
||||
|
@ -181,9 +168,9 @@ increase_user_value "$user" '$U_WEB_ALIASES'
|
|||
|
||||
# Defining domain variables
|
||||
str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'"
|
||||
str="$str $template_data SSL='no' SSL_HOME='single' NGINX='' NGINX_EXT=''"
|
||||
str="$str STATS='' STATS_USER='' STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0'"
|
||||
str="$str SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
|
||||
str="$str CGI='yes' ELOG='yes' SSL='no' SSL_HOME='single' NGINX=''"
|
||||
str="$str NGINX_EXT='' STATS='' STATS_USER='' STATS_CRYPT='' U_DISK='0'"
|
||||
str="$str U_BANDWIDTH='0' SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
|
||||
|
||||
# Registering domain
|
||||
echo "$str" >> $USER_DATA/web.conf
|
||||
|
|
|
@ -73,13 +73,13 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
|
|
@ -66,13 +66,13 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
template=${3-default}
|
||||
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}
|
||||
|
@ -31,14 +31,20 @@ source $VESTA/func/domain.sh
|
|||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'user domain [template] [extentions] [restart]'
|
||||
validate_format 'user' 'domain' 'template' 'extentions'
|
||||
validate_format 'user' 'domain' 'extentions'
|
||||
is_system_enabled "$PROXY_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX'
|
||||
is_nginx_template_valid
|
||||
if [ ! -z "$template" ]; then
|
||||
validate_format 'template'
|
||||
is_nginx_template_valid
|
||||
else
|
||||
template=$(get_user_value '$TEMPLATE')
|
||||
is_nginx_template_valid
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
|
@ -49,7 +55,7 @@ is_nginx_template_valid
|
|||
get_domain_values 'web'
|
||||
NGINX="$template"
|
||||
NGINX_EXT="$extentions"
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
|
||||
# Preparing domain values for the template substitution
|
||||
|
@ -69,7 +75,7 @@ fi
|
|||
|
||||
# Checking ssl
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
add_web_config
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ fi
|
|||
if [ ! -z "$NGINX" ]; then
|
||||
# Adding domain to the snginx.conf
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
add_web_config
|
||||
|
||||
chown root:nginx $conf
|
||||
|
|
|
@ -163,14 +163,14 @@ then
|
|||
|
||||
# Nginx config
|
||||
if [ ! -z "$NGINX" ] ; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
get_web_config_brds
|
||||
sed -n "$top_line,$bottom_line p" $conf > conf/nginx.conf
|
||||
|
||||
# SSL check
|
||||
if [ "$SSL" = 'yes' ] ; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
get_web_config_brds
|
||||
sed -n "$top_line,$bottom_line p" $conf > conf/snginx.conf
|
||||
|
|
|
@ -59,9 +59,9 @@ change_user_package() {
|
|||
echo "FNAME='$FNAME'
|
||||
LNAME='$LNAME'
|
||||
PACKAGE='$package'
|
||||
TEMPLATE='$TEMPLATE'
|
||||
WEB_DOMAINS='$WEB_DOMAINS'
|
||||
WEB_ALIASES='$WEB_ALIASES'
|
||||
WEB_TPL='$WEB_TPL'
|
||||
DNS_DOMAINS='$DNS_DOMAINS'
|
||||
DNS_RECORDS='$DNS_RECORDS'
|
||||
MAIL_DOMAINS='$MAIL_DOMAINS'
|
||||
|
|
48
bin/v_change_user_template
Executable file
48
bin/v_change_user_template
Executable file
|
@ -0,0 +1,48 @@
|
|||
#!/bin/bash
|
||||
# info: change user default template
|
||||
# options: user template
|
||||
#
|
||||
# The function changes default user web template.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
template=$2
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'user template'
|
||||
validate_format 'user' 'template'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_apache_template_valid
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Changing user shell
|
||||
update_user_value "$user" '$TEMPLATE' "$template"
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
|
@ -60,14 +60,14 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
replace_web_config
|
||||
fi
|
||||
|
||||
# Checking nginx
|
||||
if [ "$SSL" = 'yes' ] && [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
replace_web_config
|
||||
fi
|
||||
|
|
|
@ -48,7 +48,7 @@ is_nginx_template_valid
|
|||
|
||||
# Parsing domain values
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
|
||||
# Delete old vhost
|
||||
|
@ -56,7 +56,7 @@ del_web_config
|
|||
|
||||
# Checking ssl
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
fi
|
||||
|
@ -64,7 +64,7 @@ fi
|
|||
# Add new vhost
|
||||
NGINX="$template"
|
||||
NGINX_EXT="$extentions"
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
upd_web_domain_values
|
||||
add_web_config
|
||||
|
@ -73,7 +73,7 @@ chmod 640 $conf
|
|||
|
||||
# Checking ssl
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
add_web_config
|
||||
chown root:nginx $conf
|
||||
|
|
|
@ -56,7 +56,7 @@ replace_web_config
|
|||
|
||||
# Checking nginx config
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web//snginx.conf"
|
||||
replace_web_config
|
||||
fi
|
||||
|
|
|
@ -61,12 +61,6 @@ fi
|
|||
upd_web_domain_values
|
||||
tpl_file="$WEBTPL/apache_$template.tpl"
|
||||
|
||||
# Parsing new template
|
||||
template_data=$(cat $WEBTPL/apache_$template.descr | grep -v '#')
|
||||
for keys in $template_data; do
|
||||
eval ${keys%%=*}=${keys#*=}
|
||||
done
|
||||
|
||||
# Checking error log
|
||||
if [ "$ELOG" = 'no' ]; then
|
||||
elog='#'
|
||||
|
@ -104,13 +98,6 @@ fi
|
|||
# Changing tpl in config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
|
||||
|
||||
# Updating db keys
|
||||
for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
|
||||
key=$(echo "$keys"| cut -f 1 -d '=' |sed -e "s/^/\$/g")
|
||||
value=$(echo "$keys" |cut -f 2 -d \')
|
||||
update_object_value 'web' 'DOMAIN' "$domain" "$key" "$value"
|
||||
done
|
||||
|
||||
# Restart web
|
||||
if [ "$restart" != 'no' ]; then
|
||||
$BIN/v_restart_web "$EVENT"
|
||||
|
|
|
@ -70,12 +70,12 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
fi
|
||||
|
|
|
@ -72,13 +72,13 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
|
|
@ -64,13 +64,13 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
|
|
@ -41,13 +41,13 @@ is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
|
|||
|
||||
# Defining domain parameters
|
||||
get_domain_values 'web'
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
|
||||
# Checking ssl
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
fi
|
||||
|
|
|
@ -49,7 +49,7 @@ del_web_config
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
fi
|
||||
|
|
|
@ -17,36 +17,30 @@ source $VESTA/func/main.sh
|
|||
|
||||
# Json function
|
||||
json_list_dnstpl() {
|
||||
echo '{'
|
||||
for template in $(ls $DNSTPL/| grep '.descr'); do
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' },'
|
||||
templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.')
|
||||
t_counter=$(echo "$templates" | wc -w)
|
||||
i=1
|
||||
echo '['
|
||||
for template in $templates; do
|
||||
if [ "$i" -lt "$t_counter" ]; then
|
||||
echo -e "\t\"$template\","
|
||||
else
|
||||
echo -e "\t\"$template\""
|
||||
fi
|
||||
tpl_descr=$(cat $DNSTPL/$template |grep '#'|tr -d '\n')
|
||||
tpl_name="${template//.descr/}"
|
||||
echo -e "\t\"$tpl_name\": {"
|
||||
echo -e "\t\t\"DESCR\": \"${tpl_descr//# /}\""
|
||||
data=1
|
||||
(( ++i))
|
||||
done
|
||||
if [ -n "$data" ]; then
|
||||
echo -e ' }'
|
||||
fi
|
||||
echo -e '}'
|
||||
echo "]"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_dnstpl() {
|
||||
for template in $(ls $DNSTPL/| grep '.descr'); do
|
||||
tpl_name="${template//.descr/}"
|
||||
tpl_descr=$(cat $DNSTPL/$template |grep '#')
|
||||
if [ -z "$nohead" ] ; then
|
||||
echo "----------"
|
||||
fi
|
||||
echo "TEMPLATE: $tpl_name"
|
||||
echo "DESCRIPTION: ${tpl_descr//# /}"
|
||||
if [ -z "$nohead" ] ; then
|
||||
echo
|
||||
fi
|
||||
templates=$(ls -t $DNSTPL |grep '\.tpl' |cut -f 1 -d '.')
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "Templates"
|
||||
echo "----------"
|
||||
fi
|
||||
for template in $templates; do
|
||||
echo "$template"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ is_object_valid 'user' 'USER' "$user"
|
|||
conf=$USER_DATA/user.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$USER $FNAME $LNAME $PACKAGE $WEB_DOMAINS $WEB_ALIASES $WEB_TPL
|
||||
fields='$USER $FNAME $LNAME $PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_ALIASES
|
||||
$DNS_DOMAINS $DNS_RECORDS $MAIL_DOMAINS $MAIL_ACCOUNTS $DATABASES
|
||||
$CRON_JOBS $DISK_QUOTA $BANDWIDTH $NS $SHELL $BACKUPS $CONTACT
|
||||
$CRON_REPORTS $RKEY $SUSPENDED $SUSPENDED_USERS $SUSPENDED_WEB
|
||||
|
|
|
@ -71,9 +71,9 @@ shell_list_pkgs() {
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining fields
|
||||
fields='$PACKAGE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES $MAIL_DOMAINS
|
||||
$MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA $BANDWIDTH $NS
|
||||
$SHELL $BACKUPS $WEB_TPL'
|
||||
fields='$PACKAGE $TEMPLATE $WEB_DOMAINS $WEB_SSL $WEB_ALIASES $DATABASES
|
||||
$MAIL_DOMAINS $MAIL_BOXES $MAIL_FORWARDERS $DNS_DOMAINS $DISK_QUOTA
|
||||
$BANDWIDTH $NS $SHELL $BACKUPS'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
|
|
|
@ -73,17 +73,18 @@ shell_list_users() {
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Defining fileds to select
|
||||
fields="\$USER \$FNAME \$LNAME \$PACKAGE \$WEB_DOMAINS \$WEB_ALIASES \$WEB_TPL"
|
||||
fields="$fields \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS \$MAIL_ACCOUNTS"
|
||||
fields="$fields \$DATABASES \$CRON_JOBS \$DISK_QUOTA \$BANDWIDTH \$NS \$SHELL"
|
||||
fields="$fields \$BACKUPS \$CONTACT \$CRON_REPORTS \$RKEY \$SUSPENDED"
|
||||
fields="$fields \$SUSPENDED_USERS \$SUSPENDED_WEB \$SUSPENDED_DNS"
|
||||
fields="$fields \$SUSPENDED_MAIL \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL"
|
||||
fields="$fields \$IP_OWNED \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB"
|
||||
fields="$fields \$U_DISK_MAIL \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS"
|
||||
fields="$fields \$U_WEB_SSL \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS"
|
||||
fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS \$U_DATABASES"
|
||||
fields="$fields \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE"
|
||||
fields="\$USER \$FNAME \$LNAME \$PACKAGE \$TEMPLATE \$WEB_DOMAINS"
|
||||
fields="$fields \$WEB_ALIASES \$DNS_DOMAINS \$DNS_RECORDS \$MAIL_DOMAINS"
|
||||
fields="$fields \$MAIL_ACCOUNTS \$DATABASES \$CRON_JOBS \$DISK_QUOTA"
|
||||
fields="$fields \$BANDWIDTH \$NS \$SHELL \$BACKUPS \$CONTACT"
|
||||
fields="$fields \$CRON_REPORTS \$RKEY \$SUSPENDED \$SUSPENDED_USERS"
|
||||
fields="$fields \$SUSPENDED_WEB \$SUSPENDED_DNS \$SUSPENDED_MAIL"
|
||||
fields="$fields \$SUSPENDED_DB \$SUSPENDED_CRON \$IP_AVAIL \$IP_OWNED"
|
||||
fields="$fields \$U_USERS \$U_DISK \$U_DISK_DIRS \$U_DISK_WEB \$U_DISK_MAIL"
|
||||
fields="$fields \$U_DISK_DB \$U_BANDWIDTH \$U_WEB_DOMAINS \$U_WEB_SSL"
|
||||
fields="$fields \$U_WEB_ALIASES \$U_DNS_DOMAINS \$U_DNS_RECORDS"
|
||||
fields="$fields \$U_MAIL_DOMAINS \$U_MAIL_DKIM \$U_MAIL_ACCOUNTS"
|
||||
fields="$fields \$U_DATABASES \$U_CRON_JOBS \$U_BACKUPS \$TIME \$DATE"
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
|
|
|
@ -75,8 +75,8 @@ is_object_valid 'web' 'DOMAIN' "$domain"
|
|||
conf=$USER_DATA/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $PHP $CGI $ELOG
|
||||
$STATS $STATS_USER $SSL $SSL_HOME $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE'
|
||||
fields='$DOMAIN $IP $IP6 $U_DISK $U_BANDWIDTH $TPL $ALIAS $CGI $ELOG $STATS
|
||||
$STATS_USER $SSL $SSL_HOME $NGINX $NGINX_EXT $SUSPENDED $TIME $DATE'
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
|
|
|
@ -34,7 +34,7 @@ is_object_valid 'user' 'USER' "$user"
|
|||
conf=$USER_DATA/web.conf
|
||||
|
||||
# Defining fileds to select
|
||||
fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$PHP \$CGI"
|
||||
fields="\$DOMAIN \$IP \$IP6 \$U_DISK \$U_BANDWIDTH \$TPL \$ALIAS \$CGI"
|
||||
fields="$fields \$ELOG \$STATS \$STATS_USER \$SSL \$SSL_HOME \$NGINX"
|
||||
fields="$fields \$NGINX_EXT \$SUSPENDED \$TIME \$DATE"
|
||||
|
||||
|
|
|
@ -10,65 +10,48 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
format=${1-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# Json function
|
||||
json_list_wtpl() {
|
||||
templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\
|
||||
|cut -f 1 -d '.')
|
||||
t_counter=$(echo "$templates" | wc -w)
|
||||
i=1
|
||||
echo '{'
|
||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
||||
if [ -e "$WEBTPL/apache_$template.descr" ]; then
|
||||
descr=$(cat $WEBTPL/apache_$template.descr | grep '#'|\
|
||||
sed -e ':a;N;$!ba;s/\n/ /g')
|
||||
if [ $i -ne 1 ]; then
|
||||
echo -e "\t},"
|
||||
fi
|
||||
echo -e "\t\"$template\": {"
|
||||
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
|
||||
(( ++i))
|
||||
echo '['
|
||||
for template in $templates; do
|
||||
if [ "$i" -lt "$t_counter" ]; then
|
||||
echo -e "\t\"$template\","
|
||||
else
|
||||
echo -e "\t\"$template\""
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
if [ -n "$template" ]; then
|
||||
echo -e "\t}"
|
||||
fi
|
||||
echo '}'
|
||||
echo "]"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_wtpl() {
|
||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
||||
if [ -e "$WEBTPL/apache_$template.descr" ]; then
|
||||
tpl_descr=$(cat $WEBTPL/apache_$template.descr |grep '#')
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "----------"
|
||||
fi
|
||||
echo "TEMPLATE: $template"
|
||||
echo "DESCRIPTION: ${tpl_descr//# /}"
|
||||
fi
|
||||
templates=$(ls -t $WEBTPL |grep 'apache' |grep '\.tpl' |cut -f 2 -d '_'\
|
||||
|cut -f 1 -d '.')
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "Templates"
|
||||
echo "----------"
|
||||
fi
|
||||
for template in $templates; do
|
||||
echo "$template"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'user'
|
||||
validate_format 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Get user package package
|
||||
templates=$(get_user_value '$WEB_TPL')
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) json_list_wtpl ;;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
# info: listing nginx templates
|
||||
# options: user [format]
|
||||
# options: [format]
|
||||
#
|
||||
# The function for obtaining the list of nginx templates available to a user.
|
||||
|
||||
|
@ -10,66 +10,47 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
format=${2-shell}
|
||||
format=${1-shell}
|
||||
|
||||
# Includes
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
# Json function
|
||||
json_list_wtpl() {
|
||||
i='1' # iterator
|
||||
echo '{'
|
||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
||||
if [ -e "$WEBTPL/ngingx_$template.descr" ]; then
|
||||
descr=$(cat $WEBTPL/ngingx_$template.descr | grep '#'|\
|
||||
sed -e ':a;N;$!ba;s/\n/ /g')
|
||||
if [ $i -ne 1 ]; then
|
||||
echo -e "\t},"
|
||||
fi
|
||||
echo -e "\t\"$template\": {"
|
||||
echo -e "\t\t\"DESCR\": \"${descr//# /}\""
|
||||
(( ++i))
|
||||
templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\
|
||||
|cut -f 1 -d '.')
|
||||
t_counter=$(echo "$templates" | wc -w)
|
||||
i=1
|
||||
echo '['
|
||||
for template in $templates; do
|
||||
if [ "$i" -lt "$t_counter" ]; then
|
||||
echo -e "\t\"$template\","
|
||||
else
|
||||
echo -e "\t\"$template\""
|
||||
fi
|
||||
(( ++i))
|
||||
done
|
||||
|
||||
if [ -n "$template" ]; then
|
||||
echo -e "\t}"
|
||||
fi
|
||||
echo '}'
|
||||
echo "]"
|
||||
}
|
||||
|
||||
# Shell function
|
||||
shell_list_wtpl() {
|
||||
for template in $(echo "$templates" |sed -e "s/,/\n/g"); do
|
||||
if [ -e "$WEBTPL/ngingx_$template.descr" ]; then
|
||||
tpl_descr=$(cat $WEBTPL/ngingx_$template.descr |grep '#')
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "----------"
|
||||
fi
|
||||
echo "TEMPLATE: $template"
|
||||
echo "DESCRIPTION: ${tpl_descr//# /}"
|
||||
fi
|
||||
templates=$(ls -t $WEBTPL |grep 'nginx' |grep '\.tpl' |cut -f 2 -d '_'\
|
||||
|cut -f 1 -d '.')
|
||||
if [ -z "$nohead" ]; then
|
||||
echo "Templates"
|
||||
echo "----------"
|
||||
fi
|
||||
for template in $templates; do
|
||||
echo "$template"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '1' "$#" 'user'
|
||||
validate_format 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Get user package package
|
||||
templates=$(get_user_value '$WEB_TPL')
|
||||
|
||||
# Listing domains
|
||||
case $format in
|
||||
json) json_list_wtpl ;;
|
||||
|
|
|
@ -185,14 +185,14 @@ for domain in $(shell_list) ; do
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/tmp_nginx.conf"
|
||||
add_web_config
|
||||
chown root:nginx $conf
|
||||
chmod 640 $conf
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/tmp_snginx.conf"
|
||||
add_web_config
|
||||
chown root:nginx $conf
|
||||
|
|
|
@ -63,13 +63,13 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
|
|
@ -60,13 +60,13 @@ fi
|
|||
|
||||
# Checking nginx
|
||||
if [ ! -z "$NGINX" ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.tpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.tpl"
|
||||
conf="$HOMEDIR/$user/conf/web/nginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
||||
if [ "$SSL" = 'yes' ]; then
|
||||
tpl_file="$WEBTPL/ngingx_$NGINX.stpl"
|
||||
tpl_file="$WEBTPL/nginx_$NGINX.stpl"
|
||||
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||
del_web_config
|
||||
add_web_config
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue