From 9e4de074d07a3b8e492f85f978e3b22a560bafb6 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Tue, 3 Jun 2014 21:55:15 -0700 Subject: [PATCH] openvpn.sh: Add easyrsa to wrapper * Provide a way to invoke easyrsa form the wrapper * Add ability to set the EasyRSA vars file which manages the default settings for the EasyRSA PKI CA. --- bin/openvpn.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/bin/openvpn.sh b/bin/openvpn.sh index 00efc39..cd3c6e3 100755 --- a/bin/openvpn.sh +++ b/bin/openvpn.sh @@ -3,6 +3,13 @@ # OpenVPN + Docker Wrapper Script # +OPENVPN="/etc/openvpn" + +# Needed by easyrsa itself +export EASYRSA="/usr/local/share/easy-rsa/easyrsa3" +export EASYRSA_PKI="$OPENVPN/pki" +export EASYRSA_VARS_FILE="$OPENVPN/vars" + set -ex abort() { @@ -14,11 +21,46 @@ if [ $# -lt 1 ]; then abort "No command specified" fi +do_openvpn() { + if [ ! -d /dev/net ]; then + mkdir -p /dev/net + fi + if [ ! -c /dev/net/tun ]; then + mknod /dev/net/tun c 10 200 + fi + + cd /etc/easyrsa +} + # Read arguments from command line cmd=$1 shift case "$cmd" in + # nop for volume creation + init) + exit 0 + ;; + easyrsa) + cd $OPENVPN + easyrsa "$@" + ;; + easyrsa-export-vars) + if [ -f "$EASYRSA_VARS_FILE" ]; then + cat "$EASYRSA_VARS_FILE" + else + cat "$EASYRSA/vars.example" + fi + ;; + easyrsa-import-vars) + cat > "$EASYRSA_VARS_FILE" + ;; + bash) + $cmd "$@" + ;; + openvpn) + do_openvpn "$@" + ;; *) abort "Unknown cmd \"$cmd\"" ;;