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

Merge pull request #314 from Lupul/Bugfix-0514-installer

Fix: Configure unassigned web page after adding IP address to Hestia
Fix: memory stats on v-list-sys-services
Fix: Move webserver config for unassigned domains to v-add-sys-ip from upgrade script
Fix: Upgrade script will create webserver configs for unassigned domains  …
Kristan Kenney 6 лет назад
Родитель
Сommit
d7cc12647f

+ 10 - 2
bin/v-add-sys-ip

@@ -130,13 +130,21 @@ if [ ! -z "$WEB_SYSTEM" ]; then
             echo "NameVirtualHost $ip:$WEB_PORT" >  $web_conf
         fi
         echo "Listen $ip:$WEB_PORT" >> $web_conf
+        cat $HESTIA/install/deb/apache2/unassigned.conf >> $web_conf
+        sed -i 's/directIP/'$ip'/g' $web_conf
+        sed -i 's/directPORT/'$WEB_PORT'/g' $web_conf
+
+    elif [ "$WEB_SYSTEM" = 'nginx' ]; then
+        cp -f $HESTIA/install/deb/nginx/unassigned.inc $web_conf
+        sed -i 's/directIP/'$ip'/g' $web_conf
     fi
 
     if [ "$WEB_SSL" = 'mod_ssl' ]; then
         if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
-            echo "NameVirtualHost $ip:$WEB_SSL_PORT" >> $web_conf
+            sed -i "1s/^/NameVirtualHost $ip:$WEB_SSL_PORT\n/" $web_conf
         fi
-        echo "Listen $ip:$WEB_SSL_PORT" >> $web_conf
+        sed -i "1s/^/Listen $ip:$WEB_SSL_PORT\n/" $web_conf
+        sed -i 's/directSSLPORT/'$WEB_SSL_PORT'/g' $web_conf
     fi
 fi
 

+ 4 - 0
bin/v-list-sys-services

@@ -78,6 +78,9 @@ get_srv_state() {
     srv=$1
     name=${2-$1}
     state='running'
+    mem=0
+    cpu=0
+    rtime="0"
 
     # Searching related pids
     if [ -z $3 ]; then
@@ -92,6 +95,7 @@ get_srv_state() {
     # Checking pid
     if [ ! -z "$pids" ]; then
         pid=$(echo "$pids" |cut -f 1 -d '|')
+        pids=${pids%|}
         pids=$(egrep "$pids" $tmp_file)
 
         # Calculating CPU usage

+ 3 - 6
install/deb/apache2/unassigned.conf

@@ -1,16 +1,13 @@
-Listen directIP:8080
-Listen directIP:8443
-
-<VirtualHost directIP:80>
+<VirtualHost directIP:directPORT>
   
     DocumentRoot /var/www/html/
     Alias /error/ /var/www/document_errors/
 
 </VirtualHost>
 
-<VirtualHost directIP:443>
+<VirtualHost directIP:directSSLPORT>
   
     DocumentRoot /var/www/html/
     Alias /error/ /var/www/document_errors/
 
-</VirtualHost>
+</VirtualHost>

+ 6 - 20
install/hst-install-debian.sh

@@ -1147,14 +1147,6 @@ if [ "$nginx" = 'yes' ]; then
         check_result $? "php$fpm_v-fpm start failed"
     fi
 
-    # Redirect unassigned hosts to default "Success" page
-    for ip in /usr/local/hestia/data/ips/*; do
-        ipaddr=${ip##*/}
-        rm -f /etc/nginx/conf.d/$ip.conf
-        cp -f $HESTIA/install/deb/nginx/unassigned.inc /etc/nginx/conf.d/$ipaddr.conf
-        sed -i 's/directIP/'$ipaddr'/g' /etc/nginx/conf.d/$ipaddr.conf
-    done
-
     # Install dhparam.
     cp -f $HESTIA/install/deb/ssl/dhparam.pem /etc/ssl
 
@@ -1209,14 +1201,6 @@ if [ "$apache" = 'yes' ]; then
         fi
     fi
 
-    # Add unassigned hosts configuration to apache2
-    for ip in /usr/local/hestia/data/ips/*; do
-        ipaddr=${ip##*/}
-        rm -f /etc/apache2/conf.d/$ip.conf
-        cp -f $HESTIA/install/deb/apache2/unassigned.conf /etc/apache2/conf.d/$ipaddr.conf
-        sed -i 's/directIP/'$ipaddr'/g' /etc/apache2/conf.d/$ipaddr.conf
-    done
-
     update-rc.d apache2 defaults > /dev/null 2>&1
     service apache2 start >> $LOG
     check_result $? "apache2 start failed"
@@ -1803,11 +1787,13 @@ cat $tmpfile
 rm -f $tmpfile
 
 echo "(!) IMPORTANT: You must logout or restart the server before continuing."
-echo -n " Do you want to logout now? [Y/N] "
-read resetshell
+if [ "$interactive" = 'yes' ]; then
+    echo -n " Do you want to logout now? [Y/N] "
+    read resetshell
 
-if [ "$resetshell" = "Y" ] || [ "$resetshell" = "y" ]; then
-    logout
+    if [ "$resetshell" = "Y" ] || [ "$resetshell" = "y" ]; then
+        logout
+    fi
 fi
 
 # EOF

+ 6 - 20
install/hst-install-ubuntu.sh

@@ -1115,14 +1115,6 @@ if [ "$nginx" = 'yes' ]; then
         check_result $? "php$fpm_v-fpm start failed"
     fi
 
