diff --git a/openvpn-install.sh b/openvpn-install.sh index d615f60..5a76294 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -38,18 +38,25 @@ else exit 4 fi +# Makes the VPN folder in home, to keep things neater +# Also using a variable for possible future adaptation and customization +set baseFolder="~/vpn" + newclient () { + + mkdir $baseFolder -p + # Generates the custom client.ovpn - cp /etc/openvpn/client-common.txt ~/$1.ovpn - echo "" >> ~/$1.ovpn - cat /etc/openvpn/easy-rsa/pki/ca.crt >> ~/$1.ovpn - echo "" >> ~/$1.ovpn - echo "" >> ~/$1.ovpn - cat /etc/openvpn/easy-rsa/pki/issued/$1.crt >> ~/$1.ovpn - echo "" >> ~/$1.ovpn - echo "" >> ~/$1.ovpn - cat /etc/openvpn/easy-rsa/pki/private/$1.key >> ~/$1.ovpn - echo "" >> ~/$1.ovpn + cp /etc/openvpn/client-common.txt $baseFolder/$1.ovpn + echo "" >> $baseFolder/$1.ovpn + cat /etc/openvpn/easy-rsa/pki/ca.crt >> $baseFolder/$1.ovpn + echo "" >> $baseFolder/$1.ovpn + echo "" >> $baseFolder/$1.ovpn + cat /etc/openvpn/easy-rsa/pki/issued/$1.crt >> $baseFolder/$1.ovpn + echo "" >> $baseFolder/$1.ovpn + echo "" >> $baseFolder/$1.ovpn + cat /etc/openvpn/easy-rsa/pki/private/$1.key >> $baseFolder/$1.ovpn + echo "" >> $baseFolder/$1.ovpn } @@ -85,7 +92,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then # Generates the custom client.ovpn newclient "$CLIENT" echo "" - echo "Client $CLIENT added, certs available at ~/$CLIENT.ovpn" + echo "Client $CLIENT added, certs available at $baseFolder/$CLIENT.ovpn" exit ;; 2) @@ -366,6 +373,6 @@ verb 3" > /etc/openvpn/client-common.txt echo "" echo "Finished!" echo "" - echo "Your client config is available at ~/$CLIENT.ovpn" + echo "Your client config is available at $baseFolder/$CLIENT.ovpn" echo "If you want to add more clients, you simply need to run this script another time!" fi