From 1c55bb6db27dab50f20695db2bd03ae8f8c1c6b5 Mon Sep 17 00:00:00 2001 From: William Wernert Date: Wed, 18 Nov 2020 15:34:40 -0500 Subject: [PATCH] [fix] Only backup /nsm/mysql and /nsm/wazuh --- setup/so-functions | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/setup/so-functions b/setup/so-functions index f1a1ec1b5..a01515866 100755 --- a/setup/so-functions +++ b/setup/so-functions @@ -1398,14 +1398,11 @@ reinstall_init() { date_string=$(date +%s) # Backup /opt/so since we'll be rebuilding this directory during setup - if [[ -d /opt/so ]]; then - mv /opt/so "/opt/so_old_${date_string}" - fi + backup_dir /opt/so "$date_string" - # Backup /nsm for the same reason - while IFS= read -r -d '' dir; do - mv "$dir" "${dir}_old_${date_string}" - done < <(find /nsm -maxdepth 1 -mindepth 1 -type d -not -path "/nsm/docker-registry" -print0) + # Backup directories in /nsm to prevent app errors + backup_dir /nsm/mysql "$date_string" + backup_dir /nsm/wazuh "$date_string" # Remove the old launcher package in case the config changes remove_package launcher-final @@ -1413,6 +1410,15 @@ reinstall_init() { } >> $setup_log 2>&1 } +backup_dir() { + dir=$1 + backup_suffix=$2 + + if [[ -d $dir ]]; then + mv "$dir" "${dir}_old_${backup_suffix}" + fi +} + remove_package() { local package_name=$1 if [ $OS = 'centos' ]; then