Browse Source

Merge branch 'mail-ssl' into mail-stack

Kristan Kenney 7 năm trước cách đây
mục cha
commit
825c0a930a

+ 2 - 2
bin/v-add-letsencrypt-domain

@@ -85,9 +85,9 @@ fi
 
 
 # Rework domain and alieses for mail.
 # Rework domain and alieses for mail.
 if [ ! -z "$mail" ]; then
 if [ ! -z "$mail" ]; then
-    original_domain="mail.$domain"
-    domain="mail.$domain"
+    original_domain=$domain
     aliases="webmail.$domain,autodiscover.$domain"
     aliases="webmail.$domain,autodiscover.$domain"
+    domain="mail.$domain"
 fi
 fi
 
 
 # Registering LetsEncrypt user account
 # Registering LetsEncrypt user account

+ 5 - 0
bin/v-change-dns-domain-tpl

@@ -137,6 +137,11 @@ fi
 update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 
 
+# Rebuild DNS zone and update counters to ensure that it has updated correctly
+$BIN/v-rebuild-dns-domain $user $domain no
+$BIN/v-update-user-stats $user
+$BIN/v-update-user-counters $user
+
 # Restarting named
 # Restarting named
 $BIN/v-restart-dns $restart
 $BIN/v-restart-dns $restart
 check_result $? "DNS restart failed" >/dev/null
 check_result $? "DNS restart failed" >/dev/null

+ 77 - 0
bin/v-change-web-domain-dirlist

@@ -0,0 +1,77 @@
+#!/bin/bash
+# info: enable/disable directory listing
+# options: USER DOMAIN MODE
+#
+# The call is used for changing the directory list mode.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+mode=$3
+
+# Includes
+source $HESTIA/func/main.sh
+source $HESTIA/func/domain.sh
+source $HESTIA/conf/hestia.conf
+
+# Additional argument formatting
+format_domain
+format_domain_idn
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER DOMAIN MODE'
+is_format_valid 'user' 'domain'
+is_system_enabled "$WEB_SYSTEM" '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"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Fetching domain variables
+get_domain_values 'web'
+
+if [ "$mode" = "on" ]; then
+    # Enable directory listing
+    sed -i "s/-Index/+Index/g" $HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf
+    if [ -e "$ssl_dir/$domain.ca" ]; then
+        # Enable directory listing for SSL-enforced domains
+        sed -i "s/-Index/+Index/g" $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf
+    fi
+    echo "INFO: Enabled directory browsing for $domain."
+else
+    # Disable directory listing
+    sed -i "s/+Index/-Index/g" $HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf
+    if [ -e "$ssl_dir/$domain.ca" ]; then
+        # Enable directory listing for SSL-enforced domains
+        sed -i "s/+Index/-Index/g" $HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf
+    fi
+    echo "INFO: Disabled directory browsing for $domain."
+fi
+
+
+#----------------------------------------------------------#
+#                       Hestia                             #
+#----------------------------------------------------------#
+
+# Rebuilding vhosts
+$BIN/v-restart-web
+
+# Logging
+log_history "turned directory browsing $mode for $domain."
+log_event "$OK" "$EVENT"
+
+exit

+ 4 - 3
install/deb/templates/dns/child-ns.tpl

@@ -10,6 +10,7 @@ ID='9' RECORD='smtp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%tim
 ID='10' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='10' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='11' RECORD='imap' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='11' RECORD='imap' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='12' RECORD='autodiscover' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='12' RECORD='autodiscover' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
-ID='13' RECORD='@' TYPE='MX' PRIORITY='0' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
-ID='14' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% -all"' SUSPENDED='no' TIME='%time%' DATE='%date%'
-ID='15' RECORD='_dmarc' TYPE='TXT' PRIORITY='' VALUE='"v=DMARC1; p=quarantine; pct=100"' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='13' RECORD='webmail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='14' RECORD='@' TYPE='MX' PRIORITY='0' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='15' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% -all"' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='16' RECORD='_dmarc' TYPE='TXT' PRIORITY='' VALUE='"v=DMARC1; p=quarantine; pct=100"' SUSPENDED='no' TIME='%time%' DATE='%date%'

+ 4 - 3
install/deb/templates/dns/default.tpl

@@ -14,6 +14,7 @@ ID='13' RECORD='smtp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%ti
 ID='14' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='14' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='15' RECORD='imap' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='15' RECORD='imap' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='16' RECORD='autodiscover' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
 ID='16' RECORD='autodiscover' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
-ID='17' RECORD='@' TYPE='MX' PRIORITY='0' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
-ID='18' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% -all"' SUSPENDED='no' TIME='%time%' DATE='%date%'
-ID='19' RECORD='_dmarc' TYPE='TXT' PRIORITY='' VALUE='"v=DMARC1; p=quarantine; pct=100"' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='17' RECORD='webmail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='18' RECORD='@' TYPE='MX' PRIORITY='0' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='19' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% -all"' SUSPENDED='no' TIME='%time%' DATE='%date%'
+ID='20' RECORD='_dmarc' TYPE='TXT' PRIORITY='' VALUE='"v=DMARC1; p=quarantine; pct=100"' SUSPENDED='no' TIME='%time%' DATE='%date%'

+ 4 - 4
install/upgrade/0.9.8-29.sh

