Skip to content

Commit e3e11f5

Browse files
committed
Only backup WireGuard folder if it contains files
1 parent 258e800 commit e3e11f5

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

auto_install/install.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3217,13 +3217,15 @@ confWireGuard() {
32173217
fi
32183218

32193219
if [[ -d /etc/wireguard ]]; then
3220-
# Backup the wireguard folder
3221-
WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz"
3222-
echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}"
3223-
CURRENT_UMASK="$(umask)"
3224-
umask 0077
3225-
${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null
3226-
umask "${CURRENT_UMASK}"
3220+
if [[ -n "$(ls -A /etc/wireguard)" ]]; then
3221+
# Backup the wireguard folder
3222+
WIREGUARD_BACKUP="wireguard_$(date +%Y-%m-%d-%H%M%S).tar.gz"
3223+
echo "::: Backing up the wireguard folder to /etc/${WIREGUARD_BACKUP}"
3224+
CURRENT_UMASK="$(umask)"
3225+
umask 0077
3226+
${SUDO} tar -czf "/etc/${WIREGUARD_BACKUP}" /etc/wireguard &> /dev/null
3227+
umask "${CURRENT_UMASK}"
3228+
fi
32273229

32283230
if [[ -f /etc/wireguard/wg0.conf ]]; then
32293231
${SUDO} rm /etc/wireguard/wg0.conf

0 commit comments

Comments
 (0)