From e3e11f5d22b558e105c6c3925d78f8a9c2c11722 Mon Sep 17 00:00:00 2001 From: Orazio <22700499+orazioedoardo@users.noreply.github.com> Date: Wed, 12 Mar 2025 08:38:21 +0100 Subject: [PATCH] Only backup WireGuard folder if it contains files --- auto_install/install.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/auto_install/install.sh b/auto_install/install.sh index abe784e..26f6c47 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -3217,13 +3217,15 @@ confWireGuard() { fi if [[ -d /etc/wireguard ]]; then - # Backup the wireguard folder - WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz" - echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}" - CURRENT_UMASK="$(umask)" - umask 0077 - ${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null - umask "${CURRENT_UMASK}" + if [[ -n "$(ls -A /etc/wireguard)" ]]; then + # Backup the wireguard folder + WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz" + echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}" + CURRENT_UMASK="$(umask)" + umask 0077 + ${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null + umask "${CURRENT_UMASK}" + fi if [[ -f /etc/wireguard/wg0.conf ]]; then ${SUDO} rm /etc/wireguard/wg0.conf