Browse Source

Merge branch 'main' into feature/user-roles

Kristan Kenney 5 years ago
parent
commit
2bfb9d7b6c
6 changed files with 105 additions and 119 deletions
  1. 14 4
      bin/v-repair-sys-config
  2. 3 2
      bin/v-search-command
  3. 20 8
      func/syshealth.sh
  4. 36 51
      install/hst-install-debian.sh
  5. 30 52
      install/hst-install-ubuntu.sh
  6. 2 2
      install/hst-install.sh

+ 14 - 4
bin/v-restore-sys-config → bin/v-repair-sys-config

@@ -3,11 +3,11 @@
 # options: [SYSTEM]
 # labels: 
 #
-# example: v-restore-sys-config
+# example: v-repair-sys-config
 #
-# The function restores system configuration file
+# The function repairs or restores the system configuration file.
 
-system=$1
+mode=$1
 
 # Includes
 # shellcheck source=/usr/local/hestia/func/main.sh
@@ -15,13 +15,23 @@ source $HESTIA/func/main.sh
 # shellcheck source=/usr/local/hestia/func/syshealth.sh
 source $HESTIA/func/syshealth.sh
 
+
 #----------------------------------------------------------#
 #                        Action                            #
 #----------------------------------------------------------#
 
-syshealth_restore_system_installed_config
+if [ "$mode" = "restore" ]; then
+    syshealth_restore_system_config
+fi
+
+if [ "$mode" = "repair" ]; then
+    # shellcheck source=/usr/local/hestia/conf/hestia.conf
+    source $HESTIA/conf/hestia.conf
+    syshealth_repair_system_config
+fi
 
 #----------------------------------------------------------#
 #                        Hestia                            #
 #----------------------------------------------------------#
+log_history "executed $mode operation on system configuration file." '' 'admin'
 log_event "$OK" "$ARGUMENTS"

+ 3 - 2
bin/v-search-command

@@ -35,11 +35,12 @@ check_hestia_demo_mode
 #                       Action                             #
 #----------------------------------------------------------#
 
-SearchPath=`ls -a $HESTIA/bin/ | sort`
+SearchResults=`ls -a $HESTIA/bin/ | sort`
 TotalItems=`ls -a $HESTIA/bin/ | sort | wc -l`
 
+
 for i; do
-    SearchResults=`echo $SearchPath | tr " " "\n" | grep $i`
+    SearchResults=`echo $SearchResults | tr " " "\n" | grep $i`
     FoundItems=`echo $SearchResults | tr " " "\n" | grep $i | wc -l`
 done
 

+ 20 - 8
func/syshealth.sh

@@ -147,7 +147,20 @@ function syshealth_repair_web_config() {
     done
 }
 
