From 9d6668834140c5270e8b38fe603e3ab76308ad72 Mon Sep 17 00:00:00 2001 From: Akvile Date: Tue, 20 Aug 2019 11:36:05 -0500 Subject: [PATCH] added the functionality to send your OVPN file to your Bitwarden vault --- scripts/makeOVPN.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/makeOVPN.sh b/scripts/makeOVPN.sh index 8c8af49..54d4f95 100755 --- a/scripts/makeOVPN.sh +++ b/scripts/makeOVPN.sh @@ -328,6 +328,24 @@ if [ ! -d "/home/$INSTALL_USER/ovpns" ]; then chmod 0777 -R "/home/$INSTALL_USER/ovpns" fi +# If user is using Bitwarden, have them login again to submit their .ovpn file to their vault +printf "Would you like to export your .ovpn file to your Bitwarden vault? (y or n)" +read -r RESPONSE +if [ $RESPONSE == "y" ] || [ $RESPONSE == "Y" ]; then + $OVPN_FILE="$(< "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT")" + # Login to Bitwarden + printf "****Bitwarden Login****" + printf "\n" + SESSION_KEY=`bw login --raw` + export BW_SESSION=$SESSION_KEY + printf "Successfully Logged in!" + printf "\n" + # Create a Bitwarden secure note to export the .ovpn file + bw get template item | jq '.name = "PiVPN OVPN File"' | jq '.type = 2' | jq -r --arg VAL "$OVPN_FILE" '.notes = $VAL' | jq ".secureNote = $(bw get template item.secureNote)" | bw encode | bw create item + bw logout + exit + fi + # Copy the .ovpn profile to the home directory for convenient remote access cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT" chown "$INSTALL_USER" "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT"