summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-10-31 19:47:39 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-11-01 00:55:19 +0100
commit6be9a662b2d549a0c7fa6f0b18c16f126c7114a7 (patch)
tree38628b7eda0f58f2e51f789910604f0b02119bfe /src/tools
parentversion: bump snapshot (diff)
downloadwireguard-monolithic-historical-6be9a662b2d549a0c7fa6f0b18c16f126c7114a7.tar.xz
wireguard-monolithic-historical-6be9a662b2d549a0c7fa6f0b18c16f126c7114a7.zip
wg-quick: save all hooks on save
Diffstat (limited to 'src/tools')
-rwxr-xr-xsrc/tools/wg-quick.bash18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/tools/wg-quick.bash b/src/tools/wg-quick.bash
index 7dc8be1..88e671f 100755
--- a/src/tools/wg-quick.bash
+++ b/src/tools/wg-quick.bash
@@ -177,7 +177,7 @@ set_config() {
}
save_config() {
- local old_umask new_config current_config address
+ local old_umask new_config current_config address cmd
[[ $(ip -all -brief address show dev "$INTERFACE") =~ ^$INTERFACE\ +\ [A-Z]+\ +(.+)$ ]] || true
new_config=$'[Interface]\n'
for address in ${BASH_REMATCH[1]}; do
@@ -188,10 +188,18 @@ save_config() {
done < <(resolvconf -l "tun.$INTERFACE" 2>/dev/null)
[[ -n $MTU && $(ip link show dev "$INTERFACE") =~ mtu\ ([0-9]+) ]] && new_config+="MTU = ${BASH_REMATCH[1]}"$'\n'
[[ $SAVE_CONFIG -eq 0 ]] || new_config+=$'SaveConfig = true\n'
- [[ -z $PRE_UP ]] || new_config+="PreUp = $PRE_UP"$'\n'
- [[ -z $POST_UP ]] || new_config+="PostUp = $POST_UP"$'\n'
- [[ -z $PRE_DOWN ]] || new_config+="PreDown = $PRE_DOWN"$'\n'
- [[ -z $POST_DOWN ]] || new_config+="PostDown = $POST_DOWN"$'\n'
+ for cmd in "${PRE_UP[@]}"; do
+ new_config+="PreUp = $cmd"$'\n'
+ done
+ for cmd in "${POST_UP[@]}"; do
+ new_config+="PostUp = $cmd"$'\n'
+ done
+ for cmd in "${PRE_DOWN[@]}"; do
+ new_config+="PreDown = $cmd"$'\n'
+ done
+ for cmd in "${POST_DOWN[@]}"; do
+ new_config+="PostDown = $cmd"$'\n'
+ done
old_umask="$(umask)"
umask 077
current_config="$(cmd wg showconf "$INTERFACE")"