From 4ddaa97f11cf23a5d00f4ec12e7fb0989dcb6e32 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Sun, 8 May 2016 23:08:48 -0500 Subject: [PATCH 1/6] 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. --- openvpn-install.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) 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 From 8a8c78fc1d4c69b650209d7d5c44431e2f4644c8 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Sun, 8 May 2016 23:17:24 -0500 Subject: [PATCH 2/6] Update openvpn-install.sh --- openvpn-install.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 5a76294..8f5577c 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -40,9 +40,11 @@ fi # Makes the VPN folder in home, to keep things neater # Also using a variable for possible future adaptation and customization -set baseFolder="~/vpn" + +baseFolder="~/vpn" newclient () { + baseFolder="~/vpn" mkdir $baseFolder -p From 6dc63dbad4c852edaefd50a754991c1bf1cd4f32 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Sun, 8 May 2016 23:22:39 -0500 Subject: [PATCH 3/6] fixing syntax errors --- openvpn-install.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 8f5577c..1ef4252 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -49,16 +49,17 @@ newclient () { mkdir $baseFolder -p # Generates the custom client.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 + touch "$baseFolder/$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" } From b960da3b376bc7423db8c153009ee74be1b51e79 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Sun, 8 May 2016 23:37:22 -0500 Subject: [PATCH 4/6] syntax issues --- openvpn-install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 1ef4252..89a4616 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -41,10 +41,12 @@ fi # Makes the VPN folder in home, to keep things neater # Also using a variable for possible future adaptation and customization -baseFolder="~/vpn" +#baseFolder="~/vpn" +baseFolder="/home/$(whoami)/vpn" newclient () { - baseFolder="~/vpn" + #baseFolder="~/vpn" + baseFolder="/home/$(whoami)/vpn" mkdir $baseFolder -p From ccc30df192ccd909942b0301740088bce7ed3523 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Sun, 8 May 2016 23:40:05 -0500 Subject: [PATCH 5/6] syntax fixes --- openvpn-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 89a4616..8a6f0f2 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -42,11 +42,11 @@ fi # Also using a variable for possible future adaptation and customization #baseFolder="~/vpn" -baseFolder="/home/$(whoami)/vpn" +baseFolder="$HOME/vpn" newclient () { #baseFolder="~/vpn" - baseFolder="/home/$(whoami)/vpn" + baseFolder="$HOME/vpn" mkdir $baseFolder -p From e02d06ff5d81b7247cea9e9a50ddbdcc4df5f2a6 Mon Sep 17 00:00:00 2001 From: Ben Yanke Date: Sun, 8 May 2016 23:42:52 -0500 Subject: [PATCH 6/6] Update openvpn-install.sh --- openvpn-install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 8a6f0f2..c897a2f 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -41,12 +41,11 @@ fi # Makes the VPN folder in home, to keep things neater # Also using a variable for possible future adaptation and customization -#baseFolder="~/vpn" baseFolder="$HOME/vpn" newclient () { - #baseFolder="~/vpn" - baseFolder="$HOME/vpn" + +# baseFolder="$HOME/vpn" mkdir $baseFolder -p