Last active
March 30, 2022 00:11
-
-
Save NicolasEhrhardt/10950378 to your computer and use it in GitHub Desktop.
{OpenVPN, Freebox, Ubuntu} Script de reformatage du fichier de configuarion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
# make output file | |
basedir=~/.openvpn | |
vpnconfigdir=$basedir/$2 | |
mkdir -p $basedir | |
mkdir -p $vpnconfigdir | |
# print Gateway | |
sed -n 's/remote \([^ ]\+\) [0-9]\+/passerelle: \1/p' $1 | |
# create client config file | |
awk '/<ca>/{exit} {print}' $1 > $vpnconfigdir/client.ovpn | |
# output certificate of CA | |
awk '/<ca>/ {flag=1;next} /<\/ca>/{flag=0} flag {print}' $1 > $vpnconfigdir/ca.crt | |
# output certificate of client key | |
awk '/<cert>/ {flag=1;next} /<\/cert>/{flag=0} flag {print}' $1 > $vpnconfigdir/client.crt | |
# output client key | |
awk '/<key>/ {flag=1;next} /<\/key>/{flag=0} flag {print}' $1 > $vpnconfigdir/client.key | |
# remove rights for other | |
chmod -R o-rwx $vpnconfigdir/* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment