Просмотр исходного кода

Merge pull request #594 from Lupul/dev-0926

Dev 0926
Zollner Robert 6 лет назад
Родитель
Сommit
6b4ee799e7

+ 6 - 5
bin/v-add-letsencrypt-domain

@@ -53,11 +53,6 @@ query_le_v2() {
     curl -s -i -d "$post_data" "$1" -H "$content"
 }
 
-# Set DNS CAA record retrieval commands
-if [ ! -z "$DNS_SYSTEM" ]; then
-    dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
-    caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "CAA" | cut -d' ' -f1)
-fi
 
 #----------------------------------------------------------#
 #                    Verifications                         #
@@ -71,6 +66,12 @@ if [ ! -z "$mail" ]; then
     is_boolean_format_valid "$mail" 'mail'
 fi
 
+# Set DNS CAA record retrieval commands
+if [ ! -z "$DNS_SYSTEM" ]; then
+    dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
+    caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "CAA" | cut -d' ' -f1)
+fi
+
 if [ -z "$mail" ] || [ "$mail" = 'no' ]; then
     mail=''
     is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'

+ 11 - 10
bin/v-restart-mail

@@ -15,14 +15,13 @@ source $HESTIA/conf/hestia.conf
 PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
+    local mail_service="$1"
+    journalctl --no-pager --reverse --since=-1m --unit "$mail_service" >> "$tmpfile" 2>&1
     email=$(grep CONTACT $HESTIA/data/users/admin/user.conf)
     email=$(echo "$email" | cut -f 2 -d "'")
-    tmpfile=$(mktemp)
-    subj="$(hostname): $MAIL_SYSTEM restart failed"
-    service $MAIL_SYSTEM configtest >> $tmpfile 2>&1
-    service $MAIL_SYSTEM restart >> $tmpfile 2>&1
-    cat $tmpfile |$SENDMAIL -s "$subj" $email
-    rm -f $tmpfile
+    subj="$(hostname): $mail_service restart failed"
+    cat "$tmpfile" |$SENDMAIL -s "$subj" $email
+    [[ -f "$tmpfile" ]] && rm -f $tmpfile
 }
 
 
@@ -46,19 +45,20 @@ if [ -z "$MAIL_SYSTEM" ] || [ "$MAIL_SYSTEM" = 'remote' ]; then
     exit
 fi
 
+tmpfile=$(mktemp)
 # Restart IMAP system if present
 if [ ! -z "$IMAP_SYSTEM" ]; then
-    $BIN/v-restart-service $IMAP_SYSTEM > /dev/null 2>&1
+    $BIN/v-restart-service $IMAP_SYSTEM >> $tmpfile 2>&1
     if [ $? -ne 0 ]; then
-        send_email_report
+        send_email_report "$IMAP_SYSTEM"
         check_result $E_RESTART "$IMAP_SYSTEM restart failed"
     fi
 fi
 
 # Restart mail system
-$BIN/v-restart-service $MAIL_SYSTEM > /dev/null 2>&1
+$BIN/v-restart-service $MAIL_SYSTEM >> $tmpfile 2>&1
 if [ $? -ne 0 ]; then
-    send_email_report
+    send_email_report "$MAIL_SYSTEM"
     check_result $E_RESTART "$MAIL_SYSTEM restart failed"
 fi
 
@@ -72,4 +72,5 @@ fi
 #                       Hestia                             #
 #----------------------------------------------------------#
 
+[[ -f "$tmpfile" ]] && rm -f $tmpfile
 exit

+ 18 - 16
bin/v-restart-web-backend

@@ -17,12 +17,9 @@ PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 send_email_report() {
     email=$(grep CONTACT $HESTIA/data/users/admin/user.conf)
     email=$(echo "$email" | cut -f 2 -d "'")
-    tmpfile=$(mktemp)
     subj="$(hostname): $WEB_BACKEND restart failed"
-    service $WEB_BACKEND configtest >> $tmpfile 2>&1
-    service $WEB_BACKEND restart >> $tmpfile 2>&1
     cat $tmpfile |$SENDMAIL -s "$subj" $email
-    rm -f $tmpfile
+    [[ -f "$tmpfile" ]] && rm -f $tmpfile
 }
 
 
@@ -46,20 +43,24 @@ if [ -z "$WEB_BACKEND" ] || [ "$WEB_BACKEND" = 'remote' ]; then
     exit
 fi
 
-# Restart system
-php_fpm=$(ls /etc/init.d/php*-fpm* 2>/dev/null |cut -f 4 -d /)
-for back in $php_fpm
-do
-    if [ -z "$php_fpm" ]; then
-        $BIN/v-restart-service $WEB_BACKEND > /dev/null 2>&1
-    else
-        $BIN/v-restart-service $back > /dev/null 2>&1
+tmpfile=$(mktemp)
+for php_folder in /etc/php/*; do
+    [ ! -d "${php_folder}/fpm/pool.d/" ] && continue
+
+    v_php="$(basename $php_folder)"
+    v_phpfpm="php${v_php}-fpm"
+
+    if [ ! -f "/etc/php/${v_php}/fpm/pool.d/dummy.conf" ]; then
+        cp -f "$HESTIA_INSTALL_DIR/php-fpm/dummy.conf" "/etc/php/${v_php}/fpm/pool.d/"
+        sed -i "s/9999/99${v_php//.}/g" "/etc/php/${v_php}/fpm/pool.d/dummy.conf"
+    fi
+
+    $BIN/v-restart-service "$v_phpfpm" >> $tmpfile 2>&1
+    if [ $? -ne 0 ]; then
+        send_email_report
+        check_result $E_RESTART "$v_phpfpm restart failed"
     fi
 done
-if [ $? -ne 0 ]; then
-    send_email_report
-    check_result $E_RESTART "$WEB_BACKEND restart failed"
-fi
 
 # Update restart queue
 if [ -e "$HESTIA/data/queue/restart.pipe" ]; then
@@ -71,4 +72,5 @@ fi
 #                       Hestia                             #
 #----------------------------------------------------------#
 
+[[ -f "$tmpfile" ]] && rm -f $tmpfile
 exit

+ 2 - 0
install/deb/php-fpm/dummy.conf

@@ -1,3 +1,5 @@
+; origin-src: deb/php-fpm/dummy.conf
+
 [www]
 listen = 127.0.0.1:9999
 listen.allowed_clients = 127.0.0.1

+ 3 - 2
install/deb/php-fpm/multiphp.tpl

@@ -1,5 +1,6 @@
-[%domain%]
+; origin-src: deb/php-fpm/multiphp.tpl
 
+[%domain%]
 listen = /run/php/php%backend_version%-fpm-%domain%.sock
 listen.owner = %user%
 listen.group = www-data
@@ -17,7 +18,7 @@ pm.status_path = /status
 php_admin_value[upload_tmp_dir] = /home/%user%/tmp
 php_admin_value[session.save_path] = /home/%user%/tmp
 php_admin_value[open_basedir] = /home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp:/usr/share:/etc/phpMyAdmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/roundcubemail
-php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f info@%domain%\"
+php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f admin@%domain%\"
 
 env[PATH] = /usr/local/bin:/usr/bin:/bin
 env[TMP] = /home/%user%/tmp

+ 2 - 0
install/deb/php-fpm/www.conf

@@ -1,3 +1,5 @@
+; origin-src: deb/php-fpm/www.conf
+
 [www]
 listen = 127.0.0.1:9000
 listen.allowed_clients = 127.0.0.1

+ 4 - 1
install/deb/templates/web/php-fpm/default.tpl

@@ -1,5 +1,6 @@
-[%backend%]
+; origin-src: deb/templates/web/php-fpm/default.tpl
 
+[%backend%]
 listen = /run/php/php%backend_version%-fpm-%domain%.sock
 listen.owner = %user%
 listen.group = www-data
@@ -16,6 +17,8 @@ pm.status_path = /status
 
 php_admin_value[upload_tmp_dir] = /home/%user%/tmp
 php_admin_value[session.save_path] = /home/%user%/tmp
+php_admin_value[open_basedir] = /home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp:/usr/share:/etc/phpMyAdmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/roundcubemail
+php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f admin@%domain%\"
 
 env[HOSTNAME] = $HOSTNAME
 env[PATH] = /usr/local/bin:/usr/bin:/bin

+ 7 - 4
install/deb/templates/web/php-fpm/socket.tpl

@@ -1,13 +1,14 @@
+; origin-src: deb/templates/web/php-fpm/socket.tpl
+
 [%backend%]
 listen = /var/run/php/%backend%.sock
-listen.allowed_clients = 127.0.0.1
+listen.owner = %user%
+listen.group = www-data
+listen.mode = 0660
 
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = www-data
-
 pm = ondemand
 pm.max_children = 8
 pm.max_requests = 4000
@@ -16,6 +17,8 @@ pm.status_path = /status
 
 php_admin_value[upload_tmp_dir] = /home/%user%/tmp
 php_admin_value[session.save_path] = /home/%user%/tmp
+php_admin_value[open_basedir] = /home/%user%/web/%domain%/public_html:/home/%user%/web/%domain%/public_shtml:/home/%user%/tmp:/bin:/usr/bin:/usr/local/bin:/var/www/html:/tmp:/usr/share:/etc/phpMyAdmin:/etc/phpmyadmin:/var/lib/phpmyadmin:/etc/roundcubemail
+php_admin_value[sendmail_path] = \"/usr/sbin/sendmail -t -i -f admin@%domain%\"
 
 env[HOSTNAME] = $HOSTNAME
 env[PATH] = /usr/local/bin:/usr/bin:/bin