aboutsummaryrefslogtreecommitdiff
path: root/net/wireguard/files/wireguard.in
blob: 7caaa8597ab61c4cd0841604d45f0725564619d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

# $FreeBSD$
#
# 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

name=wireguard
rcvar=wireguard_enable

start_cmd="${name}_start"
stop_cmd="${name}_stop"

wireguard_start()
{
	for interface in ${wireguard_interfaces}; do
		%%PREFIX%%/bin/wg-quick up ${interface}
	done
}

wireguard_stop()
{
	for interface in ${wireguard_interfaces}; do
		%%PREFIX%%/bin/wg-quick down ${interface}
	done
}

load_rc_config $name

: ${wireguard_interfaces=""}

run_rc_command "$1"