Skip to content

Instantly share code, notes, and snippets.

@aib
Created August 13, 2024 06:59
Show Gist options
  • Save aib/d4f4699e8e5c07495c5fcddc5b8ef956 to your computer and use it in GitHub Desktop.
Save aib/d4f4699e8e5c07495c5fcddc5b8ef956 to your computer and use it in GitHub Desktop.
#!/bin/bash
CA=/etc/openvpn/keys/ca.crt
CERT=/etc/easy-rsa/keys/$1.crt
KEY=/etc/easy-rsa/keys/$1.key
TLS_AUTH=/etc/openvpn/keys/ta.key
cat client.ovpn \
| sed -e '/<ca><\/ca>/{' -e 'i <ca>' -e "r $CA" -e 'a </ca>' -e 'd' -e '}' \
| sed -e '/<key><\/key>/{' -e 'i <key>' -e "r $KEY" -e 'a </key>' -e 'd' -e '}' \
| sed -e '/<cert><\/cert>/{' -e 'i <cert>' -e "r $CERT" -e 'a </cert>' -e 'd' -e '}' \
| sed -e '/<tls-auth><\/tls-auth>/{' -e 'i <tls-auth>' -e "r $TLS_AUTH" -e 'a </tls-auth>' -e 'd' -e '}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment