summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/wg-quick.bash
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 17:51:38 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 17:51:38 +0100
commitb139499b28c418b7ddd1336998169ebe5b216e14 (patch)
tree5dd25420b5f9bf3dae1717f25f6f467b5ace1d4b /src/tools/wg-quick.bash
parentcontrib: add reresolve-dns (diff)
downloadwireguard-monolithic-historical-b139499b28c418b7ddd1336998169ebe5b216e14.tar.xz
wireguard-monolithic-historical-b139499b28c418b7ddd1336998169ebe5b216e14.zip
wg-quick: allow for saving existing interface
Diffstat (limited to '')
-rwxr-xr-xsrc/tools/wg-quick.bash11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash
index 17fe672..da4c0d4 100755
--- a/src/tools/wg-quick.bash
+++ b/src/tools/wg-quick.bash
@@ -213,7 +213,7 @@ execute_hooks() {
cmd_usage() {
cat >&2 <<-_EOF
- Usage: $PROGRAM [ up | down ] [ CONFIG_FILE | INTERFACE ]
+ Usage: $PROGRAM [ up | down | save ] [ 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
@@ -264,6 +264,11 @@ cmd_down() {
execute_hooks "${POST_DOWN[@]}"
}
+cmd_save() {
+ [[ " $(wg show interfaces) " == *" $INTERFACE "* ]] || die "\`$INTERFACE' is not a WireGuard interface"
+ save_config
+}
+
# ~~ function override insertion point ~~
if [[ $# -eq 1 && ( $1 == --help || $1 == -h || $1 == help ) ]]; then
@@ -276,6 +281,10 @@ elif [[ $# -eq 2 && $1 == down ]]; then
auto_su
parse_options "$2"
cmd_down
+elif [[ $# -eq 2 && $1 == save ]]; then
+ auto_su
+ parse_options "$2"
+ cmd_save
else
cmd_usage
exit 1