diff options
author | decke <decke@FreeBSD.org> | 2018-10-11 20:49:45 +0800 |
---|---|---|
committer | decke <decke@FreeBSD.org> | 2018-10-11 20:49:45 +0800 |
commit | a934d9aa8d7c1049894c0ee78de93d048cfc65cd (patch) | |
tree | e70528491456a9dfe5b70ed0849bb772eba63c73 /net | |
parent | 472fe9566eceb2e214ecf20df5bdaa205bf8b32a (diff) | |
download | freebsd-ports-gnome-a934d9aa8d7c1049894c0ee78de93d048cfc65cd.tar.gz freebsd-ports-gnome-a934d9aa8d7c1049894c0ee78de93d048cfc65cd.tar.zst freebsd-ports-gnome-a934d9aa8d7c1049894c0ee78de93d048cfc65cd.zip |
net/wireguard: Add rc.d script
Submitted by: Steve Hay <hay.steve@gmail.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/wireguard/Makefile | 2 | ||||
-rw-r--r-- | net/wireguard/files/wireguard.in | 38 |
2 files changed, 40 insertions, 0 deletions
diff --git a/net/wireguard/Makefile b/net/wireguard/Makefile index ae98ea837df7..7dbb2365627f 100644 --- a/net/wireguard/Makefile +++ b/net/wireguard/Makefile @@ -2,6 +2,7 @@ PORTNAME= wireguard PORTVERSION= 0.0.20181007 +PORTREVISION= 1 CATEGORIES= net MASTER_SITES= https://git.zx2c4.com/WireGuard/snapshot/ DISTNAME= WireGuard-${PORTVERSION} @@ -16,6 +17,7 @@ RUN_DEPENDS= bash:shells/bash \ wireguard-go:net/wireguard-go USES= gmake tar:xz +USE_RC_SUBR= ${PORTNAME} WRKSRC= ${WRKDIR}/${DISTNAME}/src/tools diff --git a/net/wireguard/files/wireguard.in b/net/wireguard/files/wireguard.in new file mode 100644 index 000000000000..f61a77387b64 --- /dev/null +++ b/net/wireguard/files/wireguard.in @@ -0,0 +1,38 @@ +#!/bin/sh + +# $FreeBSD$ +# +# PROVIDE: wireguard +# REQUIRE: DAEMON +# KEYWORD: shutdown + +. /etc/rc.subr + +name=wireguard +rcvar=wireguard_enable + +start_cmd="${name}_start" +stop_cmd="${name}_stop" + +wireguard_start() +{ + for f in %%PREFIX%%/etc/wireguard/*.conf; do + %%PREFIX%%/bin/wg-quick up ${f} + done +} + +wireguard_stop() +{ + %%PREFIX%%/bin/wg show interfaces | while IFS= read -r interfaces; + do + for interface in $interfaces; do + %%PREFIX%%/wg-quick down ${interface} + done + done + + # race condition in wg-quick down + sleep 1 +} + +load_rc_config $name +run_rc_command "$1" |