Ernesto Nicolás Carrea 5 lat temu
rodzic
commit
2cf7a03b1d

+ 2 - 2
bin/module/apache/install.inc

@@ -53,8 +53,8 @@ hestia_module_apache_install() {
         osal_apache_module_enable status > /dev/null 2>&1
 
         # Delete CentOS style apache logs if present (Hestia will use error.log and access.log)
-        [ -f /var/log/$OSAL_PKG_APACHE/access_log ] && rm /var/log/$OSAL_PKG_APACHE/access_log
-        [ -f /var/log/$OSAL_PKG_APACHE/error_log ] && rm /var/log/$OSAL_PKG_APACHE/error_log
+        [ -f /var/log/$OSAL_PKG_APACHE/access_log ] && hestia_safe_rm /var/log/$OSAL_PKG_APACHE/access_log
+        [ -f /var/log/$OSAL_PKG_APACHE/error_log ] && hestia_safe_rm /var/log/$OSAL_PKG_APACHE/error_log
 
         # Mitigation for some Debian-only scripts
         ln -s /etc/httpd/conf.modules.d/ /etc/httpd/mods-enabled

+ 1 - 1
bin/module/awstats/install.inc

@@ -17,7 +17,7 @@ hestia_module_awstats_install() {
     osal_package_install $OSAL_PKG_AWSTATS
 
     # Disable AWStats cron
-    rm -f /etc/cron.d/awstats
+    hestia_safe_rm /etc/cron.d/awstats
 
     osal_kv_write $HESTIA/conf/hestia.conf 'STATS_SYSTEM' 'awstats'
     osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'installed' '1'

+ 1 - 1
bin/module/awstats/remove.inc

@@ -18,7 +18,7 @@ hestia_module_awstats_remove() {
 
     hestia_config_backup 'awstats-remove' $OSAL_PATH_AWSTATS_CONF
     osal_package_remove $OSAL_PKG_AWSTATS
-    rm -rf $OSAL_PATH_AWSTATS_CONF
+    hestia_safe_rm $OSAL_PATH_AWSTATS_CONF
 
     osal_kv_write $HESTIA/conf/hestia.conf 'WEBSTATS_SYSTEM' ''
     osal_kv_write $HESTIA_CONF_MODULES/webstats.conf 'installed' '0'

+ 1 - 1
bin/module/clamav/remove.inc

@@ -25,7 +25,7 @@ hestia_module_clamav_remove() {
 
     hestia_config_backup 'clamav-remove' $OSAL_PATH_CLAMAV_CONF $OSAL_PATH_CLAMAV_CONF_D
 
-    rm -rf $OSAL_PATH_CLAMAV_CONF $OSAL_PATH_CLAMAV_CONF_D
+    hestia_safe_rm $OSAL_PATH_CLAMAV_CONF $OSAL_PATH_CLAMAV_CONF_D
 
     osal_package_remove $OSAL_PKG_CLAMAV
 

+ 1 - 1
bin/module/dovecot/install.inc

@@ -22,7 +22,7 @@ hestia_module_dovecot_install() {
     chown -R root:root $OSAL_PATH_DOVECOT_CONF
     
     # Why do we do this?
-    rm -f /etc/dovecot/conf.d/15-mailboxes.conf
+    hestia_safe_rm /etc/dovecot/conf.d/15-mailboxes.conf
 
     osal_service_enable $OSAL_SERVICE_DOVECOT
     osal_service_start $OSAL_SERVICE_DOVECOT

+ 1 - 1
bin/module/dovecot/remove.inc

@@ -20,7 +20,7 @@ hestia_module_dovecot_remove() {
     osal_service_disable $OSAL_SERVICE_DOVECOT > /dev/null 2>&1
 
     hestia_config_backup 'dovecot-remove' $OSAL_PATH_DOVECOT_CONF
-    rm -rf $OSAL_PATH_DOVECOT_CONF
+    hestia_safe_rm $OSAL_PATH_DOVECOT_CONF
 
     osal_package_remove $OSAL_PKG_DOVECOT
 

+ 2 - 2
bin/module/exim/install.inc

@@ -26,10 +26,10 @@ hestia_module_exim_install() {
     touch $OSAL_DIR_EXIM_CONF/white-blocks.conf
     touch $OSAL_DIR_EXIM_CONF/mailhelo.conf
 
-    rm -rf $OSAL_DIR_EXIM_CONF/domains
+    hestia_safe_rm $OSAL_DIR_EXIM_CONF/domains
     mkdir -p $OSAL_DIR_EXIM_CONF/domains
 
-    rm -f /etc/alternatives/mta
+    hestia_safe_rm /etc/alternatives/mta
     ln -s /usr/sbin/$OSAL_SERVICE_EXIM /etc/alternatives/mta
     
     osal_service_stop sendmail > /dev/nul 2>&1

+ 11 - 1
bin/module/func.inc

@@ -58,5 +58,15 @@ hestia_config_backup() {
     shift
 
     mkdir -p $dest
-    tar -zc --warning=none --ignore-failed-read -f $dest/${filename}.tar.gz $@ > /dev/null 2>&1
+    [ "$HESTIA_DEBUG" ] && >&2 echo tarring -f $dest/${filename}.tar.gz $@
+    tar -zc --ignore-failed-read -f $dest/${filename}.tar.gz $@ > /dev/null 2>&1
 }
+
+hestia_safe_rm() {
+    for file in "$@"; do
+        if [[ $file =~ ^/etc/.*|^/var/.* ]]; then
+            [ "$HESTIA_DEBUG" ] && >&2 echo rm -rf $file
+            rm -rf $file
+        fi
+    done
+}

+ 2 - 2
bin/module/mariadb/install.inc

@@ -49,10 +49,10 @@ hestia_module_mariadb_install() {
     touch $OSAL_PATH_MARIADB_CONF/white-blocks.conf
     touch $OSAL_PATH_MARIADB_CONF/mailhelo.conf
 
-    rm -rf $OSAL_PATH_MARIADB_CONF/domains
+    hestia_safe_rm $OSAL_PATH_MARIADB_CONF/domains
     mkdir -p $OSAL_PATH_MARIADB_CONF/domains
 
-    rm -f /etc/alternatives/mydb
+    hestia_safe_rm /etc/alternatives/mydb
     ln -s /usr/sbin/$OSAL_PKG_MARIADB /etc/alternatives/mydb
     
     osal_service_stop sendmail > /dev/nul 2>&1

+ 1 - 1
bin/module/nginx/install.inc

@@ -35,7 +35,7 @@ EOL
     osal_package_preinstall
     osal_package_install $OSAL_PKG_NGINX
 
-    rm -f $OSAL_PATH_NGINX_CONF_D/*.conf
+    hestia_safe_rm $OSAL_PATH_NGINX_CONF_D/*.conf
     cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf $OSAL_PATH_NGINX_CONF/
     cp -f $HESTIA_INSTALL_DIR/nginx/status.conf $OSAL_PATH_NGINX_CONF_D/
     #FIXME: move the following to *admin install

+ 1 - 1
bin/module/php/add.inc

@@ -95,7 +95,7 @@ hestia_module_php_add() {
     pool_d=$(osal_multiphp_fpm_pool_d $php_version)
     if [ "$pool_d" ]; then
         mkdir -p $pool_d
-        rm -f $pool_d/*
+        hestia_safe_rm $pool_d/*
         cp -f $HESTIA_INSTALL_DIR/php-fpm/dummy.conf $pool_d/
         sed -i "s/9999/99$php_withoutdot/g" $pool_d/dummy.conf       # FIXME: this'll break with PHP 10.0
     fi

+ 2 - 2
bin/module/php/del.inc

@@ -83,8 +83,8 @@ hestia_module_php_del() {
     fi
 
     # Cleanup files and folders
-    [ -f $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl ] && rm -f $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl
-    [[ -d "$php_etc_folder" ]] && rm -rf "$php_etc_folder"
+    [ -f $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl ] && hestia_safe_rm $HESTIA/data/templates/web/php-fpm/PHP-${php_version/\./_}.tpl
+    [[ -d "$php_etc_folder" ]] && hestia_safe_rm "$php_etc_folder"
 
     osal_kv_write $HESTIA_CONF_MODULES/php.conf "php${php_withoutdot}_present" '0'
 

+ 1 - 1
bin/module/spamassassin/remove.inc

@@ -27,7 +27,7 @@ hestia_module_spamassassin_remove() {
 
     osal_package_remove $OSAL_PKG_SPAMASSASSIN
 
-    rm -rf $OSAL_PATH_SPAMASSASSIN_CONF
+    hestia_safe_rm $OSAL_PATH_SPAMASSASSIN_CONF
 
     osal_kv_write $HESTIA/conf/hestia.conf 'ANTISPAM_SYSTEM' ''
     osal_kv_write $HESTIA_CONF_MODULES/antispam.conf 'installed' '0'

+ 1 - 1
bin/module/vsftpd/remove.inc

@@ -23,7 +23,7 @@ hestia_module_vsftpd_remove() {
 
     osal_package_remove vsftpd
    
-    rm -rf $OSAL_PATH_VSFTPD_CONF
+    hestia_safe_rm $OSAL_PATH_VSFTPD_CONF
 
     osal_kv_write $HESTIA/conf/hestia.conf 'FTP_SYSTEM' ''
     osal_kv_write $HESTIA_CONF_MODULES/ftp.conf 'installed' '0'

+ 1 - 1
bin/module/web/setup-ip.inc

@@ -10,7 +10,7 @@ hestia_module_web_setup-ip() {
     # Web support
     if [ ! -z "$WEB_SYSTEM" ]; then
         web_conf="/etc/$WEB_SYSTEM/conf.d/$ip.conf"
-        rm -f $web_conf
+        hestia_safe_rm $web_conf
 
         if [ "$WEB_SYSTEM" = 'httpd' ] || [ "$WEB_SYSTEM" = 'apache2' ]; then
             if [ -z "$(/usr/sbin/apachectl -v | grep Apache/2.4)" ]; then