From 3d281318728dab352ce815f8a9dad0e546f18c86 Mon Sep 17 00:00:00 2001 From: Jordan Potter Date: Thu, 14 Feb 2019 12:03:36 -0800 Subject: [PATCH] Add Dockerfile and entrypoint script --- Dockerfile | 8 ++++++++ entrypoint.sh | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Dockerfile create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..ba0e850 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:latest + +RUN apt-get update && apt-get install -y software-properties-common openresolv iptables iproute2 +RUN add-apt-repository ppa:wireguard/wireguard && apt-get update && apt-get install -y wireguard-tools + +COPY entrypoint.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..a5414b1 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +set -e + +interfaces=`find /etc/wireguard -type f` +if [[ -z $interfaces ]]; then + echo "No interface found in /etc/wireguard" >&2 + exit 1 +fi + +interface=`echo $interfaces | head -n 1` + +wg-quick up $interface + +shutdown () { + wg-quick down $interface + exit 0 +} + +trap shutdown SIGTERM SIGINT SIGQUIT + +sleep infinity & +wait $!