2015-03-08 21:40:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
## @licence AGPLv3 <https://www.gnu.org/licenses/agpl-3.0.html>
|
|
|
|
## @author Copyright (C) 2015 Robin Schneider <ypid@riseup.net>
|
|
|
|
|
2015-03-12 22:07:34 +00:00
|
|
|
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
|
2015-03-08 21:40:08 +00:00
|
|
|
|
|
|
|
TARGET="/tmp/openvpn_${OVPN_CN}"
|
|
|
|
if [ -n "$1" ]; then
|
|
|
|
TARGET="$1"
|
2015-03-12 22:07:34 +00:00
|
|
|
else
|
|
|
|
TARGET="$OPENVPN/server"
|
2015-03-08 21:40:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
rsync --recursive --verbose --prune-empty-dirs \
|
2015-03-12 22:07:34 +00:00
|
|
|
--exclude="clients" \
|
|
|
|
--exclude="server" \
|
2015-03-08 21:40:08 +00:00
|
|
|
--include "*/" \
|
|
|
|
--include "/pki/private/${OVPN_CN}.key" \
|
|
|
|
--include "/pki/ca.crt" \
|
|
|
|
--include "/pki/issued/${OVPN_CN}.crt" \
|
|
|
|
--include "/pki/dh.pem" \
|
|
|
|
--include "ta.key" \
|
|
|
|
--include "/openvpn.conf" \
|
|
|
|
--include "/ovpn_env.sh" \
|
|
|
|
--exclude="*" \
|
2015-03-12 22:07:34 +00:00
|
|
|
"$OPENVPN/" "$TARGET" -n
|
2015-03-08 21:40:08 +00:00
|
|
|
|
|
|
|
echo "Created the openvpn configuration for the server: $TARGET"
|