Skip to content

Instantly share code, notes, and snippets.

@pombredanne
Forked from NicolasEhrhardt/extractinfo.sh
Created September 22, 2019 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pombredanne/547aa41bca8fcbdc23fdc682a47646fa to your computer and use it in GitHub Desktop.
Save pombredanne/547aa41bca8fcbdc23fdc682a47646fa to your computer and use it in GitHub Desktop.
{OpenVPN, Freebox, Ubuntu} Script de reformatage du fichier de configuarion
#/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