@@ -2,6 +2,7 @@
 
 
 # define vars
 # define vars
 HESTIA="/usr/local/hestia"
 HESTIA="/usr/local/hestia"
+HESTIA_BACKUP="/root/hst_upgrade/$(date +%d%m%Y%H%M)"
 hestiacp="$HESTIA/install/deb"
 hestiacp="$HESTIA/install/deb"
 
 
 # load hestia.conf
 # load hestia.conf
@@ -100,9 +101,7 @@ chmod 751 $HESTIA/data/templates/web/unassigned/js
 chmod 751 $HESTIA/data/templates/web/unassigned/webfonts
 chmod 751 $HESTIA/data/templates/web/unassigned/webfonts
 
 
 # Add unassigned hosts configuration to nginx and apache2
 # Add unassigned hosts configuration to nginx and apache2
-if [ "$WEB_BACKEND" = "php-fpm" ]; then
-    echo "(!) Unassigned hosts configuration for Apache not necessary on PHP-FPM installations."
-elif [ "$WEB_BACKEND" = "apache2" ]; then
+if [ "$WEB_SYSTEM" = "apache2" ]; then
     echo "(*) Adding unassigned hosts configuration to apache2..."
     echo "(*) Adding unassigned hosts configuration to apache2..."
     if [ -f /usr/local/hestia/data/ips/* ]; then
     if [ -f /usr/local/hestia/data/ips/* ]; then
         for ip in /usr/local/hestia/data/ips/*; do
         for ip in /usr/local/hestia/data/ips/*; do
@@ -112,7 +111,8 @@ elif [ "$WEB_BACKEND" = "apache2" ]; then
             sed -i 's/directIP/'$ipaddr'/g' /etc/apache2/conf.d/$ipaddr.conf
             sed -i 's/directIP/'$ipaddr'/g' /etc/apache2/conf.d/$ipaddr.conf
         done
         done
     fi
     fi
-elif [ "$PROXY_SYSTEM" = "nginx" ]; then
+fi
+if [ "$PROXY_SYSTEM" = "nginx" ]; then
     echo "(*) Adding unassigned hosts configuration to nginx..."
     echo "(*) Adding unassigned hosts configuration to nginx..."
     if [ -f /usr/local/hestia/data/ips/* ]; then
     if [ -f /usr/local/hestia/data/ips/* ]; then
         for ip in /usr/local/hestia/data/ips/*; do
         for ip in /usr/local/hestia/data/ips/*; do

+ 3 - 3
web/edit/mail/index.php

@@ -244,7 +244,7 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['accou
 
 
     // Delete Lets Encrypt support
     // Delete Lets Encrypt support
     if (( $v_letsencrypt == 'yes' ) && (empty($_POST['v_letsencrypt'])) && (empty($_SESSION['error_msg']))) {
     if (( $v_letsencrypt == 'yes' ) && (empty($_POST['v_letsencrypt'])) && (empty($_SESSION['error_msg']))) {
-        exec (HESTIA_CMD."v-delete-letsencrypt-domain ".$user." ".$v_domain." 'no'", $output, $return_var);
+        exec (HESTIA_CMD."v-delete-letsencrypt-domain ".$user." ".$v_domain." 'no' 'yes'", $output, $return_var);
         check_return_code($return_var,$output);
         check_return_code($return_var,$output);
         unset($output);
         unset($output);
         $v_ssl_crt = '';
         $v_ssl_crt = '';
@@ -258,7 +258,7 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['accou
 
 
     // Delete SSL certificate
     // Delete SSL certificate
     if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
     if (( $v_ssl == 'yes' ) && (empty($_POST['v_ssl'])) && (empty($_SESSION['error_msg']))) {
-        exec (HESTIA_CMD."v-delete-domain-ssl ".$v_username." ".$v_domain." 'no' 'yes'", $output, $return_var);
+        exec (HESTIA_CMD."v-delete-mail-domain-ssl ".$v_username." ".$v_domain, $output, $return_var);
         check_return_code($return_var,$output);
         check_return_code($return_var,$output);
         unset($output);
         unset($output);
         $v_ssl_crt = '';
         $v_ssl_crt = '';
@@ -270,7 +270,7 @@ if ((!empty($_POST['save'])) && (!empty($_GET['domain'])) && (empty($_GET['accou
 
 
     // Add Lets Encrypt support
     // Add Lets Encrypt support
     if ((!empty($_POST['v_ssl'])) && ( $v_letsencrypt == 'no' ) && (!empty($_POST['v_letsencrypt'])) && empty($_SESSION['error_msg'])) {
     if ((!empty($_POST['v_ssl'])) && ( $v_letsencrypt == 'no' ) && (!empty($_POST['v_letsencrypt'])) && empty($_SESSION['error_msg'])) {
-        exec (HESTIA_CMD."v-add-letsencrypt-domain ".$user." ".$v_domain." '' 'yes'", $output, $return_var);
+        exec (HESTIA_CMD."v-add-letsencrypt-domain ".$user." ".$v_domain." ' ' 'yes'", $output, $return_var);
         check_return_code($return_var,$output);
         check_return_code($return_var,$output);
         unset($output);
         unset($output);
         $v_letsencrypt = 'yes';
         $v_letsencrypt = 'yes';