generate local keys

This commit is contained in:
2026-03-02 17:55:15 +01:00
parent 29a2aa6da9
commit ccdb380b50
2 changed files with 17 additions and 15 deletions

25
wg.mk
View File

@@ -1,21 +1,22 @@
public_key = $(shell cat /etc/wireguard/dmz_public_key)
name := $(shell git config list | grep user.nam | cut -d= -f2)
wgkeys.rec: /etc/wireguard/dmz_public_key
recins $@ -t $(basename $@) -f name -v "$(name)" -f pubkey -v "$(public_key)"
/etc/wireguard/dmz.conf: xecut/nimbus/wireguard_client.conf | /etc/wireguard/dmz_private_key
sed 's/PRIVATE_KEY/$(shell cat $|)/' $< > $@
# Local keys
/etc/wireguard/dmz_private_key: | /bin/wg
$| genkey > $@
wireguard/dmz_private_key: | /bin/wg wireguard/
wg genkey > $@
chmod 700 $@
ansible/host_vars/local_host.yml: wgkeys.rec
recsel $< -t $(basename $<) -e 'name = "$(name)"' -P pubkey
/etc/wireguard/dmz_public_key: /etc/wireguard/dmz_private_key | /bin/wg
wireguard/dmz_public_key: wireguard/dmz_private_key | /bin/wg
$| pubkey < $< > $@
.PHONY: wgkeys
wgkeys: /etc/wireguard/dmz.conf ## Create dmz-keys on your machine for wiregurd.
##############################
wgkeys.rec: wireguard/dmz_public_key
$(info Adding wireguard key as '$(name)')
recins --verbose $@ -t $(basename $@) -f name -v '$(name)' -f pubkey -v '$(shell cat $<)'
git add $@
git commit -m"add wireguard key for $(name)"
$(info Remember to git push)