From 70691678b979750a8076354b1bf2c93d84dd2e65 Mon Sep 17 00:00:00 2001 From: Luis Ressel Date: Thu, 14 Mar 2019 00:36:22 +0100 Subject: 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 --- src/tools/wg-quick/linux.bash | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/tools/wg-quick/linux.bash') 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 -- cgit v1.2.3-59-g8ed1b