add web domain

This commit is contained in:
Serghey Rodin 2012-05-28 18:19:49 +03:00
commit 2d12f47a73
18 changed files with 559 additions and 29 deletions

76
bin/v_add_dns_on_web_alias Executable file
View file

@ -0,0 +1,76 @@
#!/bin/bash
# info: add dns domain or dns record based on web domain alias
# options: user domain
#
# The function adds dns domain or dns record based on web domain alias.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
# Includes
source $VESTA/conf/vesta.conf
source $VESTA/func/main.sh
source $VESTA/func/domain.sh
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain'
validate_format 'user' 'domain'
is_system_enabled "$WEB_SYSTEM"
is_system_enabled "$DNS_SYSTEM"
is_object_valid 'user' 'USER' "$user"
is_object_unsuspended 'user' 'USER' "$user"
is_object_valid 'web' 'DOMAIN' "$domain"
is_object_unsuspended 'web' 'DOMAIN' "$domain"
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Parsing domain values
get_domain_values 'web'
OLD_IFS=$IFS
IFS=','
for web_alias in $ALIAS; do
# Check if parent dns domain exist
sub_domain=$(echo $web_alias | cut -f1 -d .)
pr_domain=$(echo $web_alias | sed -e "s/^$sub_domain.//" )
check_parent=$(grep "DOMAIN='$pr_domain'" $USER_DATA/dns.conf)
if [ -z "$check_parent" ]; then
check_dom=$(grep "DOMAIN='$web_alias'" $USER_DATA/dns.conf)
if [ -z "$check_dom" ]; then
$BIN/v_add_dns_domain $user $web_alias $IP
fi
else
check_rec=$(grep "RECORD='$sub_domain'" $USER_DATA/dns/$pr_domain.conf)
if [ -z "$check_rec" ]; then
$BIN/v_add_dns_domain_record $user $pr_domain $sub_domain A $IP
fi
fi
done
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Restart web server
$BIN/v_restart_dns "$EVENT"
# Logging
log_history "$EVENT"
log_event "$OK" "$EVENT"
exit

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add web domain
# options: user domain ip [template]
# options: user domain ip [template] [restart]
#
# The function adds virtual host to a server. In cases when a template is
# undefined in the script, the template "default" will be used. The alias of
@ -21,6 +21,7 @@ domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
domain_idn=$(idn -t --quiet -a "$domain")
ip=$3
template=${4-default}
restart=$5
# Includes
source $VESTA/conf/vesta.conf
@ -33,7 +34,7 @@ source $VESTA/func/ip.sh
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'user domain ip [template]'
check_args '3' "$#" 'user domain ip [template] [restart]'
validate_format 'user' 'domain' 'ip' 'template'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -190,7 +191,9 @@ echo "$str" >> $USER_DATA/web.conf
chmod 660 $USER_DATA/web.conf
# 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: add web domain alias
# options: user domain alias
# options: user domain alias [restart]
#
# The call is intended for adding aliases to a domain (it is also called
# "domain parking"). The function supports wildcards *.domain.tpl.
@ -18,6 +18,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
dom_alias=$(idn -t --quiet -u "$3" )
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
restart="$4"
# Includes
source $VESTA/conf/vesta.conf
@ -29,7 +30,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"
@ -98,7 +99,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
increase_user_value "$user" '$U_WEB_ALIASES'
# Adding task to the vesta pipe
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
log_history "$EVENT"
log_event "$OK" "$EVENT"

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: add error logging for domain
# options: user domain
# options: user domain [restart]
#
# The function enables a separate ErrorLog file for a domain, accessible for
# reading by users.
@ -14,6 +14,7 @@
user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
restart="$3"
# Includes
source $VESTA/conf/vesta.conf
@ -25,14 +26,13 @@ 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"
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" '$ELOG'
#----------------------------------------------------------#
@ -41,6 +41,10 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$ELOG'
# Parsing domain values
get_domain_values 'web'
if [ $ELOG == 'yes' ]; then
exit 0
fi
tpl_file="$WEBTPL/apache_$TPL.tpl"
conf="$HOMEDIR/$user/conf/web/httpd.conf"
ELOG='yes'
@ -85,7 +89,9 @@ fi
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes'
# Adding task to the vesta pipe
$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: add webdomain nginx support
# options: user domain
# options: user domain [template] [extentions] [restart]
#
# The function enables nginx support for a domain. It can significantly improve
# website speed.
@ -18,6 +18,7 @@ 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"
extentions=${4-$default_extentions}
restart="$5"
# Includes
source $VESTA/conf/vesta.conf
@ -29,7 +30,7 @@ source $VESTA/func/domain.sh
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'user domain [template] [extentions]'
check_args '2' "$#" 'user domain [template] [extentions] [restart]'
validate_format 'user' 'domain' 'template' 'extentions'
is_system_enabled "$PROXY_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -94,7 +95,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
log_history "$EVENT"
log_event "$OK" "$EVENT"

View file

@ -1,6 +1,6 @@
#!/bin/bash
# info: adding ssl for domain
# options: user domain ssl_dir [ssl_home]
# options: user domain ssl_dir [ssl_home] [restart]
#
# The function turns on SSL support for a domain. Parameter ssl_dir is a path
# to directory where 2 or 3 ssl files can be found. Certificate file
@ -19,7 +19,8 @@ user=$1
domain=$(idn -t --quiet -u "$2" )
domain_idn=$(idn -t --quiet -a "$domain")
ssl_dir=$3
ssl_home=${4-single}
ssl_home=${4-same}
restart="$5"
# Includes
source $VESTA/conf/vesta.conf
@ -32,7 +33,7 @@ source $VESTA/func/ip.sh
# Verifications #
#----------------------------------------------------------#
check_args '3' "$#" 'user domain ssl_dir [ssl_home]'
check_args '3' "$#" 'user domain ssl_dir [ssl_home] [restart]'
validate_format 'user' 'domain' 'ssl_dir'
is_system_enabled "$WEB_SYSTEM"
is_object_valid 'user' 'USER' "$user"
@ -124,7 +125,9 @@ update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
# Restart web server
$BIN/v_restart_web "$EVENT"
if [ "$restart" != 'no' ]; then
$BIN/v_restart_web "$EVENT"
fi
# Logging
log_history "$EVENT"

66
bin/v_list_web_stats Executable file
View file

@ -0,0 +1,66 @@
#!/bin/bash
# info: list web statistics
# options: [format]
#
# The function for obtaining the list of system shells.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument defenition
format=${1-shell}
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
# Json function
json_list_st() {
stats=$(echo "${STATS_SYSTEM//,/ } none")
st_counter=$(echo "$stats" | wc -w)
i=1
echo '['
for st in $stats; do
if [ "$i" -lt "$st_counter" ]; then
echo -e "\t\"$st\","
else
echo -e "\t\"$st\""
fi
(( ++i))
done
echo "]"
}
# Shell function
shell_list_st() {
stats=$(echo "none ${STATS_SYSTEM//,/ }")
if [ -z "$nohead" ]; then
echo "STATS"
echo "----------"
fi
for st in $stats; do
echo "$st"
done
}
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Listing domains
case $format in
json) json_list_st ;;
plain) nohead=1; shell_list_st ;;
shell) shell_list_st ;;
*) check_args '1' '0' '[format]' ;;
esac
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
exit