router/makefile
2023-07-17 18:09:47 +00:00

79 lines
1.9 KiB
Makefile

# TODO: some kind of automatic (without confirmation) rollback setup?
.PHONY: default
default: copy-configuration-files restart-services
.PHONY: setup
setup: system-dependencies /root/router.wg-pub enable-and-start-services mkinitcpio
.PHONY: mkinitcpio
mkinitcpio:
mkinitcpio -p linux
.PHONY: system-dependencies
system-dependencies:
pacman -Sy --needed archlinux-keyring # get latest keys
pacman -Syu # update everything
pacman -S --needed dnsmasq nftables fail2ban radvd git dhcpcd wireguard-tools # install anything needed
.PHONY: restart-services
restart-services:
systemctl restart nftables
systemctl restart systemd-sysctl
systemctl restart systemd-networkd
systemctl restart dnsmasq
systemctl restart systemd-resolved
systemctl restart dhcpcd@lan0
systemctl restart dhcpcd@wan0
.PHONY: enable-and-start-services
enable-and-start-services:
systemctl enable --now nftables
systemctl enable --now systemd-sysctl
systemctl enable --now systemd-networkd
systemctl enable --now dnsmasq
systemctl enable --now systemd-resolved
systemctl enable --now dhcpcd@lan0
systemctl enable --now dhcpcd@wan0
.PHONY: copy-configuration-files
copy-configuration-files: /etc/dnsmasq.conf /etc/systemd/resolved.conf /etc/sysctl.d/10-router-configs.conf /etc/systemd/network/10-lan0.link /etc/systemd/network/10-wan0.link /etc/dhcpcd.conf /etc/hosts
/root/router.wg-key:
umask 0077 && wg genkey > $@
/root/router.wg-pub: /root/router.wg-key
umask 0077 && cat $^ wg genkey > $@
/etc/dnsmasq.conf: dnsmasq.conf
rm -f $@
cp $^ $@
/etc/systemd/resolved.conf: resolved.conf
rm -f $@
cp $^ $@
/etc/sysctl.d/10-router-configs.conf: sysctl-configs
rm -f $@
cp $^ $@
/etc/systemd/network/10-lan0.link: lan0.link
rm -f $@
cp $^ $@
/etc/systemd/network/10-wan0.link: wan0.link
rm -f $@
cp $^ $@
/etc/dhcpcd.conf: dhcpcd.conf
rm -f $@
cp $^ $@
/etc/hosts: ./etc-hosts
rm -f $@
cp $^ $@
/etc/nftables.conf: nftables.conf
rm -f $@
cp $^ $@