-    # Redirect unassigned hosts to default "Success" page
-    for ip in /usr/local/hestia/data/ips/*; do
-        ipaddr=${ip##*/}
-        rm -f /etc/nginx/conf.d/$ip.conf
-        cp -f $HESTIA/install/deb/nginx/unassigned.inc /etc/nginx/conf.d/$ipaddr.conf
-        sed -i 's/directIP/'$ipaddr'/g' /etc/nginx/conf.d/$ipaddr.conf
-    done
-
     # Install dhparam.
     cp -f $HESTIA/install/deb/ssl/dhparam.pem /etc/ssl
 
@@ -1173,14 +1165,6 @@ if [ "$apache" = 'yes' ]; then
         chmod a+x $HESTIA/data/templates/web/apache2/*.sh
     fi
 
-    # Add unassigned hosts configuration to apache2
-    for ip in /usr/local/hestia/data/ips/*; do
-        ipaddr=${ip##*/}
-        rm -f /etc/apache2/conf.d/$ip.conf
-        cp -f $HESTIA/install/deb/apache2/unassigned.conf /etc/apache2/conf.d/$ipaddr.conf
-        sed -i 's/directIP/'$ipaddr'/g' /etc/apache2/conf.d/$ipaddr.conf
-    done
-
     update-rc.d apache2 defaults > /dev/null 2>&1
     service apache2 start >> $LOG
     check_result $? "apache2 start failed"
@@ -1710,11 +1694,13 @@ cat $tmpfile
 rm -f $tmpfile
 
 echo "(!) IMPORTANT: You must logout or restart the server before continuing."
-echo -n " Do you want to logout now? [Y/N] "
-read resetshell
+if [ "$interactive" = 'yes' ]; then
+    echo -n " Do you want to logout now? [Y/N] "
+    read resetshell
 
-if [ "$resetshell" = "Y" ] || [ "$resetshell" = "y" ]; then
-    logout
+    if [ "$resetshell" = "Y" ] || [ "$resetshell" = "y" ]; then
+        logout
+    fi
 fi
 
 # EOF

+ 39 - 18
install/upgrade/0.10.0-190430.sh

@@ -175,24 +175,45 @@ if [ -d "/etc/roundcube" ]; then
 fi
 
 # Add unassigned hosts configuration to Nginx and Apache
-if [ "$WEB_SYSTEM" = "apache2" ]; then
-    echo "(*) Adding unassigned hosts configuration to Apache..."
-    for ip in /usr/local/hestia/data/ips/*; do
-        ipaddr=${ip##*/}
-        rm -f /etc/apache2/conf.d/$ip.conf
-        cp -f $HESTIA/install/deb/apache2/unassigned.conf /etc/apache2/conf.d/$ipaddr.conf
-        sed -i 's/directIP/'$ipaddr'/g' /etc/apache2/conf.d/$ipaddr.conf
-    done
-fi
-if [ "$PROXY_SYSTEM" = "nginx" ]; then
-    echo "(*) Adding unassigned hosts configuration to Nginx..."
-    for ip in /usr/local/hestia/data/ips/*; do
-        ipaddr=${ip##*/}
-        rm -f /etc/nginx/conf.d/$ip.conf
-        cp -f $HESTIA/install/deb/nginx/unassigned.inc /etc/nginx/conf.d/$ipaddr.conf
-        sed -i 's/directIP/'$ipaddr'/g' /etc/nginx/conf.d/$ipaddr.conf
-    done
-fi
+for ipaddr in $(ls /usr/local/hestia/data/ips/ 2>/dev/null); do
+
+    web_conf="/etc/$WEB_SYSTEM/conf.d/$ipaddr.conf"
+    rm -f $web_conf
+
+    if [ "$WEB_SYSTEM" = "apache2" ]; then
+        echo "(*) Adding unassigned hosts configuration to Apache..."
+        if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
+            echo "NameVirtualHost $ipaddr:$WEB_PORT" >  $web_conf
+        fi
+        echo "Listen $ipaddr:$WEB_PORT" >> $web_conf
+        cat $HESTIA/install/deb/apache2/unassigned.conf >> $web_conf
+        sed -i 's/directIP/'$ipaddr'/g' $web_conf
+        sed -i 's/directPORT/'$WEB_PORT'/g' $web_conf
+
+        if [ "$WEB_SSL" = 'mod_ssl' ]; then
+            if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then
+                sed -i "1s/^/NameVirtualHost $ipaddr:$WEB_SSL_PORT\n/" $web_conf
+            fi
+            sed -i "1s/^/Listen $ipaddr:$WEB_SSL_PORT\n/" $web_conf
+            sed -i 's/directSSLPORT/'$WEB_SSL_PORT'/g' $web_conf
+        fi
+    
+    elif [ "$WEB_SYSTEM" = "nginx" ]; then
+        cp -f $HESTIA/install/deb/nginx/unassigned.inc $web_conf
+        sed -i 's/directIP/'$ipaddr'/g' $web_conf
+    fi
+
+    if [ "$PROXY_SYSTEM" = "nginx" ]; then
+        echo "(*) Adding unassigned hosts configuration to Nginx..."
+        cat $WEBTPL/$PROXY_SYSTEM/proxy_ip.tpl |\
+        sed -e "s/%ip%/$ipaddr/g" \
+            -e "s/%web_port%/$WEB_PORT/g" \
+            -e "s/%proxy_port%/$PROXY_PORT/g" \
+        > /etc/$PROXY_SYSTEM/conf.d/$ipaddr.conf
+    fi
+done
+
+
 
 # Fix empty pool error message for MultiPHP
 php_versions=$(ls /etc/php/*/fpm -d 2>/dev/null |wc -l)