Merge branch 'master' into alpine

This commit is contained in:
Kyle Manna 2015-09-29 11:43:08 -07:00
commit c3d526fd67
2 changed files with 42 additions and 15 deletions

View File

@ -2,6 +2,8 @@
## @licence MIT <http://opensource.org/licenses/MIT> ## @licence MIT <http://opensource.org/licenses/MIT>
## @author Copyright (C) 2015 Robin Schneider <ypid@riseup.net> ## @author Copyright (C) 2015 Robin Schneider <ypid@riseup.net>
set -e
if [ -z "$OPENVPN" ]; then if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD" export OPENVPN="$PWD"
fi fi
@ -10,27 +12,30 @@ if ! source "$OPENVPN/ovpn_env.sh"; then
exit 1 exit 1
fi fi
TARGET="/tmp/openvpn_${OVPN_CN}" TARGET="$OPENVPN/server"
if [ -n "$1" ]; then if [ -n "$1" ]; then
TARGET="$1" TARGET="$1"
else
TARGET="$OPENVPN/server"
fi fi
mkdir -p "${TARGET}"
## Ensure that no other keys then the one for the server is present. ## Ensure that no other keys then the one for the server is present.
rm --recursive --force "$TARGET/pki/private" "$TARGET/pki/issued" rm -rf "$TARGET/pki/private" "$TARGET/pki/issued"
FILES=(
"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 isn't available to keep size down
# cp --parents isn't in busybox version
# hack the directory structure with tar
tar cf - -C "${OPENVPN}" "${FILES[@]}" | tar xvf - -C "${TARGET}"
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" mkdir -p "$TARGET/ccd"
echo "Created the openvpn configuration for the server: $TARGET" echo "Created the openvpn configuration for the server: $TARGET"

22
tests/paranoid.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
set -ex
IMG=${IMG:-kylemanna/openvpn}
temp=$(mktemp -d)
pushd $temp
SERV_IP=$(ip -4 -o addr show scope global | awk '{print $4}' | sed -e 's:/.*::' | head -n1)
docker run --net=none --rm -t -i -v $PWD:/etc/openvpn $IMG ovpn_genconfig -u udp://$SERV_IP
docker run --net=none --rm -t -i -v $PWD:/etc/openvpn -e "EASYRSA_BATCH=1" -e "EASYRSA_REQ_CN=Travis-CI Test CA" kylemanna/openvpn ovpn_initpki nopass
docker run --net=none --rm -t -i -v $PWD:/etc/openvpn $IMG ovpn_copy_server_files
popd
# Can't delete the temp directory as docker creates some files as root.
# Just let it die with the test instance.
rm -rf $temp || true