.I up
|
.I down
+|
+.I save
] [
.I CONFIG_FILE
|
an interface. Running \fIup\fP adds a WireGuard interface, brings up the interface with the
supplied IP addresses, sets up mtu and routes, and optionally runs pre/post up scripts. Running \fIdown\fP
optionally saves the current configuration, removes the WireGuard interface, and optionally
-runs pre/post down scripts.
+runs pre/post down scripts. Running \fIsave\fP saves the configuration of an existing
+interface without bringing the interface down.
\fICONFIG_FILE\fP is a configuration file, whose filename is the interface name
followed by `.conf'. Otherwise, \fIINTERFACE\fP is an interface name, with configuration
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
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
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