-function syshealth_restore_system_installed_config() {
+function syshealth_update_system_config_format() {
+    # SYSTEM CONFIGURATION
+    # Create array of known keys in configuration file
+    system="system"
+    known_keys=(ANTISPAM_SYSTEM ANTIVIRUS_SYSTEM API_ALLOWED_IP API BACKEND_PORT BACKUP_GZIP BACKUP_MODE BACKUP_SYSTEM CRON_SYSTEM DB_PMA_ALIAS DB_SYSTEM DISK_QUOTA DNS_SYSTEM ENFORCE_SUBDOMAIN_OWNERSHIP FILE_MANAGER FIREWALL_EXTENSION FIREWALL_SYSTEM FTP_SYSTEM IMAP_SYSTEM INACTIVE_SESSION_TIMEOUT LANGUAGE LOGIN_STYLE MAIL_SYSTEM PROXY_PORT PROXY_SSL_PORT PROXY_SYSTEM RELEASE_BRANCH STATS_SYSTEM THEME UPDATE_HOSTNAME_SSL UPGRADE_SEND_EMAIL UPGRADE_SEND_EMAIL_LOG WEB_BACKEND WEBMAIL_ALIAS WEBMAIL_SYSTEM WEB_PORT WEB_RGROUPS WEB_SSL WEB_SSL_PORT WEB_SYSTEM VERSION)
+    write_kv_config_file
+    unset system
+    unset known_keys
+}
+
+
+# Restore System Configuration
+# Replaces $HESTIA/conf/hestia.conf with "known good defaults" file ($HESTIA/conf/defaults/hestia.conf)
+function syshealth_restore_system_config() {
     if [ -f "$HESTIA/conf/defaults/hestia.conf" ]; then
         mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.old
         cp $HESTIA/conf/defaults/hestia.conf $HESTIA/conf/hestia.conf
@@ -179,14 +192,14 @@ function syshealth_repair_system_config() {
     if [ ! -z "$DB_SYSTEM" ]; then
         if [ "$DB_SYSTEM" = "mysql" ]; then
             if [ -z "$DB_PMA_ALIAS" ]; then 
-                echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpMyAdmin')"
-                $BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpMyAdmin'
+                echo "[ ! ] Adding missing variable to hestia.conf: DB_PMA_ALIAS ('phpmyadmin)"
+                $BIN/v-change-sys-config-value 'DB_PMA_ALIAS' 'phpmyadmin'
             fi
         fi
         if [ "$DB_SYSTEM" = "pgsql" ]; then
             if [ -z "$DB_PGA_ALIAS" ]; then 
-                echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phpPgAdmin')"
-                $BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phpPgAdmin'
+                echo "[ ! ] Adding missing variable to hestia.conf: DB_PGA_ALIAS ('phppgadmin')"
+                $BIN/v-change-sys-config-value 'DB_PGA_ALIAS' 'phppgadmin'
             fi
         fi
     fi
@@ -199,8 +212,8 @@ function syshealth_repair_system_config() {
 
     # Theme
     if [ -z "$THEME" ]; then 
-        echo "[ ! ] Adding missing variable to hestia.conf: THEME ('default')"
-        $BIN/v-change-sys-config-value 'THEME' 'default'
+        echo "[ ! ] Adding missing variable to hestia.conf: THEME ('dark')"
+        $BIN/v-change-sys-config-value 'THEME' 'dark'
     fi
 
     # Default language
@@ -242,7 +255,6 @@ function syshealth_repair_system_config() {
     # File Manager
     if [ -z "$FILE_MANAGER" ]; then
         echo "[ ! ] Adding missing variable to hestia.conf: FILE_MANAGER ('true')"
-        echo "[ ! ] File Manager is enabled but not installed, repairing components..."
         $BIN/v-add-sys-filemanager quiet
     fi
     

+ 36 - 51
install/hst-install-debian.sh

@@ -71,7 +71,6 @@ installer_dependencies="apt-transport-https curl dirmngr gnupg wget ca-certifica
 help() {
     echo "Usage: $0 [OPTIONS]
   -a, --apache            Install Apache        [yes|no]  default: yes
-  -n, --nginx             Install Nginx         [yes|no]  default: yes
   -w, --phpfpm            Install PHP-FPM       [yes|no]  default: yes
   -o, --multiphp          Install Multi-PHP     [yes|no]  default: no
   -v, --vsftpd            Install Vsftpd        [yes|no]  default: yes
@@ -182,7 +181,6 @@ for arg; do
     delim=""
     case "$arg" in
         --apache)               args="${args}-a " ;;
-        --nginx)                args="${args}-n " ;;
         --phpfpm)               args="${args}-w " ;;
         --vsftpd)               args="${args}-v " ;;
         --proftpd)              args="${args}-j " ;;
@@ -214,10 +212,9 @@ done
 eval set -- "$args"
 
 # Parsing arguments
-while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
+while getopts "a:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
     case $Option in
         a) apache=$OPTARG ;;            # Apache
