Skip to content

Commit

Permalink
Prevent overwrite of config on multiple installs.
Browse files Browse the repository at this point in the history
* Fixes #4.
* Install now creates a docs location with the latest default example config.
* /etc/wireguard-initramfs/config is not modified if it exists.
  • Loading branch information
r-pufky committed Sep 27, 2022
1 parent 008b3fa commit 37d454d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

TARGETDIR = /etc/wireguard-initramfs
INITRAMFS = /etc/initramfs-tools
DOCSDIR = /usr/local/share/docs/wireguard-initramfs

help:
@echo "USAGE:"
Expand All @@ -13,6 +14,8 @@ help:
@echo " Remove wireguard-initramfs from initramfs, leaves "
@echo " $(TARGETDIR). Does not need to be installed."
@echo
@echo "Example configuration located at: $(DOCSDIR)"
@echo

.PHONY: help Makefile

Expand All @@ -23,14 +26,18 @@ install: remove_legacy
@mkdir -p "$(TARGETDIR)"
@touch "$(TARGETDIR)/private_key"
@chmod 0600 "$(TARGETDIR)/private_key"
@cp -v config "$(TARGETDIR)/config"
@cp -vn config "$(TARGETDIR)/config"
@chmod 0644 "$(TARGETDIR)/config"
@cp -v hooks "$(INITRAMFS)/hooks/wireguard"
@chmod 0755 hooks "$(INITRAMFS)/hooks/wireguard"
@cp -v init-premount "$(INITRAMFS)/scripts/init-premount/wireguard"
@chmod 0755 init-premount "$(INITRAMFS)/scripts/init-premount/wireguard"
@cp -v init-bottom "$(INITRAMFS)/scripts/init-bottom/wireguard"
@chmod 0755 init-bottom "$(INITRAMFS)/scripts/init-bottom/wireguard"
-@mkdir -p "$(DOCSDIR)/examples"
@chmod -R 0755 "$(DOCSDIR)"
@cp -v config "$(DOCSDIR)/examples/config"
@chmod 0644 "$(DOCSDIR)/examples/config"
@echo "Done."
@echo
@echo "Setup $(TARGETDIR)/config and run:"
Expand All @@ -45,6 +52,7 @@ uninstall: remove_legacy
@rm -f "$(INITRAMFS)/hooks/wireguard"
@rm -f "$(INITRAMFS)/scripts/init-premount/wireguard"
@rm -f "$(INITRAMFS)/scripts/init-bottom/wireguard"
@rm -rf "$(DOCSDIR)"
@echo
@echo "Done."

Expand Down
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# and compromised/untrusted. Boot wireguard network should be
# **different** & untrusted; versus the network used after booting.
# Always restrict ports and access on the wireguard server.
#
#
# Be sure to test wireguard config with a running system before setting
# options. See: https://manpages.debian.org/unstable/wireguard-tools/wg.8.en.html
#
Expand Down

0 comments on commit 37d454d

Please sign in to comment.