Automatic backup of existing OpenVPN/WireGuard folder should only be readable by root

This commit is contained in:
Orazio 2020-02-10 17:58:32 +01:00
parent 0cb5546608
commit 3730d315e9

View file

@ -1735,7 +1735,10 @@ confOpenVPN(){
# Backup the openvpn folder
OPENVPN_BACKUP="openvpn_$(date +%Y-%m-%d-%H%M%S).tar.gz"
echo "::: Backing up the openvpn folder to /etc/${OPENVPN_BACKUP}"
CURRENT_UMASK=$(umask)
umask 0077
$SUDO tar czf "/etc/${OPENVPN_BACKUP}" /etc/openvpn &> /dev/null
umask "$CURRENT_UMASK"
if [ -f /etc/openvpn/server.conf ]; then
$SUDO rm /etc/openvpn/server.conf
@ -1912,7 +1915,10 @@ confWireGuard(){
# 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 [ -f /etc/wireguard/wg0.conf ]; then
$SUDO rm /etc/wireguard/wg0.conf