-        n) nginx=$OPTARG ;;             # Nginx
         w) phpfpm=$OPTARG ;;            # PHP-FPM
         o) multiphp=$OPTARG ;;          # Multi-PHP
         v) vsftpd=$OPTARG ;;            # Vsftpd
@@ -453,9 +450,9 @@ clear
 install_welcome_message
 
 # Web stack
-if [ "$nginx" = 'yes' ]; then
-    echo '   - NGINX Web / Proxy Server'
-fi
+
+echo '   - NGINX Web / Proxy Server'
+
 if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
     echo '   - Apache Web Server'
 fi
@@ -605,11 +602,10 @@ echo "Adding required repositories to proceed with installation:"
 echo
 
 # Installing Nginx repo
-if [ "$nginx" = 'yes' ]; then
-    echo "[ * ] NGINX"
-    echo "deb [arch=amd64] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
-    apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1
-fi
+echo "[ * ] NGINX"
+echo "deb [arch=amd64] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
+apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1
+
 
 # Installing sury PHP repo
 echo "[ * ] PHP"
@@ -752,9 +748,7 @@ fi
 
 # Excluding packages
 software=$(echo "$software" | sed -e "s/apache2.2-common//")
-if [ "$nginx" = 'no'  ]; then
-    software=$(echo "$software" | sed -r -e 's/(\s|^)nginx(\s|$)/ /')
-fi
+
 if [ "$apache" = 'no' ]; then
     software=$(echo "$software" | sed -e "s/apache2 //")
     software=$(echo "$software" | sed -e "s/apache2-bin//")
@@ -1000,15 +994,7 @@ touch $HESTIA/conf/hestia.conf
 chmod 660 $HESTIA/conf/hestia.conf
 
 # Web stack
-if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
-    write_config_value "WEB_SYSTEM" "apache2"
-    write_config_value "WEB_RGROUPS" "www-data"
-    write_config_value "WEB_PORT" "80"
-    write_config_value "WEB_SSL_PORT" "443"
-    write_config_value "WEB_SSL" "mod_ssl"
-    write_config_value "STATS_SYSTEM" "awstats"
-fi
-if [ "$apache" = 'yes' ] && [ "$nginx"  = 'yes' ] ; then
+if [ "$apache" = 'yes' ]; then
     write_config_value "WEB_SYSTEM" "apache2"
     write_config_value "WEB_RGROUPS" "www-data"
     write_config_value "WEB_PORT" "8080"
@@ -1019,12 +1005,13 @@ if [ "$apache" = 'yes' ] && [ "$nginx"  = 'yes' ] ; then
     write_config_value "PROXY_SSL_PORT" "443"
     write_config_value "STATS_SYSTEM" "awstats"
 fi
-if [ "$apache" = 'no' ] && [ "$nginx"  = 'yes' ]; then
+if [ "$apache" = 'no' ]; then
     write_config_value "WEB_SYSTEM" "nginx"
     write_config_value "WEB_PORT" "80"
     write_config_value "WEB_SSL_PORT" "443"
     write_config_value "WEB_SSL" "openssl"
     write_config_value "STATS_SYSTEM" "awstats"
+
 fi
 
 if [ "$release" -ge 9 ] || [ "$multiphp" = 'yes' ]; then
@@ -1180,35 +1167,33 @@ cp -f $HESTIA_INSTALL_DIR/ssl/dhparam.pem /etc/ssl
 #                     Configure Nginx                      #
 #----------------------------------------------------------#
 
