mirror of
https://git.FreeBSD.org/ports.git
synced 2024-12-02 01:20:54 +00:00
net/wireguard: Update rc.d script to let the user define which wg interfaces to manage
Most people will likely want to put wireguard_interfaces="wg0" in /etc/rc.conf Reported by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
52dec40c0c
commit
94f2babee1
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=482968
@ -2,6 +2,7 @@
|
||||
|
||||
PORTNAME= wireguard
|
||||
PORTVERSION= 0.0.20181018
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net
|
||||
MASTER_SITES= https://git.zx2c4.com/WireGuard/snapshot/
|
||||
DISTNAME= WireGuard-${PORTVERSION}
|
||||
|
@ -5,6 +5,13 @@
|
||||
# PROVIDE: wireguard
|
||||
# REQUIRE: DAEMON
|
||||
# KEYWORD: shutdown
|
||||
#
|
||||
# wireguard_enable (bool): Set to "YES" to enable wireguard.
|
||||
# (default: "NO")
|
||||
#
|
||||
# wireguard_interfaces (str): List of interfaces to bring up/down
|
||||
# on start/stop. (eg: "wg0 wg1")
|
||||
# (default: "")
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
@ -16,20 +23,20 @@ stop_cmd="${name}_stop"
|
||||
|
||||
wireguard_start()
|
||||
{
|
||||
for f in %%PREFIX%%/etc/wireguard/*.conf; do
|
||||
%%PREFIX%%/bin/wg-quick up ${f}
|
||||
for interface in ${wireguard_interfaces}; do
|
||||
%%PREFIX%%/bin/wg-quick up ${interface}
|
||||
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
|
||||
for interface in ${wireguard_interfaces}; do
|
||||
%%PREFIX%%/bin/wg-quick down ${interface}
|
||||
done
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
|
||||
: ${wireguard_interfaces=""}
|
||||
|
||||
run_rc_command "$1"
|
||||
|
Loading…
Reference in New Issue
Block a user