diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-31 17:51:38 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-10-31 17:51:38 +0100 |
commit | eb181e811c674080a6cf54bd8ab260dd65ce0b3f (patch) | |
tree | f5561c8f7fd9a170b7bdcd05a959ec5d896a09f6 /src/wg-quick.bash | |
parent | contrib: add reresolve-dns (diff) | |
download | wireguard-tools-eb181e811c674080a6cf54bd8ab260dd65ce0b3f.tar.xz wireguard-tools-eb181e811c674080a6cf54bd8ab260dd65ce0b3f.zip |
wg-quick: allow for saving existing interface
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/wg-quick.bash')
-rwxr-xr-x | src/wg-quick.bash | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/wg-quick.bash b/src/wg-quick.bash index 17fe672..da4c0d4 100755 --- a/src/wg-quick.bash +++ b/src/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 |