-if [ "$nginx" = 'yes' ]; then
-    echo "[ * ] Configuring NGINX..."
-    rm -f /etc/nginx/conf.d/*.conf
-    cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
-    cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
-    cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
-    cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
-    cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
-    mkdir -p /etc/nginx/conf.d/domains
-    mkdir -p /etc/nginx/modules-enabled
-    mkdir -p /var/log/nginx/domains
-
-    # Update dns servers in nginx.conf
-    dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
-    for ip in $dns_resolver; do
-        if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
-            resolver="$ip $resolver"
-        fi
-    done
-    if [ ! -z "$resolver" ]; then
-        sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
-        sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
+echo "[ * ] Configuring NGINX..."
+rm -f /etc/nginx/conf.d/*.conf
+cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
+cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
+cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
+cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
+cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
+mkdir -p /etc/nginx/conf.d/domains
+mkdir -p /etc/nginx/modules-enabled
+mkdir -p /var/log/nginx/domains
+
+# Update dns servers in nginx.conf
+dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
+for ip in $dns_resolver; do
+    if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+        resolver="$ip $resolver"
     fi
-
-    update-rc.d nginx defaults > /dev/null 2>&1
-    systemctl start nginx >> $LOG
-    check_result $? "nginx start failed"
+done
+if [ ! -z "$resolver" ]; then
+    sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
+    sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
 fi
 
+update-rc.d nginx defaults > /dev/null 2>&1
+systemctl start nginx >> $LOG
+check_result $? "nginx start failed"
+
 
 #----------------------------------------------------------#
 #                    Configure Apache                      #

+ 30 - 52
install/hst-install-ubuntu.sh

@@ -52,7 +52,6 @@ installer_dependencies="apt-transport-https curl dirmngr gnupg wget software-pro
 help() {
     echo "Usage: $0 [OPTIONS]
   -a, --apache            Install Apache        [yes|no]  default: yes
-  -n, --nginx             Install Nginx         [yes|no]  default: yes
   -w, --phpfpm            Install PHP-FPM       [yes|no]  default: yes
   -o, --multiphp          Install Multi-PHP     [yes|no]  default: no
   -v, --vsftpd            Install Vsftpd        [yes|no]  default: yes
@@ -163,7 +162,6 @@ for arg; do
     delim=""
     case "$arg" in
         --apache)               args="${args}-a " ;;
-        --nginx)                args="${args}-n " ;;
         --phpfpm)               args="${args}-w " ;;
         --vsftpd)               args="${args}-v " ;;
         --proftpd)              args="${args}-j " ;;
@@ -195,10 +193,9 @@ done
 eval set -- "$args"
 
 # Parsing arguments
-while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
+while getopts "a:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
     case $Option in
         a) apache=$OPTARG ;;            # Apache
-        n) nginx=$OPTARG ;;             # Nginx
         w) phpfpm=$OPTARG ;;            # PHP-FPM
         o) multiphp=$OPTARG ;;          # Multi-PHP
         v) vsftpd=$OPTARG ;;            # Vsftpd
@@ -427,9 +424,7 @@ clear
 install_welcome_message
 
 # Web stack
-if [ "$nginx" = 'yes' ]; then
-    echo '   - NGINX Web / Proxy Server'
-fi
+echo '   - NGINX Web / Proxy Server'
 if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
     echo '   - Apache Web Server'
 fi
@@ -579,11 +574,9 @@ echo "Adding required repositories to proceed with installation:"
 echo
 
 # Installing Nginx repo
-if [ "$nginx" = 'yes' ]; then
-    echo "[ * ] NGINX"
-    echo "deb [arch=amd64] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
-    apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1
-fi
+echo "[ * ] NGINX"
+echo "deb [arch=amd64] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
+apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1    
 
 # Installing sury PHP repo
 echo "[ * ] PHP"
@@ -724,10 +717,7 @@ fi
 
 # Excluding packages
 software=$(echo "$software" | sed -e "s/apache2.2-common//")
-if [ "$nginx" = 'no'  ]; then
-    software=$(echo "$software" | sed -r -e 's/(\s|^)nginx(\s|$)/ /')
 
-fi
 if [ "$apache" = 'no' ]; then
     software=$(echo "$software" | sed -e "s/apache2 //")
     software=$(echo "$software" | sed -e "s/apache2-bin//")
@@ -1039,16 +1029,7 @@ touch $HESTIA/conf/hestia.conf
 chmod 660 $HESTIA/conf/hestia.conf
 
 # Web stack
-if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
-    write_config_value "WEB_SYSTEM" "apache2"
-    write_config_value "WEB_RGROUPS" "www-data"
-    write_config_value "WEB_PORT" "80"
-    write_config_value "WEB_SSL_PORT" "443"
-    write_config_value "WEB_SSL" "mod_ssl"
-    write_config_value "STATS_SYSTEM" "awstats"
-fi
-
-if [ "$apache" = 'yes' ] && [ "$nginx"  = 'yes' ] ; then
+if [ "$apache" = 'yes' ]; then
     write_config_value "WEB_SYSTEM" "apache2"
     write_config_value "WEB_RGROUPS" "www-data"
     write_config_value "WEB_PORT" "8080"
@@ -1060,7 +1041,7 @@ if [ "$apache" = 'yes' ] && [ "$nginx"  = 'yes' ] ; then
     write_config_value "STATS_SYSTEM" "awstats"
 fi
 
-if [ "$apache" = 'no' ] && [ "$nginx"  = 'yes' ]; then
+if [ "$apache" = 'no' ]; then
     write_config_value "WEB_SYSTEM" "nginx"
     write_config_value "WEB_PORT" "80"
     write_config_value "WEB_SSL_PORT" "443"
@@ -1221,35 +1202,32 @@ cp -f $HESTIA_INSTALL_DIR/ssl/dhparam.pem /etc/ssl
 #                     Configure Nginx                      #
 #----------------------------------------------------------#
 
-if [ "$nginx" = 'yes' ]; then
-    echo "[ * ] Configuring NGINX..."
-    rm -f /etc/nginx/conf.d/*.conf
-    cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
-    cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
-    cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
-    cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
-    cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
-    mkdir -p /etc/nginx/conf.d/domains
-    mkdir -p /etc/nginx/modules-enabled
-    mkdir -p /var/log/nginx/domains
-
-    # Update dns servers in nginx.conf
-    dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
-    for ip in $dns_resolver; do
-        if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
-            resolver="$ip $resolver"
-        fi
-    done
-    if [ ! -z "$resolver" ]; then
-        sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
-        sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
+echo "[ * ] Configuring NGINX..."
+rm -f /etc/nginx/conf.d/*.conf
+cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
+cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
+cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
+cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
+cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
+mkdir -p /etc/nginx/conf.d/domains
+mkdir -p /etc/nginx/modules-enabled
+mkdir -p /var/log/nginx/domains
+
+# Update dns servers in nginx.conf
+dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
+for ip in $dns_resolver; do
+    if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+        resolver="$ip $resolver"
     fi
-
-    update-rc.d nginx defaults > /dev/null 2>&1
-    systemctl start nginx >> $LOG
-    check_result $? "nginx start failed"
+done
+if [ ! -z "$resolver" ]; then
+    sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
+    sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
 fi
 
+update-rc.d nginx defaults > /dev/null 2>&1
+systemctl start nginx >> $LOG
+check_result $? "nginx start failed"
 
 #----------------------------------------------------------#
 #                    Configure Apache                      #

+ 2 - 2
install/hst-install.sh

@@ -6,7 +6,7 @@
 # Currently Supported Operating Systems:
 #
 #   Debian 9, 10
-#   Ubuntu 16.04, 18.04, 20.04
+#   Ubuntu 18.04, 20.04
 #
 
 # Am I root?
@@ -99,7 +99,7 @@ check_wget_curl(){
 
 # Check for supported operating system before proceeding with download
 # of OS-specific installer, and throw error message if unsupported OS detected.
-if [[ "$release" =~ ^(9|10|16.04|18.04|20.04)$ ]]; then
+if [[ "$release" =~ ^(9|10|18.04|20.04)$ ]]; then
     check_wget_curl $*
 else
     no_support_message