From da954e93e35b751ac488d0f2851c43036e91d766 Mon Sep 17 00:00:00 2001 From: David Scott Date: Sat, 21 May 2016 21:56:32 +0100 Subject: [PATCH] tap-vsockd: add tap-vsockd service to bring up eth1 The tap-vsockd service is started from eth1's pre-up script. On the Mac: the bind of the AF_HYPERV socket fails, and eth1 is skipped. On Windows: if there is no database then eth1 is skipped. On Windows: if the database has network=native then eth1 is brought up. Signed-off-by: David Scott --- alpine/Dockerfile | 1 + alpine/etc/network/interfaces | 2 + .../packages/tap-vsockd/etc/init.d/tap-vsockd | 43 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100755 alpine/packages/tap-vsockd/etc/init.d/tap-vsockd diff --git a/alpine/Dockerfile b/alpine/Dockerfile index 2e495dc26..e4de2367e 100644 --- a/alpine/Dockerfile +++ b/alpine/Dockerfile @@ -41,6 +41,7 @@ COPY packages/proxy/etc /etc/ COPY packages/transfused/transfused /sbin/ COPY packages/transfused/etc /etc/ COPY packages/tap-vsockd/tap-vsockd /sbin/ +COPY packages/tap-vsockd/etc /etc/ COPY packages/llmnrd/llmnrd /sbin/ COPY packages/llmnrd/etc /etc/ COPY packages/llmnrd/llmnrd.tar.gz /usr/share/src/ diff --git a/alpine/etc/network/interfaces b/alpine/etc/network/interfaces index 786503a5e..fec093bbd 100644 --- a/alpine/etc/network/interfaces +++ b/alpine/etc/network/interfaces @@ -9,3 +9,5 @@ auto eth1 iface eth1 inet dhcp udhcpc_opts -T 1 -A 3 metric 199 + pre-up service tap-vsockd start + post-down service tap-vsockd stop diff --git a/alpine/packages/tap-vsockd/etc/init.d/tap-vsockd b/alpine/packages/tap-vsockd/etc/init.d/tap-vsockd new file mode 100755 index 000000000..0e7fd6f44 --- /dev/null +++ b/alpine/packages/tap-vsockd/etc/init.d/tap-vsockd @@ -0,0 +1,43 @@ +#!/sbin/openrc-run + +description="VPN proxy" + +depend() +{ + before networking +} + +start() +{ + if mobyconfig exists network + then + NETWORK_MODE="$(mobyconfig get network | tr -d '[[:space:]]')" + if [ "${NETWORK_MODE}" = "hybrid" ]; then + + ebegin "Starting VPN proxy" + + PIDFILE=/var/run/tap-vsockd.pid + start-stop-daemon --start --quiet \ + --exec /sbin/tap-vsockd \ + --pidfile ${PIDFILE} \ + -- \ + --daemon \ + --pidfile "${PIDFILE}" \ + --listen + + eend $? "Failed to start VPN proxy" + fi + fi +} + +stop() +{ + ebegin "Stopping VPN proxy" + + PIDFILE=/var/run/tap-vsockd.pid + + start-stop-daemon --stop --quiet \ + --pidfile "${PIDFILE}" + + eend $? "Failed to stop VPN proxy" +}