1
0
mirror of https://github.com/Nyr/openvpn-install.git synced 2024-11-24 05:56:08 +03:00

Store client config info in ~/vpn instead of ~

fixed for neatness. Also declared $baseFolder at line 43, so the VPN folder can be changed easily.
This commit is contained in:
Ben Yanke 2016-05-08 23:08:48 -05:00
parent 2bcb4681a1
commit 4ddaa97f11

View File

@ -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 "<ca>" >> ~/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/ca.crt >> ~/$1.ovpn
echo "</ca>" >> ~/$1.ovpn
echo "<cert>" >> ~/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/issued/$1.crt >> ~/$1.ovpn
echo "</cert>" >> ~/$1.ovpn
echo "<key>" >> ~/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/private/$1.key >> ~/$1.ovpn
echo "</key>" >> ~/$1.ovpn
cp /etc/openvpn/client-common.txt $baseFolder/$1.ovpn
echo "<ca>" >> $baseFolder/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/ca.crt >> $baseFolder/$1.ovpn
echo "</ca>" >> $baseFolder/$1.ovpn
echo "<cert>" >> $baseFolder/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/issued/$1.crt >> $baseFolder/$1.ovpn
echo "</cert>" >> $baseFolder/$1.ovpn
echo "<key>" >> $baseFolder/$1.ovpn
cat /etc/openvpn/easy-rsa/pki/private/$1.key >> $baseFolder/$1.ovpn
echo "</key>" >> $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