Skip to content

Commit

Permalink
ovpn_copy_server_files: Copy files without rsync
Browse files Browse the repository at this point in the history
* Hack around the missing rsync by using tar to preserve the directory
  structure.
* Fixes #73
  • Loading branch information
kylemanna committed Sep 29, 2015
1 parent 7f58926 commit f00de36
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions bin/ovpn_copy_server_files
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
## @licence MIT <http://opensource.org/licenses/MIT>
## @author Copyright (C) 2015 Robin Schneider <[email protected]>

set -e

if [ -z "$OPENVPN" ]; then
export OPENVPN="$PWD"
fi
Expand All @@ -10,27 +12,30 @@ if ! source "$OPENVPN/ovpn_env.sh"; then
exit 1
fi

TARGET="/tmp/openvpn_${OVPN_CN}"
TARGET="$OPENVPN/server"
if [ -n "$1" ]; then
TARGET="$1"
else
TARGET="$OPENVPN/server"
fi
mkdir -p "${TARGET}"

## 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"
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}"

mkdir -p "$TARGET/ccd"

echo "Created the openvpn configuration for the server: $TARGET"

2 comments on commit f00de36

@muhmuhten
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also just apk add rsync to the image. it adds something like half a MB.

@ypid
Copy link
Contributor

@ypid ypid commented on f00de36 Sep 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. Thanks. But I agree with @kylemanna that it is unnecessary. The rsync solution wasn’t very good anyway.

Please sign in to comment.