Backup and restore vpn keys
This commit is contained in:
parent
54bc008961
commit
01c182b668
|
@ -64,19 +64,61 @@ function upgrade_vpn {
|
|||
}
|
||||
|
||||
function backup_local_vpn {
|
||||
echo -n ''
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [ -f /home/$USERNAME/$OPENVPN_KEY_FILENAME ]; then
|
||||
cp /home/$USERNAME/$OPENVPN_KEY_FILENAME /etc/openvpn/easy-rsa/keys/${USERNAME}_${OPENVPN_KEY_FILENAME}
|
||||
fi
|
||||
done
|
||||
|
||||
function_check backup_directory_to_usb
|
||||
backup_directory_to_usb /etc/openvpn/easy-rsa/keys vpn
|
||||
}
|
||||
|
||||
function restore_local_vpn {
|
||||
echo -n ''
|
||||
temp_restore_dir=/root/tempvpn
|
||||
restore_directory_from_usb $temp_restore_dir vpn
|
||||
if [ -d ${temp_restore_dir} ]; then
|
||||
cp -r ${temp_restore_dir}/* /etc/openvpn/easy-rsa/keys
|
||||
rm -rf ${temp_restore_dir}
|
||||
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [ -f /etc/openvpn/easy-rsa/keys/${USERNAME}_${OPENVPN_KEY_FILENAME} ]; then
|
||||
cp /etc/openvpn/easy-rsa/keys/${USERNAME}_${OPENVPN_KEY_FILENAME} /home/$USERNAME/$OPENVPN_KEY_FILENAME
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/$OPENVPN_KEY_FILENAME
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function backup_remote_vpn {
|
||||
echo -n ''
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [ -f /home/$USERNAME/$OPENVPN_KEY_FILENAME ]; then
|
||||
cp /home/$USERNAME/$OPENVPN_KEY_FILENAME /etc/openvpn/easy-rsa/keys/${USERNAME}_${OPENVPN_KEY_FILENAME}
|
||||
fi
|
||||
done
|
||||
|
||||
function_check backup_directory_to_friend
|
||||
backup_directory_to_friend /etc/openvpn/easy-rsa/keys vpn
|
||||
}
|
||||
|
||||
function restore_remote_vpn {
|
||||
echo -n ''
|
||||
temp_restore_dir=/root/tempvpn
|
||||
restore_directory_from_friend $temp_restore_dir vpn
|
||||
if [ -d ${temp_restore_dir} ]; then
|
||||
cp -r ${temp_restore_dir}/* /etc/openvpn/easy-rsa/keys
|
||||
rm -rf ${temp_restore_dir}
|
||||
|
||||
for d in /home/*/ ; do
|
||||
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
|
||||
if [ -f /etc/openvpn/easy-rsa/keys/${USERNAME}_${OPENVPN_KEY_FILENAME} ]; then
|
||||
cp /etc/openvpn/easy-rsa/keys/${USERNAME}_${OPENVPN_KEY_FILENAME} /home/$USERNAME/$OPENVPN_KEY_FILENAME
|
||||
chown $USERNAME:$USERNAME /home/$USERNAME/$OPENVPN_KEY_FILENAME
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_vpn {
|
||||
|
|
Loading…
Reference in New Issue