2015-03-08 21:40:08 +00:00
|
|
|
#!/bin/bash
|
2015-05-12 19:24:59 +00:00
|
|
|
## @licence MIT <http://opensource.org/licenses/MIT>
|
2015-03-08 21:40:08 +00:00
|
|
|
## @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
|
|
|
|
|
2015-08-26 11:00:17 +00:00
|
|
|
## Ensure that no other keys then the one for the server is present.
|
|
|
|
rm --recursive --force "$TARGET/pki/private" "$TARGET/pki/issued"
|
|
|
|
|
2015-05-30 22:45:16 +00:00
|
|
|
echo "
|
|
|
|
pki/private/${OVPN_CN}.key
|
|
|
|
pki/issued/${OVPN_CN}.crt
|
|
|
|
pki/dh.pem
|
|
|
|
pki/ta.key
|
|
|
|
pki/ca.crt
|
|
|
|
" | rsync --recursive --verbose \
|
|
|
|
--files-from - \
|
2015-03-12 22:49:49 +00:00
|
|
|
"$OPENVPN/" "$TARGET"
|
2015-05-30 22:45:16 +00:00
|
|
|
ln --symbolic --force ../openvpn.conf ../ovpn_env.sh "$TARGET"
|
2015-05-31 20:10:54 +00:00
|
|
|
mkdir -p "$TARGET/ccd"
|
2015-03-08 21:40:08 +00:00
|
|
|
|
|
|
|
echo "Created the openvpn configuration for the server: $TARGET"
|