diff options
author | Luis Ressel <aranea@aixah.de> | 2019-03-14 00:36:22 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-03-23 12:49:48 +0100 |
commit | 70691678b979750a8076354b1bf2c93d84dd2e65 (patch) | |
tree | e316d08e4e9b4def56b6c108fd9b2b85b8509613 /src/tools/wg-quick | |
parent | tools: warn if an AllowedIP has a nonzero host part (diff) | |
download | wireguard-monolithic-historical-70691678b979750a8076354b1bf2c93d84dd2e65.tar.xz wireguard-monolithic-historical-70691678b979750a8076354b1bf2c93d84dd2e65.zip |
wg-quick: add 'strip' subcommand
`wg-quick strip` prints the config file to stdout after stripping it of
all wg-quick-specific options.
This enables tricks such as `wg addconf $DEV <(wg-quick strip $DEV)`.
Signed-off-by: Luis Ressel <aranea@aixah.de>
Diffstat (limited to 'src/tools/wg-quick')
-rwxr-xr-x | src/tools/wg-quick/darwin.bash | 10 | ||||
-rwxr-xr-x | src/tools/wg-quick/freebsd.bash | 10 | ||||
-rwxr-xr-x | src/tools/wg-quick/linux.bash | 10 | ||||
-rwxr-xr-x | src/tools/wg-quick/openbsd.bash | 10 |
4 files changed, 36 insertions, 4 deletions
diff --git a/src/tools/wg-quick/darwin.bash b/src/tools/wg-quick/darwin.bash index bf07fdb..aa3edeb 100755 --- a/src/tools/wg-quick/darwin.bash +++ b/src/tools/wg-quick/darwin.bash @@ -385,7 +385,7 @@ execute_hooks() { cmd_usage() { cat >&2 <<-_EOF - Usage: $PROGRAM [ up | down | save ] [ CONFIG_FILE | INTERFACE ] + Usage: $PROGRAM [ up | down | 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 @@ -452,6 +452,10 @@ cmd_save() { save_config } +cmd_strip() { + echo "$WG_CONFIG" +} + # ~~ function override insertion point ~~ if [[ $# -eq 1 && ( $1 == --help || $1 == -h || $1 == help ) ]]; then @@ -468,6 +472,10 @@ elif [[ $# -eq 2 && $1 == save ]]; then auto_su parse_options "$2" cmd_save +elif [[ $# -eq 2 && $1 == strip ]]; then + auto_su + parse_options "$2" + cmd_strip else cmd_usage exit 1 diff --git a/src/tools/wg-quick/freebsd.bash b/src/tools/wg-quick/freebsd.bash index c3fa47a..9d3a402 100755 --- a/src/tools/wg-quick/freebsd.bash +++ b/src/tools/wg-quick/freebsd.bash @@ -368,7 +368,7 @@ execute_hooks() { cmd_usage() { cat >&2 <<-_EOF - Usage: $PROGRAM [ up | down | save ] [ CONFIG_FILE | INTERFACE ] + Usage: $PROGRAM [ up | down | 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 @@ -431,6 +431,10 @@ cmd_save() { save_config } +cmd_strip() { + echo "$WG_CONFIG" +} + # ~~ function override insertion point ~~ make_temp @@ -450,6 +454,10 @@ elif [[ $# -eq 2 && $1 == save ]]; then auto_su parse_options "$2" cmd_save +elif [[ $# -eq 2 && $1 == strip ]]; then + auto_su + parse_options "$2" + cmd_strip else cmd_usage exit 1 diff --git a/src/tools/wg-quick/linux.bash b/src/tools/wg-quick/linux.bash index 84643c4..5eaa504 100755 --- a/src/tools/wg-quick/linux.bash +++ b/src/tools/wg-quick/linux.bash @@ -247,7 +247,7 @@ execute_hooks() { cmd_usage() { cat >&2 <<-_EOF - Usage: $PROGRAM [ up | down | save ] [ CONFIG_FILE | INTERFACE ] + Usage: $PROGRAM [ up | down | 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 @@ -305,6 +305,10 @@ cmd_save() { save_config } +cmd_strip() { + echo "$WG_CONFIG" +} + # ~~ function override insertion point ~~ if [[ $# -eq 1 && ( $1 == --help || $1 == -h || $1 == help ) ]]; then @@ -321,6 +325,10 @@ elif [[ $# -eq 2 && $1 == save ]]; then auto_su parse_options "$2" cmd_save +elif [[ $# -eq 2 && $1 == strip ]]; then + auto_su + parse_options "$2" + cmd_strip else cmd_usage exit 1 diff --git a/src/tools/wg-quick/openbsd.bash b/src/tools/wg-quick/openbsd.bash index 9996162..b234609 100755 --- a/src/tools/wg-quick/openbsd.bash +++ b/src/tools/wg-quick/openbsd.bash @@ -361,7 +361,7 @@ execute_hooks() { cmd_usage() { cat >&2 <<-_EOF - Usage: $PROGRAM [ up | down | save ] [ CONFIG_FILE | INTERFACE ] + Usage: $PROGRAM [ up | down | 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 @@ -426,6 +426,10 @@ cmd_save() { save_config } +cmd_strip() { + echo "$WG_CONFIG" +} + # ~~ function override insertion point ~~ if [[ $# -eq 1 && ( $1 == --help || $1 == -h || $1 == help ) ]]; then @@ -442,6 +446,10 @@ elif [[ $# -eq 2 && $1 == save ]]; then auto_su parse_options "$2" cmd_save +elif [[ $# -eq 2 && $1 == strip ]]; then + auto_su + parse_options "$2" + cmd_strip else cmd_usage exit 1 |