diff --git a/wireguard/assets/root/templates/wg0-client.tpl b/wireguard/assets/root/templates/client.tpl similarity index 100% rename from wireguard/assets/root/templates/wg0-client.tpl rename to wireguard/assets/root/templates/client.tpl diff --git a/wireguard/assets/root/templates/wg0.conf b/wireguard/assets/root/templates/server.conf similarity index 100% rename from wireguard/assets/root/templates/wg0.conf rename to wireguard/assets/root/templates/server.conf diff --git a/wireguard/make.sh b/wireguard/make.sh index 9ce98e6..a11aad5 100755 --- a/wireguard/make.sh +++ b/wireguard/make.sh @@ -57,6 +57,7 @@ DNS=${DNS/\/*} xread "Local network DNS:" DNS xreadYes "Show profile as QRcode when done?" QRCODE +QRCODE=${QRCODE:-0} readVars diff --git a/wireguard/templates/root/Makefile b/wireguard/templates/root/Makefile index 1f55bd1..3c21c6e 100644 --- a/wireguard/templates/root/Makefile +++ b/wireguard/templates/root/Makefile @@ -1,10 +1,10 @@ - +INTERFACE := wg0 SERVER_DIR := /etc/wireguard/ -SERVER_TPL := templates/wg0.conf -SERVER_CLIENT_TPL := templates/wg0-client.tpl -SERVER_CONF := $(SERVER_DIR)/wg0.conf +SERVER_TPL := templates/server.conf +SERVER_CLIENT_TPL := templates/client.tpl +SERVER_CONF := $(SERVER_DIR)/$(INTERFACE).conf SERVER_KEY := $(SERVER_DIR)/server_id SERVER_PUBLIC_KEY := $(SERVER_DIR)/server_id.pub @@ -64,8 +64,9 @@ $(SERVER_CONF): $(SERVER_TPL) $(SERVER_KEY) -e 's/\$${\CLIENT_PUBLIC_KEY}/'$$(sed -e 's/\//\\\//g' "$(CLIENT_DIR)/$*_id.pub")'/g' \ -e 's/\$${\SERVER_PUBLIC_KEY}/'$$(sed -e 's/\//\\\//g' "$(SERVER_PUBLIC_KEY)")'/g' \ >> "$(SERVER_CONF)" - @ [ -z "$$QRCODE" ] \ - || ( echo "# Profile: $*" \ + make update + @ [ "$(QRCODE)" == "1" ] \ + && ( echo "# Profile: $*" \ && qrencode -t UTF8 -r "$(CLIENT_DIR)/$*.conf" ) @@ -78,4 +79,8 @@ $(SERVER_CONF): $(SERVER_TPL) $(SERVER_KEY) server: $(SERVER_CONF) +update: + wg syncconf $(INTERFACE) <(wg-quick strip $(INTERFACE)) + +