Parse arguments in the tests entrypoint

Add an argument parsing routine to the tests entrypoint, and use it
to parse the interface name, passed to
wireguard-go.
This commit is contained in:
kaiyou 2020-05-18 23:57:29 +02:00 committed by Leo Antunes
parent 2fe308cd1d
commit 61988692a1
1 changed files with 16 additions and 5 deletions

View File

@ -1,10 +1,21 @@
#!/bin/sh #!/bin/bash
set -e set -e
# Parse arguments
args=("$@")
while [[ $# -gt 0 ]]; do case $1 in
--interface)
iface=$2
shift
;;
esac; shift; done
# Create tun device if necessary
if [ ! -e /dev/net/tun ]; then
mkdir -p /dev/net mkdir -p /dev/net
mknod /dev/net/tun c 10 200 mknod /dev/net/tun c 10 200
fi
wireguard-go wgoverlay wireguard-go ${iface:-wgoverlay}
/app/wesher --log-level debug --cluster-key 'ILICZ3yBMCGAWNIq5Pn0bewBVimW3Q2yRVJ/Be+b1Uc=' "${args[@]}"
/app/wesher --log-level debug --cluster-key 'ILICZ3yBMCGAWNIq5Pn0bewBVimW3Q2yRVJ/Be+b1Uc=' "$@"