[PATCH 3/6] wg-quick: freebsd: add restart command
Garrit Franke
contact at garrit.xyz
Thu May 28 20:35:44 CEST 2020
---
src/wg-quick/freebsd.bash | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/wg-quick/freebsd.bash b/src/wg-quick/freebsd.bash
index e1ee67f..81c341b 100755
--- a/src/wg-quick/freebsd.bash
+++ b/src/wg-quick/freebsd.bash
@@ -387,7 +387,7 @@ execute_hooks() {
cmd_usage() {
cat >&2 <<-_EOF
- Usage: $PROGRAM [ up | down | save | strip ] [ CONFIG_FILE | INTERFACE ]
+ Usage: $PROGRAM [ up | down | restart | save | strip ] [ CONFIG_FILE | INTERFACE ]
CONFIG_FILE is a configuration file, whose filename is the interface name
followed by \`.conf'. Otherwise, INTERFACE is an interface name, with
@@ -445,6 +445,12 @@ cmd_down() {
execute_hooks "${POST_DOWN[@]}"
}
+cmd_restart() {
+ [[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
+ cmd_down
+ cmd_up
+}
+
cmd_save() {
[[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
save_config
@@ -469,6 +475,10 @@ elif [[ $# -eq 2 && $1 == down ]]; then
auto_su
parse_options "$2"
cmd_down
+elif [[ $# -eq 2 && $1 == restart ]]; then
+ auto_su
+ parse_options "$2"
+ cmd_restart
elif [[ $# -eq 2 && $1 == save ]]; then
auto_su
parse_options "$2"
--
2.24.3 (Apple Git-128)
More information about the WireGuard
mailing list