Backup and restore stunnel

This commit is contained in:
Bob Mottram 2017-09-27 15:31:50 +01:00
parent a7f783c3a8
commit 886e9a8c49
1 changed files with 36 additions and 0 deletions

View File

@ -213,6 +213,7 @@ function backup_local_vpn {
function_check backup_directory_to_usb
backup_directory_to_usb /etc/openvpn/easy-rsa/keys vpn
backup_directory_to_usb /etc/stunnel vpnstunnel
}
function restore_local_vpn {
@ -232,6 +233,23 @@ function restore_local_vpn {
fi
done
fi
temp_restore_dir=/root/tempvpnstunnel
restore_directory_from_usb $temp_restore_dir vpnstunnel
if [ -d ${temp_restore_dir} ]; then
cp -r ${temp_restore_dir}/* /etc/stunnel
rm -rf ${temp_restore_dir}
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [ -f /home/$USERNAME/stunnel.pem ]; then
cp /etc/stunnel/stunnel.pem /home/$USERNAME/stunnel.pem
chown $USERNAME:$USERNAME /home/$USERNAME/stunnel.pem
fi
if [ -f /home/$USERNAME/stunnel.p12 ]; then
cp /etc/stunnel/stunnel.p12 /home/$USERNAME/stunnel.p12
chown $USERNAME:$USERNAME /home/$USERNAME/stunnel.p12
fi
done
fi
}
function backup_remote_vpn {
@ -244,6 +262,7 @@ function backup_remote_vpn {
function_check backup_directory_to_friend
backup_directory_to_friend /etc/openvpn/easy-rsa/keys vpn
backup_directory_to_friend /etc/stunnel vpnstunnel
}
function restore_remote_vpn {
@ -263,6 +282,23 @@ function restore_remote_vpn {
fi
done
fi
temp_restore_dir=/root/tempvpnstunnel
restore_directory_from_friend $temp_restore_dir vpnstunnel
if [ -d ${temp_restore_dir} ]; then
cp -r ${temp_restore_dir}/* /etc/stunnel
rm -rf ${temp_restore_dir}
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [ -f /home/$USERNAME/stunnel.pem ]; then
cp /etc/stunnel/stunnel.pem /home/$USERNAME/stunnel.pem
chown $USERNAME:$USERNAME /home/$USERNAME/stunnel.pem
fi
if [ -f /home/$USERNAME/stunnel.p12 ]; then
cp /etc/stunnel/stunnel.p12 /home/$USERNAME/stunnel.p12
chown $USERNAME:$USERNAME /home/$USERNAME/stunnel.p12
fi
done
fi
}
function remove_vpn {