Browse Source

wg-installer: create wireguard key if it does not exist

Check if the key exists which is given by
    option wg_key '/etc/wgserver/wg.key'

Signed-off-by: Nick Hainke <vincent@systemli.org>
lilik-openwrt-22.03
Nick Hainke 3 years ago
parent
commit
324fa79d7c
2 changed files with 6 additions and 3 deletions
  1. +3
    -3
      net/wg-installer/Makefile
  2. +3
    -0
      net/wg-installer/wg-server/lib/wg_functions.sh

+ 3
- 3
net/wg-installer/Makefile View File

@ -22,7 +22,7 @@ define Package/wg-installer-server
$(call Package/wg-installer/Default) $(call Package/wg-installer/Default)
TITLE+= (server) TITLE+= (server)
MENU:=1 MENU:=1
DEPENDS+=+rpcd +uhttpd +uhttpd-mod-ubus
DEPENDS+=+rpcd +uhttpd +uhttpd-mod-ubus +coreutils-dirname
endef endef
define Package/wg-installer-server/install define Package/wg-installer-server/install
@ -57,7 +57,7 @@ endef
define Package/wg-installer-server-hotplug-babeld define Package/wg-installer-server-hotplug-babeld
$(call Package/wg-installer-server) $(call Package/wg-installer-server)
DEPENDS:=wg-installer-server +coreutils-dirname +coreutils-realpath
DEPENDS:=wg-installer-server +coreutils-realpath
endef endef
define Package/wg-installer-server-hotplug-babeld/install define Package/wg-installer-server-hotplug-babeld/install
@ -67,7 +67,7 @@ endef
define Package/wg-installer-server-hotplug-olsrd define Package/wg-installer-server-hotplug-olsrd
$(call Package/wg-installer-server) $(call Package/wg-installer-server)
DEPENDS:=wg-installer-server +coreutils-dirname +coreutils-realpath
DEPENDS:=wg-installer-server +coreutils-realpath
endef endef
define Package/wg-installer-server-hotplug-olsrd/install define Package/wg-installer-server-hotplug-olsrd/install


+ 3
- 0
net/wg-installer/wg-server/lib/wg_functions.sh View File

@ -75,6 +75,9 @@ wg_register () {
gw_key="/tmp/run/wgserver/${ifname}.key" gw_key="/tmp/run/wgserver/${ifname}.key"
gw_pub="/tmp/run/wgserver/${ifname}.pub" gw_pub="/tmp/run/wgserver/${ifname}.pub"
wg genkey | tee "$gw_key" | wg pubkey > "$gw_pub" wg genkey | tee "$gw_key" | wg pubkey > "$gw_pub"
else
[ -d "$(dirname $gw_key)" ] || mkdir -p "$(dirname $gw_key)"
[ -f "$gw_key" ] || wg genkey | tee "$gw_key" | wg pubkey > "$gw_pub"
fi fi
wg_server_pubkey=$(cat "$gw_pub") wg_server_pubkey=$(cat "$gw_pub")


Loading…
Cancel
Save