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.
This commit is contained in:
Kyle Manna 2014-06-03 21:55:15 -07:00
parent f6873cf5bd
commit 9e4de074d0

View File

@ -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\""
;;