forked from r-pufky/wireguard-initramfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
56 lines (50 loc) · 1.98 KB
/
Makefile
File metadata and controls
56 lines (50 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Makefile for wireguard initramfs boot.
# You can set these variables from the command line, and also
# from the environment for the first two.
TARGETDIR = /etc/wireguard-initramfs
INITRAMFS = /etc/initramfs-tools
help:
@echo "USAGE:"
@echo " make install"
@echo " Install wireguard-initramfs and default configuration files."
@echo " Requires additional configuration!"
@echo
@echo " make uninstall"
@echo " Remove wireguard-initramfs from initramfs, leaves "
@echo " $(TARGETDIR). Does not need to be installed."
@echo
.PHONY: help Makefile
install: remove_legacy
@if ! [ "$(shell id -u)" = 0 ]; then echo "You must be root to perform this action."; exit 1; fi
@echo "Installing wireguard-initramfs ..."
@apt update && apt install initramfs-tools
@mkdir -p "$(TARGETDIR)"
@touch "$(TARGETDIR)/private_key"
@chmod 0600 "$(TARGETDIR)/private_key"
@cp -v 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"
@echo "Done."
@echo
@echo "Setup $(TARGETDIR)/config and run:"
@echo
@echo " update-initramfs -u && update-grub"
@echo
@echo "Done."
uninstall: remove_legacy
@if ! [ "$(shell id -u)" = 0 ]; then echo "You must be root to perform this action."; exit 1; fi
@echo "Uninstalling wireguard-initramfs ..."
@rm -f "$(INITRAMFS)/hooks/wireguard"
@rm -f "$(INITRAMFS)/scripts/init-premount/wireguard"
@rm -f "$(INITRAMFS)/scripts/init-bottom/wireguard"
@echo
@echo "Done."
remove_legacy:
@rm -f "/usr/share/initramfs-tools/hooks/wireguard"
@rm -f "/usr/share/initramfs-tools/scripts/init-premount/wireguard"
@rm -f "/usr/share/initramfs-tools/scripts/init-bottom/wireguard"