mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
Refactoring stage IV (web)
This commit is contained in:
parent
33717629f7
commit
0fb633a8c4
62 changed files with 467 additions and 994 deletions
|
@ -70,7 +70,7 @@ sync_cron_jobs
|
||||||
increase_user_value $user '$U_CRON_JOBS'
|
increase_user_value $user '$U_CRON_JOBS'
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -45,7 +45,7 @@ sync_cron_jobs
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -109,7 +109,7 @@ increase_user_value "$user" '$U_DNS_DOMAINS'
|
||||||
increase_user_value "$user" '$U_DNS_RECORDS' "$records"
|
increase_user_value "$user" '$U_DNS_RECORDS' "$records"
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -79,7 +79,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
|
||||||
increase_user_value "$user" '$U_DNS_RECORDS'
|
increase_user_value "$user" '$U_DNS_RECORDS'
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -106,7 +106,7 @@ fi
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
if [ "$web_restart" = 'yes' ]; then
|
if [ "$web_restart" = 'yes' ]; then
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -22,7 +22,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ip=$3
|
ip=$3
|
||||||
template=${4-default}
|
template=${4-default}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -33,32 +33,15 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain ip [template]'
|
check_args '3' "$#" 'user domain ip [template]'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'ip' 'template'
|
validate_format 'user' 'domain' 'ip' 'template'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_domain_new 'web'
|
||||||
# Checking domain
|
is_ip_valid
|
||||||
is_domain_new 'dns'
|
|
||||||
|
|
||||||
# Checking ip
|
|
||||||
is_ip_avalable
|
is_ip_avalable
|
||||||
|
|
||||||
# Checking package
|
|
||||||
is_package_full 'WEB_DOMAINS'
|
is_package_full 'WEB_DOMAINS'
|
||||||
|
|
||||||
# Checking template
|
|
||||||
templates=$(get_user_value '$WEB_TPL')
|
|
||||||
is_apache_template_valid
|
is_apache_template_valid
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +72,6 @@ group="$user"
|
||||||
email="$user@$domain"
|
email="$user@$domain"
|
||||||
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
docroot="$HOMEDIR/$user/web/$domain/public_html"
|
||||||
docroot_string="DocumentRoot $docroot"
|
docroot_string="DocumentRoot $docroot"
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
|
@ -192,34 +174,26 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Increasing ip value
|
# Increasing counters
|
||||||
increase_ip_value "$ip"
|
increase_ip_value "$ip"
|
||||||
|
|
||||||
# Increasing domain value
|
|
||||||
increase_user_value "$user" '$U_WEB_DOMAINS'
|
increase_user_value "$user" '$U_WEB_DOMAINS'
|
||||||
increase_user_value "$user" '$U_WEB_ALIASES'
|
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||||
|
|
||||||
# Defining domain variables
|
# Defining domain variables
|
||||||
v_str="DOMAIN='$domain'"
|
str="DOMAIN='$domain' IP='$ip' IP6='' ALIAS='$aliases' TPL='$template'"
|
||||||
v_str="$v_str IP='$ip' IP6=''"
|
str="$str $template_data SSL='no' SSL_HOME='single' NGINX='' NGINX_EXT=''"
|
||||||
v_str="$v_str U_DISK='0'"
|
str="$str STATS='' STATS_USER='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
|
||||||
v_str="$v_str U_BANDWIDTH='0'"
|
str="$str TIME='$TIME' DATE='$DATE'"
|
||||||
v_str="$v_str TPL='$template'"
|
|
||||||
v_str="$v_str ALIAS='$aliases'"
|
|
||||||
v_str="$v_str $template_data" # Inserting PHP, CGI and ELOG keys
|
|
||||||
v_str="$v_str STATS='' STATS_AUTH=''"
|
|
||||||
v_str="$v_str SSL='no' SSL_HOME='single'"
|
|
||||||
v_str="$v_str NGINX='' NGINX_EXT='' SUSPENDED='no' DATE='$DATE'"
|
|
||||||
|
|
||||||
# Registering domain
|
# Registering domain
|
||||||
echo "$v_str" >> $USER_DATA/web.conf
|
echo "$str" >> $USER_DATA/web.conf
|
||||||
chmod 660 $USER_DATA/web.conf
|
chmod 660 $USER_DATA/web.conf
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_delete_web_domain $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -19,7 +19,7 @@ dom_alias=$(idn -t --quiet -u "$3" )
|
||||||
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
|
dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
|
||||||
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
|
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -29,31 +29,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain dom_alias'
|
check_args '3' "$#" 'user domain dom_alias'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'dom_alias'
|
validate_format 'user' 'domain' 'dom_alias'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking alias on the server
|
|
||||||
is_domain_new 'web' "$dom_alias"
|
is_domain_new 'web' "$dom_alias"
|
||||||
|
|
||||||
# Checking package
|
|
||||||
is_package_full 'WEB_ALIASES'
|
is_package_full 'WEB_ALIASES'
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,15 +92,15 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding new alias
|
# Adding new alias
|
||||||
update_domain_value 'web' '$ALIAS' "$ALIAS"
|
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
||||||
|
|
||||||
# Update counters
|
# Update counters
|
||||||
increase_user_value "$user" '$U_WEB_ALIASES'
|
increase_user_value "$user" '$U_WEB_ALIASES'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
log_history "$EVENT" "v_delete_web_domain_alias $user $domain $dom_alias"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -27,29 +27,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_empty 'web' 'DOMAIN' "$domain" '$CGI'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking cgi is not added
|
|
||||||
is_domain_key_empty 'web' '$CGI'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -82,14 +67,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding elog in config
|
# Update config value
|
||||||
update_domain_value 'web' '$CGI' 'yes'
|
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'yes'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_delete_web_domain_cgi $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -15,7 +15,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -25,29 +25,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_empty 'web' 'DOMAIN' "$domain" '$ELOG'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking errorlog is not added
|
|
||||||
is_domain_key_empty 'web' '$ELOG'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -96,14 +81,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding elog in config
|
# Update config
|
||||||
update_domain_value 'web' '$ELOG' 'yes'
|
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'yes'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_delete_web_domain_elog $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -29,31 +29,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain [template] [extentions]'
|
check_args '2' "$#" 'user domain [template] [extentions]'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'template' 'extentions'
|
validate_format 'user' 'domain' 'template' 'extentions'
|
||||||
|
is_system_enabled "$PROXY_SYSTEM"
|
||||||
# Checking proxy system is enabled
|
|
||||||
is_system_enabled 'proxy'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_empty 'web' 'DOMAIN' "$domain" '$NGINX'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Check nginx is not added
|
|
||||||
is_domain_key_empty 'web' '$NGINX'
|
|
||||||
|
|
||||||
# Checking template
|
|
||||||
is_nginx_template_valid
|
is_nginx_template_valid
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,14 +89,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding nginx params to config
|
# Update config
|
||||||
update_domain_value 'web' '$NGINX' "$NGINX"
|
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' "$NGINX"
|
||||||
update_domain_value 'web' '$NGINX_EXT' "$extentions"
|
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' "$extentions"
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
log_history "$EVENT" "v_delete_web_domain_nginx $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -21,7 +21,7 @@ domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ssl_dir=$3
|
ssl_dir=$3
|
||||||
ssl_home=${4-single}
|
ssl_home=${4-single}
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -32,31 +32,15 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain ssl_dir [ssl_home]'
|
check_args '3' "$#" 'user domain ssl_dir [ssl_home]'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'ssl_dir'
|
validate_format 'user' 'domain' 'ssl_dir'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_empty 'web' 'DOMAIN' "$domain" '$SSL'
|
||||||
|
is_sys_ip_owner
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Check ssl is not added
|
|
||||||
is_domain_key_empty 'web' '$SSL'
|
|
||||||
|
|
||||||
# Checking ssl certificate
|
|
||||||
is_web_domain_cert_valid
|
is_web_domain_cert_valid
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,9 +64,6 @@ 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"
|
||||||
|
|
||||||
# Checking ip ownership
|
|
||||||
is_sys_ip_owner
|
|
||||||
|
|
||||||
# Preparing domain values for the template substitution
|
# Preparing domain values for the template substitution
|
||||||
upd_web_domain_values
|
upd_web_domain_values
|
||||||
|
|
||||||
|
@ -139,11 +120,14 @@ fi
|
||||||
increase_user_value "$user" '$U_WEB_SSL'
|
increase_user_value "$user" '$U_WEB_SSL'
|
||||||
|
|
||||||
# Adding ssl values
|
# Adding ssl values
|
||||||
update_domain_value 'web' '$SSL_HOME' "$SSL_HOME"
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
|
||||||
update_domain_value 'web' '$SSL' 'yes'
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
|
||||||
|
|
||||||
|
# Restart web server
|
||||||
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_delete_web_domain_ssl $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
# info: add password protection to web domain statistics
|
|
||||||
# options: user domain auth_user auth_password
|
|
||||||
#
|
|
||||||
# The call is used for securing the web statistics page.
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Variable&Function #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Argument defenition
|
|
||||||
user=$1
|
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
|
||||||
auth_user=$3
|
|
||||||
auth_pass=$4
|
|
||||||
|
|
||||||
# Importing variables
|
|
||||||
source $VESTA/conf/vesta.conf
|
|
||||||
source $VESTA/func/shared.sh
|
|
||||||
source $VESTA/func/domain.sh
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Verifications #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '4' "$#" 'user domain auth_user auth_password'
|
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'auth_user' 'auth_pass'
|
|
||||||
|
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
|
||||||
|
|
||||||
# Checking domain exist
|
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Action #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Definining statistic dir
|
|
||||||
stat_dir="$HOMEDIR/$user/web/$domain/stats"
|
|
||||||
|
|
||||||
# Adding htaccess file
|
|
||||||
if [ ! -e "$stat_dir/.htaccess" ]; then
|
|
||||||
echo "AuthUserFile $stat_dir/.htpasswd" > $stat_dir/.htaccess
|
|
||||||
echo "AuthName \"Only for admins\"" >> $stat_dir/.htaccess
|
|
||||||
echo "AuthType Basic" >> $stat_dir/.htaccess
|
|
||||||
echo "Require valid-user" >> $stat_dir/.htaccess
|
|
||||||
echo "" >> $stat_dir/.htaccess
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generating htaccess user and password
|
|
||||||
if [ ! -e "$stat_dir/.htpasswd" ]; then
|
|
||||||
htpasswd -bc $stat_dir/.htpasswd "$auth_user" "$auth_pass" &>/dev/null
|
|
||||||
else
|
|
||||||
htpasswd -b $stat_dir/.htpasswd "$auth_user" "$auth_pass" &>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
# Vesta #
|
|
||||||
#----------------------------------------------------------#
|
|
||||||
|
|
||||||
# Get current value
|
|
||||||
curr_val=$(get_domain_value 'web' '$STATS_AUTH')
|
|
||||||
check_uniq=$(echo "$curr_val" | grep -w "$auth_user")
|
|
||||||
|
|
||||||
# Checking current users
|
|
||||||
if [ -z "$curr_val" ] || [ "$curr_val" = 'no' ]; then
|
|
||||||
a_users="$auth_user"
|
|
||||||
else
|
|
||||||
if [ -z "$check_uniq" ]; then
|
|
||||||
a_users="$curr_val,$auth_user"
|
|
||||||
else
|
|
||||||
a_users="$curr_val"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Adding stats user in config
|
|
||||||
update_domain_value 'web' '$STATS_AUTH' "$a_users"
|
|
||||||
|
|
||||||
# Hiding password
|
|
||||||
EVENT="$DATE $SCRIPT $user $domain $auth_user *****"
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
log_history "$EVENT" "v_delete_web_domain_stat_auth $user $domain $auth_user"
|
|
||||||
log_event "$OK" "$EVENT"
|
|
||||||
|
|
||||||
exit
|
|
|
@ -19,7 +19,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
type=$3
|
type=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -29,32 +29,15 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain type'
|
check_args '3' "$#" 'user domain type'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user" "$user"
|
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
|
||||||
|
|
||||||
# Checking domain exist
|
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking statistic type
|
|
||||||
is_type_valid "$STATS_SYSTEM" "$type"
|
is_type_valid "$STATS_SYSTEM" "$type"
|
||||||
|
is_object_valid 'user' 'USER' "$user" "$user"
|
||||||
# Check statistic is not added
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
is_domain_key_empty 'web' '$STATS'
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
|
is_object_value_empty 'web' 'DOMAIN' "$domain" '$STATS'
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -87,14 +70,14 @@ cat $WEBTPL/$type.tpl |\
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding command to pipe
|
# Schedule statistic processing
|
||||||
echo "$BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
|
echo "$BIN/v_update_web_domain_stat $user $domain" >> $V_QUEUE/stats.pipe
|
||||||
|
|
||||||
# Adding stats in config
|
# Update config
|
||||||
update_domain_value 'web' '$STATS' "$type"
|
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_delete_web_domain_stat $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
72
bin/v_add_web_domain_stats_user
Executable file
72
bin/v_add_web_domain_stats_user
Executable file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: add password protection to web domain statistics
|
||||||
|
# options: user domain stats_user stats_password
|
||||||
|
#
|
||||||
|
# The call is used for securing the web statistics page.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument defenition
|
||||||
|
user=$1
|
||||||
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
|
stats_user=$3
|
||||||
|
stats_pass=$4
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
source $VESTA/func/shared.sh
|
||||||
|
source $VESTA/func/domain.sh
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '4' "$#" 'user domain stats_user stats_pass'
|
||||||
|
validate_format 'user' 'domain' 'stats_user' 'stats_pass'
|
||||||
|
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" '$STATS_USER'
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Definining statistic dir
|
||||||
|
stats_dir="$HOMEDIR/$user/web/$domain/stats"
|
||||||
|
|
||||||
|
# Adding htaccess file
|
||||||
|
rm -f $stats_dir/.htaccess
|
||||||
|
echo "AuthUserFile $stats_dir/.htpasswd
|
||||||
|
AuthName \"Web Statistics\"
|
||||||
|
AuthType Basic
|
||||||
|
Require valid-user" > $stats_dir/.htaccess
|
||||||
|
|
||||||
|
# Generating htaccess user and password
|
||||||
|
rm -f $stats_dir/.htpasswd
|
||||||
|
htpasswd -bc $stats_dir/.htpasswd "$stats_user" "$stats_pass" &>/dev/null
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Adding stats user in config
|
||||||
|
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' "$stats_user"
|
||||||
|
|
||||||
|
# Hiding password
|
||||||
|
EVENT="DATE='$DATE' TIME='$TIME' COMMAND='$SCRIPT'"
|
||||||
|
EVENT="$EVENT ARGUMENTS='$user $domain $stats_user *****'"
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_history "$EVENT"
|
||||||
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
|
exit
|
|
@ -64,7 +64,7 @@ sync_cron_jobs
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -53,7 +53,7 @@ update_domain_zone
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -70,7 +70,7 @@ update_domain_zone
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -51,7 +51,7 @@ update_domain_zone
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -79,7 +79,7 @@ update_domain_zone
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -50,7 +50,7 @@ update_domain_zone
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -16,7 +16,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ip=$3
|
ip=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -27,28 +27,14 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain ip'
|
check_args '3' "$#" 'user domain ip'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'ip'
|
validate_format 'user' 'domain' 'ip'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_ip_valid
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking ip
|
|
||||||
is_ip_avalable
|
is_ip_avalable
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,20 +76,18 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Increasing ip value
|
# Update counters
|
||||||
increase_ip_value "$new"
|
increase_ip_value "$new"
|
||||||
|
|
||||||
# Decreasing old ip value
|
|
||||||
decrease_ip_value "$old"
|
decrease_ip_value "$old"
|
||||||
|
|
||||||
# Adding ip in config
|
# Update config
|
||||||
update_domain_value 'web' '$IP' "$new"
|
update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$ip"
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "$SCRIPT $user $domain $old_ip"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -16,7 +16,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ssl_dir=$3
|
ssl_dir=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -26,31 +26,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain ssl_dir'
|
check_args '3' "$#" 'user domain ssl_dir'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'ssl_dir'
|
validate_format 'user' 'domain' 'ssl_dir'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Check SSL is added
|
|
||||||
is_domain_value_exist 'web' '$SSL'
|
|
||||||
|
|
||||||
# Checking ssl certificate
|
|
||||||
is_web_domain_cert_valid
|
is_web_domain_cert_valid
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,11 +69,11 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "$SCRIPT $user $domain $tmpdir"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -11,7 +11,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
ssl_home=$3
|
ssl_home=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -21,29 +21,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain ssl_home'
|
check_args '3' "$#" 'user domain ssl_home'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Check SSL is added
|
|
||||||
is_domain_value_exist 'web' '$SSL'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -55,7 +40,7 @@ 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/shttpd.conf"
|
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
|
||||||
|
|
||||||
# Parsing tpl_option
|
# Parsing tpl_option
|
||||||
case $SSL_HOME in
|
case $SSL_HOME in
|
||||||
|
@ -72,7 +57,7 @@ replace_web_config
|
||||||
# Checking nginx config
|
# Checking nginx config
|
||||||
if [ ! -z "$NGINX" ]; then
|
if [ ! -z "$NGINX" ]; then
|
||||||
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
|
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/snginx.conf"
|
conf="$HOMEDIR/$user/conf/web//snginx.conf"
|
||||||
replace_web_config
|
replace_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -81,14 +66,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding sslhome in config
|
# Update config
|
||||||
update_domain_value 'web' '$SSL_HOME' "$SSL_HOME"
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "$SCRIPT $user $domain $old_ssl_home"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -16,7 +16,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
template=$3
|
template=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -26,29 +26,13 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain template'
|
check_args '3' "$#" 'user domain template'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'template'
|
validate_format 'user' 'domain' 'template'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking template
|
|
||||||
templates=$(get_user_value '$WEB_TPL')
|
|
||||||
is_apache_template_valid
|
is_apache_template_valid
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,20 +160,20 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Changing tpl in config
|
# Changing tpl in config
|
||||||
update_domain_value 'web' '$TPL' "$template"
|
update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
|
||||||
|
|
||||||
# Updating db keys
|
# Updating db keys
|
||||||
for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
|
for keys in $(cat $WEBTPL/apache_$template.descr|grep -v '#'); do
|
||||||
key=$(echo "$keys"| cut -f 1 -d '=' |sed -e "s/^/\$/g")
|
key=$(echo "$keys"| cut -f 1 -d '=' |sed -e "s/^/\$/g")
|
||||||
value=$(echo "$keys" |cut -f 2 -d \')
|
value=$(echo "$keys" |cut -f 2 -d \')
|
||||||
update_domain_value 'web' "$key" "$value"
|
update_object_value 'web' 'DOMAIN' "$domain" "$key" "$value"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_change_web_domain_tpl $user $domain $old_tpl"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -53,7 +53,7 @@ sync_cron_jobs
|
||||||
decrease_user_value "$user" '$U_CRON_JOBS'
|
decrease_user_value "$user" '$U_CRON_JOBS'
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -45,7 +45,7 @@ sync_cron_jobs
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -59,7 +59,7 @@ decrease_user_value "$user" '$U_DNS_RECORDS' "$records"
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ update_domain_zone
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -42,7 +42,7 @@ done
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -98,7 +98,7 @@ fi
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
if [ "$web_restart" = 'yes' ]; then
|
if [ "$web_restart" = 'yes' ]; then
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -16,8 +16,9 @@
|
||||||
user=$1
|
user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
restart=$3
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -28,26 +29,13 @@ source $VESTA/func/ip.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -119,7 +107,7 @@ sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
|
||||||
# Checking last ssl domain
|
# Checking last ssl domain
|
||||||
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l)
|
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf | wc -l)
|
||||||
if [ "$ssl_dom" -eq '0' ]; then
|
if [ "$ssl_dom" -eq '0' ]; then
|
||||||
sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf
|
sed -i "s/ Include /#Include /" $HOMEDIR/$user/conf/web/httpd.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking last domain
|
# Checking last domain
|
||||||
|
@ -152,22 +140,18 @@ if [ -z "$last_nginx" ]; then
|
||||||
rm -f $HOMEDIR/$user/conf/web/nginx.conf
|
rm -f $HOMEDIR/$user/conf/web/nginx.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Decreasing ip value
|
# Decrease counters
|
||||||
decrease_ip_value "$IP"
|
decrease_ip_value "$IP"
|
||||||
|
|
||||||
# Decreasing domain value
|
|
||||||
decrease_user_value "$user" '$U_WEB_DOMAINS'
|
decrease_user_value "$user" '$U_WEB_DOMAINS'
|
||||||
|
|
||||||
# Decreasing web aliases
|
|
||||||
decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases"
|
decrease_user_value "$user" '$U_WEB_ALIASES' "$aliases"
|
||||||
|
|
||||||
# Decreasing web ssl
|
|
||||||
if [ "$SSL" = 'yes' ]; then
|
if [ "$SSL" = 'yes' ]; then
|
||||||
decrease_user_value "$user" '$U_WEB_SSL'
|
decrease_user_value "$user" '$U_WEB_SSL'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
if [ "$restart" != 'no' ]; then
|
||||||
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
||||||
|
|
|
@ -17,7 +17,7 @@ domain_idn=$(idn -t --quiet -a "$domain" )
|
||||||
dom_alias=$(idn -t --quiet -u "$3" )
|
dom_alias=$(idn -t --quiet -u "$3" )
|
||||||
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
|
dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -27,36 +27,21 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '3' "$#" 'user domain dom_alias'
|
check_args '3' "$#" 'user domain dom_alias'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain' 'dom_alias'
|
validate_format 'user' 'domain' 'dom_alias'
|
||||||
|
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
is_system_enabled 'WEB_SYSTEM'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking alias is added
|
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
check_alias=$(echo ${ALIAS//,/ }|grep -w "$dom_alias")
|
if [ -z "$(echo $ALIAS | tr ',' '\n' | grep ^$dom_alias$)" ]; then
|
||||||
if [ -z "$check_alias" ]; then
|
echo "Error: alias $dom_alias not exist"
|
||||||
echo "Error: alias not exist"
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
exit $E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -105,17 +90,17 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting alias
|
# Update config
|
||||||
update_domain_value 'web' '$ALIAS' "$ALIAS"
|
update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
|
||||||
|
|
||||||
# Update counters
|
# Update counters
|
||||||
decrease_user_value "$user" '$U_WEB_ALIASES'
|
decrease_user_value "$user" '$U_WEB_ALIASES'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_add_web_domain_alias $user $domain $dom_alias"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -17,7 +17,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -27,29 +27,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$CGI'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking cgi is added
|
|
||||||
is_domain_value_exist 'web' '$CGI'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -81,14 +66,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting cgi in config
|
# Update config
|
||||||
update_domain_value 'web' '$CGI' 'no'
|
update_object_value 'web' 'DOMAIN' "$domain" '$CGI' 'no'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_add_web_domain_cgi $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -16,7 +16,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -26,29 +26,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user" "$user"
|
is_object_valid 'user' 'USER' "$user" "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$ELOG'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Check errorlog is added
|
|
||||||
is_domain_value_exist 'web' '$ELOG'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -97,14 +82,14 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting elog in config
|
# Update config
|
||||||
update_domain_value 'web' '$ELOG' 'no'
|
update_object_value 'web' 'DOMAIN' "$domain" '$ELOG' 'no'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_add_web_domain_elog $user $domain"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -14,7 +14,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -24,29 +24,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$NGINX'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking ssl is added
|
|
||||||
is_domain_value_exist 'web' '$NGINX'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -56,13 +41,13 @@ is_domain_value_exist 'web' '$NGINX'
|
||||||
# Defining domain parameters
|
# Defining domain parameters
|
||||||
get_domain_values 'web'
|
get_domain_values 'web'
|
||||||
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
|
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.tpl"
|
||||||
conf="$HOMEDIR/$user/conf/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/ngingx_vhost_$NGINX.stpl"
|
tpl_file="$WEBTPL/ngingx_vhost_$NGINX.stpl"
|
||||||
conf="$HOMEDIR/$user/conf/snginx.conf"
|
conf="$HOMEDIR/$user/conf/web/snginx.conf"
|
||||||
del_web_config
|
del_web_config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -71,9 +56,9 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting nginx keys
|
# Update config
|
||||||
update_domain_value 'web' '$NGINX' ''
|
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX' ''
|
||||||
update_domain_value 'web' '$NGINX_EXT' ''
|
update_object_value 'web' 'DOMAIN' "$domain" '$NGINX_EXT' ''
|
||||||
|
|
||||||
# Checking last nginx domain
|
# Checking last nginx domain
|
||||||
conf='/etc/nginx/conf.d/vesta_users.conf'
|
conf='/etc/nginx/conf.d/vesta_users.conf'
|
||||||
|
@ -89,11 +74,11 @@ if [ -z "$last_nginx" ]; then
|
||||||
rm -f $HOMEDIR/$user/conf/web/nginx.conf
|
rm -f $HOMEDIR/$user/conf/web/nginx.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_add_web_domain_nginx $user $domain $NGINX $NGINX_EXT"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -14,7 +14,7 @@ user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -24,29 +24,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking ssl is added
|
|
||||||
is_domain_value_exist 'web' '$SSL'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -79,13 +64,13 @@ chown -R $user:$user $tmpdir
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Deleting ssl in config
|
# Update config
|
||||||
update_domain_value 'web' '$SSL' 'no'
|
update_object_value 'web' 'DOMAIN' "$domain" '$SSL' 'no'
|
||||||
|
|
||||||
# Checking last ssl domain
|
# Checking last ssl domain
|
||||||
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
|
ssl_dom=$(grep "SSL='yes'" $USER_DATA/web.conf)
|
||||||
main_conf='/etc/httpd/conf.d/vesta.conf'
|
main_conf='/etc/httpd/conf.d/vesta.conf'
|
||||||
conf="$HOMEDIR/$user/conf/shttpd.conf"
|
conf="$HOMEDIR/$user/conf/web/shttpd.conf"
|
||||||
if [ -z "$ssl_dom" ]; then
|
if [ -z "$ssl_dom" ]; then
|
||||||
sed -i "/Include ${conf////\/}/d" $main_conf
|
sed -i "/Include ${conf////\/}/d" $main_conf
|
||||||
rm -f $conf
|
rm -f $conf
|
||||||
|
@ -96,19 +81,18 @@ conf='/etc/nginx/conf.d/vesta_users.conf'
|
||||||
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
|
last_nginx=$(grep -v "NGINX=''" $USER_DATA/web.conf)
|
||||||
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
|
last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
|
||||||
if [ -z "$last_snginx" ]; then
|
if [ -z "$last_snginx" ]; then
|
||||||
if [ -z "$last_nginx" ]; then
|
sed -i "/$user\/conf\/web\/snginx.conf/d" $conf
|
||||||
sed -i "/$user\/conf\/snginx.conf/d" $conf
|
rm -f $HOMEDIR/$user/conf/web/snginx.conf
|
||||||
rm -f $HOMEDIR/$user/conf/snginx.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Decreasing domain value
|
# Decreasing domain value
|
||||||
decrease_user_value "$user" '$U_WEB_SSL'
|
decrease_user_value "$user" '$U_WEB_SSL'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Restart web server
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_add_web_domain_ssl $user $domain $tmpdir $SSL_HOME"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
user=$1
|
user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -24,29 +24,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '2' "$#" 'user domain'
|
check_args '2' "$#" 'user domain'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking stats enabled
|
|
||||||
is_domain_value_exist 'web' '$STATS'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -54,16 +39,16 @@ is_domain_value_exist 'web' '$STATS'
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining statistic type
|
# Defining statistic type
|
||||||
type=$(get_domain_value 'web' '$STATS')
|
get_domain_values 'web'
|
||||||
|
|
||||||
# Defining statistic dir
|
# Defining statistic dir
|
||||||
stat_dir="$HOMEDIR/$user/web/$domain/stats"
|
stats_dir="$HOMEDIR/$user/web/$domain/stats"
|
||||||
|
|
||||||
# Deleting dir content
|
# Deleting dir content
|
||||||
rm -rf $stat_dir/*
|
rm -rf $stats_dir/*
|
||||||
|
|
||||||
# Deleting config
|
# Deleting config
|
||||||
rm -f $HOMEDIR/$user/conf/$type.$domain.conf
|
rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -73,11 +58,11 @@ rm -f $HOMEDIR/$user/conf/$type.$domain.conf
|
||||||
# Deleting pipe command
|
# Deleting pipe command
|
||||||
sed -i "/ $domain$/d" $V_QUEUE/stats.pipe
|
sed -i "/ $domain$/d" $V_QUEUE/stats.pipe
|
||||||
|
|
||||||
# Deleting stats
|
# Update config
|
||||||
update_domain_value 'web' '$STATS' ''
|
update_object_value 'web' 'DOMAIN' "$domain" '$STATS' ''
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT" "v_add_web_domain_stat $user $doman $type"
|
log_history "$EVENT"
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
||||||
exit
|
exit
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# info: disable webdomain stats authentication support
|
# info: disable webdomain stats authentication support
|
||||||
# options: user domain [auth_user]
|
# options: user domain
|
||||||
#
|
#
|
||||||
# The function removes authentication of statistics system. If the script is
|
# The function removes authentication of statistics system. If the script is
|
||||||
# called without naming a certain user, all users will be removed. After
|
# called without naming a certain user, all users will be removed. After
|
||||||
|
@ -15,9 +15,8 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
domain=$(idn -t --quiet -u "$2" )
|
domain=$(idn -t --quiet -u "$2" )
|
||||||
auth_user=$3
|
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -27,29 +26,14 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
check_args '2' "$#" 'user domain'
|
||||||
check_args '2' "$#" 'user domain [auth_user]'
|
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
is_domain_valid 'web'
|
is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS_USER'
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
# Checking stats auth enabled
|
|
||||||
is_domain_value_exist 'web' '$STATS_AUTH'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -57,50 +41,16 @@ is_domain_value_exist 'web' '$STATS_AUTH'
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Definining statistic dir
|
# Definining statistic dir
|
||||||
stat_dir="$HOMEDIR/$user/web/$domain/stats"
|
rm -f $HOMEDIR/$user/web/$domain/stats/.htpasswd
|
||||||
|
rm -f $HOMEDIR/$user/web/$domain/stats/.htaccess
|
||||||
# Checking auth_user
|
|
||||||
if [ ! -z "$auth_user" ]; then
|
|
||||||
validate_format 'auth_user'
|
|
||||||
htpasswd -D $stat_dir/.htpasswd "$auth_user" &>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Checking htpasswd current users
|
|
||||||
lines=$(wc -l $stat_dir/.htpasswd |cut -f 1 -d ' ')
|
|
||||||
if [ -z "$auth_user" ] || [ "$lines" -eq '0' ]; then
|
|
||||||
rm -f $stat_dir/.htpasswd
|
|
||||||
rm -f $stat_dir/.htaccess
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking auth_user
|
# Update config
|
||||||
if [ ! -z "$auth_user" ]; then
|
update_object_value 'web' 'DOMAIN' "$domain" '$STATS_USER' ''
|
||||||
# Get current value
|
|
||||||
curr_val=$(get_domain_value 'web' '$STATS_AUTH')
|
|
||||||
|
|
||||||
# Deleteting auth_user
|
|
||||||
new_val=$(echo "$curr_val" |\
|
|
||||||
sed -e "s/,/\n/g"|\
|
|
||||||
sed -e "s/^$auth_user$//g"|\
|
|
||||||
sed -e "/^$/d"|\
|
|
||||||
sed -e ':a;N;$!ba;s/\n/,/g')
|
|
||||||
|
|
||||||
# Checking it was last user
|
|
||||||
if [ -z "$new_val" ]; then
|
|
||||||
new_val=''
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
|
||||||
# User empty, deleting all
|
|
||||||
new_val=''
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Deleting stats auth_user
|
|
||||||
update_domain_value 'web' '$STATS_AUTH' "$new_val"
|
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_history "$EVENT"
|
log_history "$EVENT"
|
|
@ -12,26 +12,18 @@
|
||||||
# Argument defenition
|
# Argument defenition
|
||||||
user=$1
|
user=$1
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking arg number
|
|
||||||
check_args '1' "$#" 'user'
|
check_args '1' "$#" 'user'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user'
|
validate_format 'user'
|
||||||
|
is_system_enabled "$WEB_SYSTEM"
|
||||||
# Checking web system is enabled
|
|
||||||
is_system_enabled 'WEB_SYSTEM'
|
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,26 +31,9 @@ is_object_valid 'user' 'USER' "$user"
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Defining config
|
|
||||||
conf="$USER_DATA/web.conf"
|
|
||||||
|
|
||||||
# Defining fileds to select
|
|
||||||
field='$DOMAIN'
|
|
||||||
|
|
||||||
# Defining search string
|
|
||||||
search_string="SUSPENDED='no'"
|
|
||||||
|
|
||||||
# Parsing domain list
|
|
||||||
domains=$(dom_clear_search)
|
|
||||||
|
|
||||||
# Starting delete loop
|
# Starting delete loop
|
||||||
for domain in $domains; do
|
for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
|
||||||
$BIN/v_delete_web_domain "$user" "$domain"
|
$BIN/v_delete_web_domain "$user" "$domain" 'no'
|
||||||
rv="$?"
|
|
||||||
if [ "$rv" -ne '0' ]; then
|
|
||||||
log_event 'debug' "$rv $EVENT"
|
|
||||||
exit $rv
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ domain=$(idn -t --quiet -u "$2" )
|
||||||
domain_idn=$(idn -t --quiet -a "$domain")
|
domain_idn=$(idn -t --quiet -a "$domain")
|
||||||
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
|
key=$(echo "$3"| tr '[:lower:]' '[:upper:]'|sed -e "s/^/$/")
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
source $VESTA/func/shared.sh
|
source $VESTA/func/shared.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -27,31 +27,19 @@ source $VESTA/func/domain.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking args
|
|
||||||
check_args '3' "$#" 'user domain key'
|
check_args '3' "$#" 'user domain key'
|
||||||
|
|
||||||
# Checking argument format
|
|
||||||
validate_format 'user' 'domain'
|
validate_format 'user' 'domain'
|
||||||
|
|
||||||
# Checking user
|
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
# Checking user is active
|
|
||||||
is_object_unsuspended 'user' 'USER' "$user"
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||||
# Checking domain exist
|
|
||||||
is_domain_valid 'web'
|
|
||||||
|
|
||||||
# Checking domain is not suspened
|
|
||||||
is_domain_suspended 'web'
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
value=$(get_domain_value 'web' "$key")
|
get_domain_values 'web'
|
||||||
echo "$value"
|
eval echo $key
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -40,7 +40,7 @@ sync_cron_jobs
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -121,7 +121,7 @@ update_user_value "$user" '$U_DNS_RECORDS' "$user_records"
|
||||||
update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
|
update_user_value "$user" '$SUSPENDED_DNS' "$suspended_dns"
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -228,7 +228,7 @@ update_user_value "$user" '$U_WEB_SSL' "$user_ssl"
|
||||||
update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
|
update_user_value "$user" '$U_WEB_ALIASES' "$user_aliases"
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
source $VESTA/func/shared.sh
|
||||||
|
EVENT=${1-$EVENT}
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
|
@ -20,8 +23,11 @@ source $VESTA/conf/vesta.conf
|
||||||
if [ "$CRON_SYSTEM" = 'crond' ]; then
|
if [ "$CRON_SYSTEM" = 'crond' ]; then
|
||||||
/etc/init.d/crond 'reload' &>/dev/null
|
/etc/init.d/crond 'reload' &>/dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "$E_RESTART $1"
|
/etc/init.d/crond 'restart' &>/dev/null
|
||||||
exit $E_RESTART
|
if [ $? -ne 0 ]; then
|
||||||
|
log_event "$E_RESTART" "$EVENT"
|
||||||
|
exit $E_RESTART
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source /etc/profile.d/vesta.sh
|
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
source $VESTA/func/shared.sh
|
||||||
|
EVENT=${1-$EVENT}
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
|
@ -21,9 +21,11 @@ source $VESTA/conf/vesta.conf
|
||||||
if [ "$DNS_SYSTEM" = 'bind' ]; then
|
if [ "$DNS_SYSTEM" = 'bind' ]; then
|
||||||
/etc/init.d/named reload &>/dev/null
|
/etc/init.d/named reload &>/dev/null
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
#$VESTA/func/report_issue 'sys' 'cron'
|
/etc/init.d/named restart &>/dev/null
|
||||||
echo "$E_RESTART $1"
|
if [ $? -ne 0 ]; then
|
||||||
exit $E_RESTART
|
log_event "$E_RESTART" "$EVENT"
|
||||||
|
exit $E_RESTART
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -9,56 +9,48 @@
|
||||||
# Variable&Function #
|
# Variable&Function #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Importing variables
|
# Includes
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
source $VESTA/func/shared.sh
|
||||||
# Restart functions
|
EVENT=${1-$EVENT}
|
||||||
apache() {
|
|
||||||
/etc/init.d/httpd status &>/dev/null
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
/etc/init.d/httpd graceful &>/dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "$E_RESTART $1"
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
/etc/init.d/httpd start &>/dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "$E_RESTART $1"
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
nginx() {
|
|
||||||
/etc/init.d/nginx status &>/dev/null
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
/etc/init.d/nginx reload &>/dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "$E_RESTART $1"
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
/etc/init.d/nginx start &>/dev/null
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "$E_RESTART $1"
|
|
||||||
exit $E_RESTART
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Checking system
|
|
||||||
if [ "$WEB_SYSTEM" = 'apache' ]; then
|
if [ "$WEB_SYSTEM" = 'apache' ]; then
|
||||||
apache $1
|
/etc/init.d/httpd status &>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
/etc/init.d/httpd graceful &>/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_event "$E_RESTART" "$EVENT"
|
||||||
|
exit $E_RESTART
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
/etc/init.d/httpd start &>/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_event "$E_RESTART" "$EVENT"
|
||||||
|
exit $E_RESTART
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
||||||
nginx $1
|
/etc/init.d/nginx status &>/dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
/etc/init.d/nginx reload &>/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_event "$E_RESTART" "$EVENT"
|
||||||
|
exit $E_RESTART
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
/etc/init.d/nginx start &>/dev/null
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
log_event "$E_RESTART" "$EVENT"
|
||||||
|
exit $E_RESTART
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,5 +58,4 @@ fi
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Logging
|
|
||||||
exit
|
exit
|
||||||
|
|
|
@ -48,7 +48,7 @@ sync_cron_jobs
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -41,7 +41,7 @@ done
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -50,7 +50,7 @@ increase_user_value "$user" '$SUSPENDED_DNS'
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -42,7 +42,7 @@ done
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -75,9 +75,9 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Changing suspend value
|
# Changing suspend value
|
||||||
update_user_value "$user" '$SUSPENDED' 'yes'
|
update_user_value "$user" '$SUSPENDED' 'yes'
|
||||||
|
|
|
@ -99,7 +99,7 @@ update_domain_value 'web' '$SUSPENDED' 'yes'
|
||||||
increase_user_value "$user" '$SUSPENDED_WEB'
|
increase_user_value "$user" '$SUSPENDED_WEB'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -48,7 +48,7 @@ sync_cron_jobs
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -41,7 +41,7 @@ done
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart crond
|
# Restart crond
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -50,7 +50,7 @@ decrease_user_value "$user" '$SUSPENDED_DNS'
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
if [ "$restart" != 'no' ]; then
|
if [ "$restart" != 'no' ]; then
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
|
@ -42,7 +42,7 @@ done
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Restart named
|
# Restart named
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -72,9 +72,9 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_cron
|
$BIN/v_restart_cron "$EVENT"
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
$BIN/v_restart_dns
|
$BIN/v_restart_dns "$EVENT"
|
||||||
|
|
||||||
# Changing suspend value
|
# Changing suspend value
|
||||||
update_user_value "$user" '$SUSPENDED' 'no'
|
update_user_value "$user" '$SUSPENDED' 'no'
|
||||||
|
|
|
@ -94,7 +94,7 @@ update_domain_value 'web' '$SUSPENDED' 'no'
|
||||||
decrease_user_value "$user" '$SUSPENDED_WEB'
|
decrease_user_value "$user" '$SUSPENDED_WEB'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$EVENT"
|
log_event "$OK" "$EVENT"
|
||||||
|
|
|
@ -95,7 +95,7 @@ increase_user_value "$user" '$IP_OWNED'
|
||||||
|
|
||||||
# Adding task to the vesta pipe
|
# Adding task to the vesta pipe
|
||||||
if [ "$web_restart" = 'yes' ]; then
|
if [ "$web_restart" = 'yes' ]; then
|
||||||
$BIN/v_restart_web
|
$BIN/v_restart_web "$EVENT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|
203
func/domain.sh
203
func/domain.sh
|
@ -1,11 +1,11 @@
|
||||||
# Web template check
|
# Web template check
|
||||||
is_apache_template_valid() {
|
is_apache_template_valid() {
|
||||||
c=$(echo "$templates" | grep -w "$template")
|
c=$(echo "$(get_user_value '$WEB_TPL')" | grep -w "$template")
|
||||||
t="$WEBTPL/apache_$template.tpl"
|
t="$WEBTPL/apache_$template.tpl"
|
||||||
d="$WEBTPL/apache_$template.descr"
|
d="$WEBTPL/apache_$template.descr"
|
||||||
s="$WEBTPL/apache_$template.stpl"
|
s="$WEBTPL/apache_$template.stpl"
|
||||||
if [ -z "$c" ] || [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
|
if [ -z "$c" ] || [ ! -e $t ] || [ ! -e $d ] || [ ! -e $s ]; then
|
||||||
echo "Error: $template not found"
|
echo "Error: template $template not found"
|
||||||
log_event "$E_NOTEXIST" "$EVENT"
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
exit $E_NOTEXIST
|
exit $E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
|
@ -38,19 +38,19 @@ is_dns_template_valid() {
|
||||||
is_domain_new() {
|
is_domain_new() {
|
||||||
config_type="$1"
|
config_type="$1"
|
||||||
dom=${2-$domain}
|
dom=${2-$domain}
|
||||||
check_all=$(grep -w $dom $V_USERS/*/*.conf)
|
check_all=$(grep -w $dom $VESTA/data/users/*/*.conf)
|
||||||
if [ ! -z "$check_all" ]; then
|
if [ ! -z "$check_all" ]; then
|
||||||
check_ownership=$(grep -w $dom $USER_DATA/*.conf)
|
check_ownership=$(grep -w $dom $USER_DATA/*.conf)
|
||||||
if [ ! -z "$check_ownership" ]; then
|
if [ ! -z "$check_ownership" ]; then
|
||||||
check_type=$(grep -w $dom $USER_DATA/$config_type.conf)
|
check_type=$(grep -w $dom $USER_DATA/$config_type.conf)
|
||||||
if [ ! -z "$check_type" ]; then
|
if [ ! -z "$check_type" ]; then
|
||||||
echo "Error: domain $dom exist"
|
echo "Error: domain $dom exist"
|
||||||
log_event 'debug' "$E_EXISTS $EVENT"
|
log_event "$E_EXISTS" "$EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "Error: domain $dom exist"
|
echo "Error: domain $dom exist"
|
||||||
log_event 'debug' "$E_EXISTS $EVENT"
|
log_event "$E_EXISTS" "$EVENT"
|
||||||
exit $E_EXISTS
|
exit $E_EXISTS
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -58,12 +58,9 @@ is_domain_new() {
|
||||||
|
|
||||||
# Update domain zone
|
# Update domain zone
|
||||||
update_domain_zone() {
|
update_domain_zone() {
|
||||||
# Definigng variables
|
|
||||||
conf="$HOMEDIR/$user/conf/dns/$domain.db"
|
conf="$HOMEDIR/$user/conf/dns/$domain.db"
|
||||||
line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
line=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
|
||||||
fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
|
fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
|
||||||
|
|
||||||
# Checking serial
|
|
||||||
if [ -e $conf ]; then
|
if [ -e $conf ]; then
|
||||||
zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g")
|
zn_serial=$(head $conf|grep 'SOA' -A1|tail -n 1|sed -e "s/ //g")
|
||||||
s_date=$(echo ${zn_serial:0:8})
|
s_date=$(echo ${zn_serial:0:8})
|
||||||
|
@ -83,12 +80,8 @@ update_domain_zone() {
|
||||||
serial="$(date +'%Y%m%d01')"
|
serial="$(date +'%Y%m%d01')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Parsing dns domains conf
|
|
||||||
eval $line
|
eval $line
|
||||||
|
|
||||||
# Converting SOA to ascii
|
|
||||||
SOA=$(idn --quiet -a -t "$SOA")
|
SOA=$(idn --quiet -a -t "$SOA")
|
||||||
# Adding zone header
|
|
||||||
echo "\$TTL $TTL
|
echo "\$TTL $TTL
|
||||||
@ IN SOA $SOA. root.$domain_idn. (
|
@ IN SOA $SOA. root.$domain_idn. (
|
||||||
$serial
|
$serial
|
||||||
|
@ -97,22 +90,18 @@ update_domain_zone() {
|
||||||
1209600
|
1209600
|
||||||
180 )
|
180 )
|
||||||
" > $conf
|
" > $conf
|
||||||
|
|
||||||
# Adding zone records
|
|
||||||
while read line ; do
|
while read line ; do
|
||||||
# Defining new delimeter
|
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
# Parsing key=value
|
|
||||||
for key in $(echo $line|sed -e "s/' /'\n/g"); do
|
for key in $(echo $line|sed -e "s/' /'\n/g"); do
|
||||||
eval ${key%%=*}="${key#*=}"
|
eval ${key%%=*}="${key#*=}"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Converting utf records to ascii
|
|
||||||
RECORD=$(idn --quiet -a -t "$RECORD")
|
RECORD=$(idn --quiet -a -t "$RECORD")
|
||||||
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
|
eval echo -e "\"$fields\""|sed -e "s/%quote%/'/g" >> $conf
|
||||||
done < $USER_DATA/dns/$domain.conf
|
done < $USER_DATA/dns/$domain.conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get next DNS record ID
|
||||||
get_next_dnsrecord(){
|
get_next_dnsrecord(){
|
||||||
if [ -z "$id" ]; then
|
if [ -z "$id" ]; then
|
||||||
curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
|
curr_str=$(grep "ID=" $USER_DATA/dns/$domain.conf | cut -f 2 -d \' |\
|
||||||
|
@ -121,15 +110,15 @@ get_next_dnsrecord(){
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Sort DNS records
|
||||||
sort_dns_records() {
|
sort_dns_records() {
|
||||||
# Defining conf
|
|
||||||
conf="$USER_DATA/dns/$domain.conf"
|
conf="$USER_DATA/dns/$domain.conf"
|
||||||
cat $conf |sort -n -k 2 -t \' >$conf.tmp
|
cat $conf |sort -n -k 2 -t \' >$conf.tmp
|
||||||
mv -f $conf.tmp $conf
|
mv -f $conf.tmp $conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add web config
|
||||||
add_web_config() {
|
add_web_config() {
|
||||||
# Adding template to config
|
|
||||||
cat $tpl_file | \
|
cat $tpl_file | \
|
||||||
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" \
|
||||||
|
@ -159,25 +148,22 @@ add_web_config() {
|
||||||
>> $conf
|
>> $conf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get config top and bottom line numbers
|
||||||
get_web_config_brds() {
|
get_web_config_brds() {
|
||||||
# Defining template borders
|
|
||||||
serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
|
serv_line=$(grep -ni 'Name %domain_idn%' "$tpl_file" |cut -f 1 -d :)
|
||||||
if [ -z "$serv_line" ]; then
|
if [ -z "$serv_line" ]; then
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
return $E_PARSING
|
return $E_PARSING
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Template lines
|
|
||||||
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
|
last_line=$(wc -l $tpl_file|cut -f 1 -d ' ')
|
||||||
bfr_line=$((serv_line - 1))
|
bfr_line=$((serv_line - 1))
|
||||||
aftr_line=$((last_line - serv_line - 1))
|
aftr_line=$((last_line - serv_line - 1))
|
||||||
|
|
||||||
# Config lines
|
|
||||||
str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
|
str=$(grep -ni "Name $domain_idn" $conf | cut -f 1 -d :)
|
||||||
top_line=$((str - serv_line + 1))
|
top_line=$((str - serv_line + 1))
|
||||||
bottom_line=$((top_line + last_line -1))
|
bottom_line=$((top_line + last_line -1))
|
||||||
|
|
||||||
# Check for multialias (8k alias issue)
|
|
||||||
multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
|
multi=$(sed -n "$top_line,$bottom_line p" $conf |grep ServerAlias |wc -l)
|
||||||
if [ "$multi" -ge 2 ]; then
|
if [ "$multi" -ge 2 ]; then
|
||||||
bottom_line=$((bottom_line + multi -1))
|
bottom_line=$((bottom_line + multi -1))
|
||||||
|
@ -185,173 +171,98 @@ get_web_config_brds() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Change web config
|
||||||
change_web_config() {
|
change_web_config() {
|
||||||
# Get config borders
|
|
||||||
get_web_config_brds || exit $?
|
get_web_config_brds || exit $?
|
||||||
|
|
||||||
# Parsing config
|
|
||||||
vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
|
vhost=$(grep -A $aftr_line -B $bfr_line -ni "Name $domain_idn" $conf)
|
||||||
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
|
str=$(echo "$vhost" | grep -F "$search_phrase" | head -n 1)
|
||||||
|
|
||||||
# Parsing string position and content
|
|
||||||
str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=')
|
str_numb=$(echo "$str" | sed -e "s/-/=/" | cut -f 1 -d '=')
|
||||||
str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=')
|
str_cont=$(echo "$str" | sed -e "s/-/=/" | cut -f 2 -d '=')
|
||||||
|
|
||||||
# Escaping chars
|
|
||||||
str_repl=$(echo "$str_repl" | sed \
|
str_repl=$(echo "$str_repl" | sed \
|
||||||
-e 's/\\/\\\\/g' \
|
-e 's/\\/\\\\/g' \
|
||||||
-e 's/&/\\&/g' \
|
-e 's/&/\\&/g' \
|
||||||
-e 's/\//\\\//g')
|
-e 's/\//\\\//g')
|
||||||
|
|
||||||
# Changing config
|
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
sed -i "$str_numb s/.*/$str_repl/" $conf
|
sed -i "$str_numb s/.*/$str_repl/" $conf
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Replace web config
|
||||||
replace_web_config() {
|
replace_web_config() {
|
||||||
# Get config borders
|
|
||||||
get_web_config_brds || exit $?
|
get_web_config_brds || exit $?
|
||||||
|
|
||||||
# Escaping chars
|
|
||||||
clean_new=$(echo "$new" | sed \
|
clean_new=$(echo "$new" | sed \
|
||||||
-e 's/\\/\\\\/g' \
|
-e 's/\\/\\\\/g' \
|
||||||
-e 's/&/\\&/g' \
|
-e 's/&/\\&/g' \
|
||||||
-e 's/\//\\\//g')
|
-e 's/\//\\\//g')
|
||||||
|
|
||||||
clean_old=$(echo "$old" | sed \
|
clean_old=$(echo "$old" | sed \
|
||||||
-e 's/\\/\\\\/g' \
|
-e 's/\\/\\\\/g' \
|
||||||
-e 's/&/\\&/g' \
|
-e 's/&/\\&/g' \
|
||||||
-e 's/\//\\\//g')
|
-e 's/\//\\\//g')
|
||||||
|
|
||||||
# Replacing string in config
|
|
||||||
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
|
sed -i "$top_line,$bottom_line s/$clean_old/$clean_new/" $conf
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get domain values
|
# Get domain variables
|
||||||
get_domain_values() {
|
get_domain_values() {
|
||||||
for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
|
for line in $(grep "DOMAIN='$domain'" $USER_DATA/$1.conf); do
|
||||||
eval $line
|
eval $line
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# SSL certificate verification
|
||||||
is_web_domain_cert_valid() {
|
is_web_domain_cert_valid() {
|
||||||
|
|
||||||
# Checking file existance
|
|
||||||
if [ ! -e "$ssl_dir/$domain.crt" ] || [ ! -e "$ssl_dir/$domain.key" ]; then
|
if [ ! -e "$ssl_dir/$domain.crt" ] || [ ! -e "$ssl_dir/$domain.key" ]; then
|
||||||
echo "Error: ssl certificate not exist"
|
echo "Error: $ssl_dir/$domain.[crt|key] not found"
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
exit $E_NOTEXIST
|
exit $E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking certificate
|
|
||||||
crt=$(openssl verify $ssl_dir/$domain.crt 2>/dev/null |grep '/C=')
|
crt=$(openssl verify $ssl_dir/$domain.crt 2>/dev/null |grep '/C=')
|
||||||
if [ -z "$crt" ]; then
|
if [ -z "$crt" ]; then
|
||||||
echo "Error: ssl certificate invalid"
|
echo "Error: certificate is not valid"
|
||||||
log_event 'debug' "$E_INVALID $EVENT"
|
log_event "$E_INVALID" "$EVENT"
|
||||||
exit $E_INVALID
|
exit $E_INVALID
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking certificate key
|
openssl rsa -in "$ssl_dir/$domain.key" -check &>/dev/null
|
||||||
openssl rsa -in "$ssl_dir/$domain.key" -check >/dev/null 2>/dev/null
|
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
echo "Error: ssl key invalid"
|
echo "Error: ssl key is not valid"
|
||||||
log_event 'debug' "$E_INVALID $EVENT"
|
log_event "$E_INVALID" "$EVENT"
|
||||||
exit $E_INVALID
|
exit $E_INVALID
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking certificate authority
|
|
||||||
if [ -e "$ssl_dir/$domain.ca" ]; then
|
if [ -e "$ssl_dir/$domain.ca" ]; then
|
||||||
ca=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep '/C=')
|
ca=$(openssl verify $ssl_dir/$domain.ca 2>/dev/null |grep '/C=')
|
||||||
if [ -z "$ca" ]; then
|
if [ -z "$ca" ]; then
|
||||||
echo "Error: ssl certificate invalid"
|
echo "Error: ssl certificate authority is not valid"
|
||||||
log_event 'debug' "$E_INVALID $EVENT"
|
log_event "$E_INVALID" "$EVENT"
|
||||||
exit $E_INVALID
|
exit $E_INVALID
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking server
|
openssl s_server -quiet -cert $ssl_dir/$domain.crt \
|
||||||
openssl s_server -quiet \
|
-key $ssl_dir/$domain.key &
|
||||||
-cert $ssl_dir/$domain.crt -key $ssl_dir/$domain.key &
|
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 1
|
sleep 0.5
|
||||||
disown > /dev/null 2>&1
|
disown &> /dev/null
|
||||||
kill $pid > /dev/null 2>&1
|
kill $pid &> /dev/null
|
||||||
result=$?
|
if [ "$?" -ne '0' ]; then
|
||||||
if [ "$result" -ne '0' ]; then
|
echo "Error: ssl certificate key pair is not valid"
|
||||||
echo "Error: ssl certificate key pair invalid"
|
log_event "$E_INVALID" "$EVENT"
|
||||||
log_event 'debug' "$E_INVALID $EVENT"
|
|
||||||
exit $E_INVALID
|
exit $E_INVALID
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
is_dns_record_valid() {
|
# Delete web configuartion
|
||||||
# Checking record id
|
|
||||||
check_id=$(grep "^ID='$id'" $USER_DATA/dns/$domain)
|
|
||||||
|
|
||||||
if [ -z "$check_id" ]; then
|
|
||||||
echo "Error: ID not exist"
|
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_domain_value_exist() {
|
|
||||||
domain_type="$1"
|
|
||||||
key="$2"
|
|
||||||
|
|
||||||
# Parsing domains
|
|
||||||
string=$( grep "DOMAIN='$domain'" $USER_DATA/$domain_type.conf )
|
|
||||||
|
|
||||||
# Parsing key=value
|
|
||||||
eval $string
|
|
||||||
|
|
||||||
# Self reference
|
|
||||||
eval value="$key"
|
|
||||||
|
|
||||||
# Checking result
|
|
||||||
if [ -z "$value" ] || [ "$value" = 'no' ]; then
|
|
||||||
echo "Error: ${key//$/} is empty"
|
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
del_web_config() {
|
del_web_config() {
|
||||||
# Get config borders
|
|
||||||
get_web_config_brds || exit $?
|
get_web_config_brds || exit $?
|
||||||
|
|
||||||
# Deleting lines from config
|
|
||||||
sed -i "$top_line,$bottom_line d" $conf
|
sed -i "$top_line,$bottom_line d" $conf
|
||||||
}
|
}
|
||||||
|
|
||||||
dom_clear_search(){
|
# Add ip virtual hosting support
|
||||||
# Defining delimeter
|
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
# Reading file line by line
|
|
||||||
for line in $(grep $search_string $conf); do
|
|
||||||
# Parsing key=val
|
|
||||||
eval $line
|
|
||||||
|
|
||||||
# Print result line
|
|
||||||
eval echo "$field"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
dom_clear_list() {
|
|
||||||
# Reading file line by line
|
|
||||||
while read line ; do
|
|
||||||
# Parsing key=value
|
|
||||||
eval $line
|
|
||||||
|
|
||||||
# Print result line
|
|
||||||
eval echo "$field"
|
|
||||||
done < $conf
|
|
||||||
}
|
|
||||||
|
|
||||||
namehost_ip_support() {
|
namehost_ip_support() {
|
||||||
# Checking httpd config for NameHost string number
|
|
||||||
if [ "$WEB_SYSTEM" = 'apache' ]; then
|
if [ "$WEB_SYSTEM" = 'apache' ]; then
|
||||||
conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':')
|
conf_line=$(grep -n "NameVirtual" $conf|tail -n 1|cut -f 1 -d ':')
|
||||||
if [ ! -z "$conf_line" ]; then
|
if [ ! -z "$conf_line" ]; then
|
||||||
|
@ -360,7 +271,6 @@ namehost_ip_support() {
|
||||||
conf_ins='1'
|
conf_ins='1'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking ssl support
|
|
||||||
if [ "$WEB_SSL" = 'mod_ssl' ]; then
|
if [ "$WEB_SSL" = 'mod_ssl' ]; then
|
||||||
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf
|
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_SSL_PORT" $conf
|
||||||
sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf
|
sed -i "$conf_ins i Listen $ip:$WEB_SSL_PORT" $conf
|
||||||
|
@ -369,67 +279,54 @@ namehost_ip_support() {
|
||||||
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf
|
sed -i "$conf_ins i NameVirtualHost $ip:$WEB_PORT" $conf
|
||||||
sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
|
sed -i "$conf_ins i Listen $ip:$WEB_PORT" $conf
|
||||||
|
|
||||||
# Checking proxy support
|
|
||||||
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
if [ "$PROXY_SYSTEM" = 'nginx' ]; then
|
||||||
cat $WEBTPL/ngingx_ip.tpl | sed -e "s/%ip%/$ip/g" \
|
cat $WEBTPL/ngingx_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
|
||||||
|
|
||||||
# Adding to rpaf ip pool as well
|
|
||||||
ips=$(grep 'RPAFproxy_ips' $rconf)
|
ips=$(grep 'RPAFproxy_ips' $rconf)
|
||||||
sed -i "s/$ips/$ips $ip/g" $rconf
|
sed -i "s/$ips/$ips $ip/g" $rconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Scheduling restart
|
|
||||||
web_restart='yes'
|
web_restart='yes'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Disable virtual ip hosting support
|
||||||
namehost_ip_disable() {
|
namehost_ip_disable() {
|
||||||
#Checking web system
|
|
||||||
if [ "$WEB_SYSTEM" = 'apache' ]; then
|
if [ "$WEB_SYSTEM" = 'apache' ]; then
|
||||||
sed -i "/NameVirtualHost $ip:/d" $conf
|
sed -i "/NameVirtualHost $ip:/d" $conf
|
||||||
sed -i "/Listen $ip:/d" $conf
|
sed -i "/Listen $ip:/d" $conf
|
||||||
|
|
||||||
# Checking proxy support
|
|
||||||
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/ngingx_ip.tpl | cut -f 1 -d ' ')
|
||||||
ip_line=$(grep -n "%ip%" $WEBTPL/ngingx_ip.tpl |head -n1 |\
|
ip_line=$(grep -n "%ip%" $WEBTPL/ngingx_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 :)
|
||||||
|
|
||||||
# Checking parsed lines
|
|
||||||
if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]
|
if [ -z "$tpl_ln" ] || [ -z "$ip_line" ] || [ -z "$conf_line" ]
|
||||||
then
|
then
|
||||||
echo "Error: nginx config paring error"
|
echo "Error: nginx config paring error"
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
exit $E_PARSING
|
exit $E_PARSING
|
||||||
fi
|
fi
|
||||||
|
|
||||||
up_line=$((ip_line - 1))
|
up_line=$((ip_line - 1))
|
||||||
first_line=$((conf_line - up_line))
|
first_line=$((conf_line - up_line))
|
||||||
last_line=$((conf_line - ip_line + tpl_ln))
|
last_line=$((conf_line - ip_line + tpl_ln))
|
||||||
|
|
||||||
# Checking parsed lines
|
|
||||||
if [ -z "$first_line" ] || [ -z "$last_line" ]; then
|
if [ -z "$first_line" ] || [ -z "$last_line" ]; then
|
||||||
echo "Error: nginx config paring error"
|
echo "Error: nginx config paring error"
|
||||||
log_event 'debug' "$E_PARSING $EVENT"
|
log_event "$E_PARSING" "$EVENT"
|
||||||
exit $E_PARSING
|
exit $E_PARSING
|
||||||
fi
|
fi
|
||||||
sed -i "$first_line,$last_line d" $nconf
|
sed -i "$first_line,$last_line d" $nconf
|
||||||
|
|
||||||
# Deleting from rpaf ip pool as well
|
|
||||||
ips=$(grep 'RPAFproxy_ips' $rconf)
|
ips=$(grep 'RPAFproxy_ips' $rconf)
|
||||||
new_ips=$(echo "$ips"|sed -e "s/$ip//")
|
new_ips=$(echo "$ips"|sed -e "s/$ip//")
|
||||||
sed -i "s/$ips/$new_ips/g" $rconf
|
sed -i "s/$ips/$new_ips/g" $rconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Scheduling restart
|
|
||||||
web_restart='yes'
|
web_restart='yes'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Update web domain values
|
||||||
upd_web_domain_values() {
|
upd_web_domain_values() {
|
||||||
ip=$IP
|
ip=$IP
|
||||||
group="$user"
|
group="$user"
|
||||||
|
@ -438,7 +335,6 @@ upd_web_domain_values() {
|
||||||
docroot_string="DocumentRoot $docroot"
|
docroot_string="DocumentRoot $docroot"
|
||||||
proxy_string="proxy_pass http://$ip:$WEB_PORT;"
|
proxy_string="proxy_pass http://$ip:$WEB_PORT;"
|
||||||
|
|
||||||
# Parsing domain aliases
|
|
||||||
i=1
|
i=1
|
||||||
j=1
|
j=1
|
||||||
OLD_IFS="$IFS"
|
OLD_IFS="$IFS"
|
||||||
|
@ -447,7 +343,6 @@ upd_web_domain_values() {
|
||||||
alias_string=''
|
alias_string=''
|
||||||
for dalias in $ALIAS; do
|
for dalias in $ALIAS; do
|
||||||
dalias=$(idn -t --quiet -a $dalias)
|
dalias=$(idn -t --quiet -a $dalias)
|
||||||
# Spliting ServerAlias lines
|
|
||||||
check_8k="$server_alias $dalias"
|
check_8k="$server_alias $dalias"
|
||||||
if [ "${#check_8k}" -ge '8100' ]; then
|
if [ "${#check_8k}" -ge '8100' ]; then
|
||||||
if [ "$j" -eq 1 ]; then
|
if [ "$j" -eq 1 ]; then
|
||||||
|
@ -476,15 +371,12 @@ upd_web_domain_values() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=$OLD_IFS
|
IFS=$OLD_IFS
|
||||||
|
|
||||||
# Checking error log status
|
|
||||||
if [ "$ELOG" = 'no' ]; then
|
if [ "$ELOG" = 'no' ]; then
|
||||||
elog='#'
|
elog='#'
|
||||||
else
|
else
|
||||||
elog=''
|
elog=''
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking cgi
|
|
||||||
if [ "$CGI" != 'yes' ]; then
|
if [ "$CGI" != 'yes' ]; then
|
||||||
cgi='#'
|
cgi='#'
|
||||||
cgi_option='-ExecCGI'
|
cgi_option='-ExecCGI'
|
||||||
|
@ -493,13 +385,11 @@ upd_web_domain_values() {
|
||||||
cgi_option='+ExecCGI'
|
cgi_option='+ExecCGI'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Checking suspend
|
|
||||||
if [ "$SUSPENDED" = 'yes' ]; then
|
if [ "$SUSPENDED" = 'yes' ]; then
|
||||||
docroot_string="Redirect / http://$url"
|
docroot_string="Redirect / http://$url"
|
||||||
proxy_string="rewrite ^(.*)\$ http://$url;"
|
proxy_string="rewrite ^(.*)\$ http://$url;"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Defining SSL vars
|
|
||||||
ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
|
ssl_crt="$HOMEDIR/$user/conf/web/ssl.$domain.crt"
|
||||||
ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
|
ssl_key="$HOMEDIR/$user/conf/web/ssl.$domain.key"
|
||||||
ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
|
ssl_pem="$HOMEDIR/$user/conf/web/ssl.$domain.pem"
|
||||||
|
@ -514,22 +404,3 @@ upd_web_domain_values() {
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
is_mail_account_free() {
|
|
||||||
acc=${1-$account}
|
|
||||||
check_acc=$(grep -w $acc $USER_DATA/mail/$domain.conf)
|
|
||||||
if [ ! -z "$check_acc" ]; then
|
|
||||||
echo "Error: account $acc exists"
|
|
||||||
log_event 'debug' "$E_EXISTS $EVENT"
|
|
||||||
exit $E_EXISTS
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_mail_account_valid() {
|
|
||||||
acc=${1-$account}
|
|
||||||
check_acc=$(grep -w $acc $USER_DATA/mail/$domain.conf)
|
|
||||||
if [ -z "$check_acc" ]; then
|
|
||||||
echo "Error: account $acc not exist"
|
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
85
func/ip.sh
85
func/ip.sh
|
@ -1,3 +1,41 @@
|
||||||
|
# Validationg ip address
|
||||||
|
is_ip_valid() {
|
||||||
|
check_ifc=$(/sbin/ifconfig |grep "inet addr:$ip")
|
||||||
|
if [ ! -e "$VESTA/data/ips/$ip" ] || [ -z "$check_ifc" ]; then
|
||||||
|
echo "Error: IP $ip not exist"
|
||||||
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
|
exit $E_NOTEXIST
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if ip availabile for user
|
||||||
|
is_ip_avalable() {
|
||||||
|
ip_data=$(cat $VESTA/data/ips/$ip)
|
||||||
|
owner=$(echo "$ip_data"|grep OWNER= | cut -f 2 -d \')
|
||||||
|
status=$(echo "$ip_data"|grep OWNER= | cut -f 2 -d \')
|
||||||
|
shared=no
|
||||||
|
if [ 'admin' = "$owner" ] && [ "$status" = 'shared' ]; then
|
||||||
|
shared='yes'
|
||||||
|
fi
|
||||||
|
if [ "$owner" != "$user" ] && [ "$shared" != 'yes' ]; then
|
||||||
|
echo "Error: User $user don't have permission to use $ip"
|
||||||
|
log_event "$E_FORBIDEN" "$EVENT"
|
||||||
|
exit $E_FORBIDEN
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check ip ownership
|
||||||
|
is_sys_ip_owner() {
|
||||||
|
# Parsing ip
|
||||||
|
owner=$(grep 'OWNER=' $VESTA/data/ips/$IP|cut -f 2 -d \')
|
||||||
|
if [ "$owner" != "$user" ]; then
|
||||||
|
echo "Error: IP $IP not owned"
|
||||||
|
log_event "$E_FORBIDEN" "$EVENT"
|
||||||
|
exit $E_FORBIDEN
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
is_sys_ip_free() {
|
is_sys_ip_free() {
|
||||||
# Parsing system ips
|
# Parsing system ips
|
||||||
ip_list=$(/sbin/ifconfig|grep 'inet addr:'|cut -f 2 -d ':'|cut -f 1 -d " ")
|
ip_list=$(/sbin/ifconfig|grep 'inet addr:'|cut -f 2 -d ':'|cut -f 1 -d " ")
|
||||||
|
@ -25,17 +63,6 @@ get_next_interface_number() {
|
||||||
echo ":$n"
|
echo ":$n"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_sys_ip_valid() {
|
|
||||||
# Parsing ifconfig
|
|
||||||
check_ifc=$(/sbin/ifconfig |grep "inet addr:$ip")
|
|
||||||
|
|
||||||
# Checking ip existance
|
|
||||||
if [ ! -e "$VESTA/data/ips/$ip" ] || [ -z "$check_ifc" ]; then
|
|
||||||
echo "Error: IP not exist"
|
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_ip_key_empty() {
|
is_ip_key_empty() {
|
||||||
key="$1"
|
key="$1"
|
||||||
|
@ -88,43 +115,7 @@ update_sys_ip_value() {
|
||||||
$conf
|
$conf
|
||||||
}
|
}
|
||||||
|
|
||||||
is_ip_avalable() {
|
|
||||||
# Checking ip existance
|
|
||||||
if [ ! -e "$VESTA/data/ips/$ip" ]; then
|
|
||||||
echo "Error: IP not exist"
|
|
||||||
log_event 'debug' "$E_NOTEXIST $EVENT"
|
|
||||||
exit $E_NOTEXIST
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Parsing ip data
|
|
||||||
ip_data=$(cat $VESTA/data/ips/$ip)
|
|
||||||
ip_owner=$(echo "$ip_data" | grep 'OWNER=' | cut -f 2 -d \' )
|
|
||||||
ip_status=$(echo "$ip_data" | grep 'STATUS=' | cut -f 2 -d \' )
|
|
||||||
|
|
||||||
# Parsing user data
|
|
||||||
if [ 'admin' = "$ip_owner" ] && [ "$ip_status" = 'shared' ]; then
|
|
||||||
ip_shared='yes'
|
|
||||||
else
|
|
||||||
ip_shared='no'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$ip_owner" != "$user" ] && [ "$ip_shared" != 'yes' ]; then
|
|
||||||
echo "Error: ip not owned by user"
|
|
||||||
log_event 'debug' "$E_FORBIDEN $EVENT"
|
|
||||||
exit $E_FORBIDEN
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_sys_ip_owner() {
|
|
||||||
# Parsing ip
|
|
||||||
ip="$IP"
|
|
||||||
ip_owner=$(grep 'OWNER=' $VESTA/data/ips/$ip|cut -f 2 -d \')
|
|
||||||
if [ "$ip_owner" != "$user" ]; then
|
|
||||||
echo "Error: IP not owned"
|
|
||||||
log_event 'debug' "$E_FORBIDEN $EVENT"
|
|
||||||
exit $E_FORBIDEN
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
get_ip_name() {
|
get_ip_name() {
|
||||||
# Prinitng name
|
# Prinitng name
|
||||||
|
|
|
@ -113,7 +113,7 @@ is_package_valid() {
|
||||||
# Validate system type
|
# Validate system type
|
||||||
is_type_valid() {
|
is_type_valid() {
|
||||||
if [ -z "$(echo $1 | grep -w $2)" ]; then
|
if [ -z "$(echo $1 | grep -w $2)" ]; then
|
||||||
echo "Error: unknown type"
|
echo "Error: $2 is unknown type"
|
||||||
log_event "$E_INVALID" "$EVENT"
|
log_event "$E_INVALID" "$EVENT"
|
||||||
exit $E_INVALID
|
exit $E_INVALID
|
||||||
fi
|
fi
|
||||||
|
@ -193,6 +193,30 @@ is_object_unsuspended() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if object value is empty
|
||||||
|
is_object_value_empty() {
|
||||||
|
str=$(grep "$2='$3'" $USER_DATA/$1.conf)
|
||||||
|
eval $str
|
||||||
|
eval value=$4
|
||||||
|
if [ ! -z "$value" ] && [ "$value" != 'no' ]; then
|
||||||
|
echo "Error: ${4//$}=$value (not empty)"
|
||||||
|
log_event "$E_EXISTS" "$EVENT"
|
||||||
|
exit $E_EXISTS
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if object value is empty
|
||||||
|
is_object_value_exist() {
|
||||||
|
str=$(grep "$2='$3'" $USER_DATA/$1.conf)
|
||||||
|
eval $str
|
||||||
|
eval value=$4
|
||||||
|
if [ -z "$value" ] || [ "$value" = 'no' ]; then
|
||||||
|
echo "Error: ${4//$}=$value (not exist)"
|
||||||
|
log_event "$E_NOTEXIST" "$EVENT"
|
||||||
|
exit $E_NOTEXIST
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Get object value
|
# Get object value
|
||||||
get_object_value() {
|
get_object_value() {
|
||||||
object=$(grep "$2='$3'" $USER_DATA/$1.conf)
|
object=$(grep "$2='$3'" $USER_DATA/$1.conf)
|
||||||
|
@ -617,8 +641,6 @@ validate_format(){
|
||||||
account) validate_format_username "$arg" "$arg_name" ;;
|
account) validate_format_username "$arg" "$arg_name" ;;
|
||||||
antispam) validate_format_boolean "$arg" ;;
|
antispam) validate_format_boolean "$arg" ;;
|
||||||
antivirus) validate_format_boolean "$arg" ;;
|
antivirus) validate_format_boolean "$arg" ;;
|
||||||
auth_pass) validate_format_password "$arg" ;;
|
|
||||||
auth_user) validate_format_username "$arg" "$arg_name" ;;
|
|
||||||
backup) validate_format_date "$arg" ;;
|
backup) validate_format_date "$arg" ;;
|
||||||
charset) validate_format_username "$arg" "$arg_name" ;;
|
charset) validate_format_username "$arg" "$arg_name" ;;
|
||||||
charsets) validate_format_common "$arg" 'charsets' ;;
|
charsets) validate_format_common "$arg" 'charsets' ;;
|
||||||
|
@ -667,6 +689,8 @@ validate_format(){
|
||||||
rtype) validate_format_dns_type "$arg" ;;
|
rtype) validate_format_dns_type "$arg" ;;
|
||||||
shell) validate_format_shell "$arg" ;;
|
shell) validate_format_shell "$arg" ;;
|
||||||
soa) validate_format_domain "$arg" ;;
|
soa) validate_format_domain "$arg" ;;
|
||||||
|
stats_pass) validate_format_password "$arg" ;;
|
||||||
|
stats_user) validate_format_username "$arg" "$arg_name" ;;
|
||||||
template) validate_format_username "$arg" "$arg_name" ;;
|
template) validate_format_username "$arg" "$arg_name" ;;
|
||||||
ttl) validate_format_int "$arg" ;;
|
ttl) validate_format_int "$arg" ;;
|
||||||
url) validate_format_url "$arg" ;;
|
url) validate_format_url "$arg" ;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue