aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/wg-quick/freebsd.bash
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-23 15:08:30 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-23 15:24:07 +0200
commita62f4ce1da764591f66f5a1ceb8f791fc05ed074 (patch)
treeb1aeaa6532ab4fecde77a246bb8950c7e436062d /src/tools/wg-quick/freebsd.bash
parenttools: always pass -v as first argument to install (diff)
downloadwireguard-monolithic-historical-a62f4ce1da764591f66f5a1ceb8f791fc05ed074.tar.xz
wireguard-monolithic-historical-a62f4ce1da764591f66f5a1ceb8f791fc05ed074.zip
wg-quick: support FreeBSD/Darwin search path
Diffstat (limited to '')
-rwxr-xr-xsrc/tools/wg-quick/freebsd.bash18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/tools/wg-quick/freebsd.bash b/src/tools/wg-quick/freebsd.bash
index 6d698e2..cc3b8e6 100755
--- a/src/tools/wg-quick/freebsd.bash
+++ b/src/tools/wg-quick/freebsd.bash
@@ -38,10 +38,16 @@ die() {
exit 1
}
+CONFIG_SEARCH_PATHS=( /etc/wireguard /usr/local/etc/wireguard )
+
parse_options() {
- local interface_section=0 line key value stripped
+ local interface_section=0 line key value stripped path
CONFIG_FILE="$1"
- [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]] && CONFIG_FILE="/etc/wireguard/$CONFIG_FILE.conf"
+ if [[ $CONFIG_FILE =~ ^[a-zA-Z0-9_=+.-]{1,15}$ ]]; then
+ for path in "${CONFIG_SEARCH_PATHS[@]}"; do
+ [[ -e $path/$CONFIG_FILE.conf ]] && { CONFIG_FILE="$path/$CONFIG_FILE.conf"; break; }
+ done
+ fi
[[ -e $CONFIG_FILE ]] || die "\`$CONFIG_FILE' does not exist"
[[ $CONFIG_FILE =~ (^|/)([a-zA-Z0-9_=+.-]{1,15})\.conf$ ]] || die "The config file must be a valid interface name, followed by .conf"
CONFIG_FILE="$(readlink -f "$CONFIG_FILE")"
@@ -334,9 +340,11 @@ cmd_usage() {
CONFIG_FILE is a configuration file, whose filename is the interface name
followed by \`.conf'. Otherwise, INTERFACE is an interface name, with
- configuration found at /etc/wireguard/INTERFACE.conf. It is to be readable
- by wg(8)'s \`setconf' sub-command, with the exception of the following additions
- to the [Interface] section, which are handled by $PROGRAM:
+ configuration found at:
+ ${CONFIG_SEARCH_PATHS[@]/%//INTERFACE.conf}.
+ It is to be readable by wg(8)'s \`setconf' sub-command, with the exception
+ of the following additions to the [Interface] section, which are handled
+ by $PROGRAM:
- Address: may be specified one or more times and contains one or more
IP addresses (with an optional CIDR mask) to be set for the interface.