#!/bin/bash ## @licence MIT ## @author Copyright (C) 2015 Robin Schneider if [ -z "$OPENVPN" ]; then export OPENVPN="$PWD" fi if ! source "$OPENVPN/ovpn_env.sh"; then echo "Could not source $OPENVPN/ovpn_env.sh." exit 1 fi TARGET="/tmp/openvpn_${OVPN_CN}" if [ -n "$1" ]; then TARGET="$1" else TARGET="$OPENVPN/server" fi ## Ensure that no other keys then the one for the server is present. rm --recursive --force "$TARGET/pki/private" "$TARGET/pki/issued" echo " openvpn.conf ovpn_env.sh pki/private/${OVPN_CN}.key pki/issued/${OVPN_CN}.crt pki/dh.pem pki/ta.key pki/ca.crt " | rsync --recursive --verbose \ --files-from - \ "$OPENVPN/" "$TARGET" mkdir -p "$TARGET/ccd" echo "Created the openvpn configuration for the server: $TARGET"