pulls out more dyndns stuff to dyndns.mk
This commit is contained in:
@@ -5,8 +5,10 @@ include config.mk
|
|||||||
#############
|
#############
|
||||||
|
|
||||||
HOSTNAME := $(shell cat /etc/hostname)
|
HOSTNAME := $(shell cat /etc/hostname)
|
||||||
|
HOSTNAMES := pi-broughton blade-canongate
|
||||||
MODULES_pi-broughton := http gemini smtp vaultwarden ln
|
MODULES_pi-broughton := http gemini smtp vaultwarden ln
|
||||||
MODULES_blade-canongate := etherpad
|
MODULES_blade-canongate := etherpad
|
||||||
|
ALL_MODULES := $(sort $(foreach hostname,$(HOSTNAMES),$(MODULES_$(hostname))))
|
||||||
MASTER_NODE := pi-broughton
|
MASTER_NODE := pi-broughton
|
||||||
IS_MASTER_NODE := $(filter $(MASTER_NODE),$(HOSTNAME))
|
IS_MASTER_NODE := $(filter $(MASTER_NODE),$(HOSTNAME))
|
||||||
MODULES := $(MODULES_$(HOSTNAME))
|
MODULES := $(MODULES_$(HOSTNAME))
|
||||||
@@ -21,7 +23,6 @@ MAKE_MODULES := $(foreach module,$(MODULES),\
|
|||||||
# FUNCTIONS #
|
# FUNCTIONS #
|
||||||
#############
|
#############
|
||||||
|
|
||||||
dyndns_module_target = $(if $(SUBDOMAIN_$(module)),/etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net)
|
|
||||||
openrc_module_target = $(if $(filter $(COMPOSE_SERVICES),$(module)),~/.config/rc/init.d/joeac.net.$(module))
|
openrc_module_target = $(if $(filter $(COMPOSE_SERVICES),$(module)),~/.config/rc/init.d/joeac.net.$(module))
|
||||||
install_submake_file = $(shell [ -f "$(module)/install.mk" ] && echo "$(module)/install.mk")
|
install_submake_file = $(shell [ -f "$(module)/install.mk" ] && echo "$(module)/install.mk")
|
||||||
|
|
||||||
@@ -38,13 +39,13 @@ endef
|
|||||||
|
|
||||||
define install_module_rule =
|
define install_module_rule =
|
||||||
.PHONY: install_$(module)
|
.PHONY: install_$(module)
|
||||||
install_$(module): install_openrc_$(module) install_nginx_module_$(module) $(dyndns_module_target) $(install_submake_file)
|
install_$(module): install_openrc_$(module) install_nginx_module_$(module) install_dyndns_module_$(module) $(install_submake_file)
|
||||||
$(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) install)
|
$(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) install)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define reinstall_module_rule =
|
define reinstall_module_rule =
|
||||||
.PHONY: reinstall_$(module)
|
.PHONY: reinstall_$(module)
|
||||||
reinstall_$(module): reinstall_openrc_$(module) reinstall_nginx_module_$(module) $(dyndns_module_target) $(install_submake_file)
|
reinstall_$(module): reinstall_openrc_$(module) reinstall_nginx_module_$(module) reinstall_dyndns_module_$(module) $(install_submake_file)
|
||||||
$(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) reinstall)
|
$(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) reinstall)
|
||||||
endef
|
endef
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,34 @@
|
|||||||
.PHONY: install_dyndns
|
define install_dyndns_module_rule =
|
||||||
install_dyndns: /usr/local/bin/dyndns.sh ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
.PHONY: install_dyndns_module_$(module)
|
||||||
|
install_dyndns_module_$(module): $(if $(SUBDOMAIN_$(module)),/etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net install_dyndns)
|
||||||
|
endef
|
||||||
|
|
||||||
.PHONY: reinstall_dyndns
|
define reinstall_dyndns_module_rule =
|
||||||
reinstall_dyndns: /usr/local/bin/dyndns.sh ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
.PHONY: reinstall_dyndns_module_$(module)
|
||||||
|
reinstall_dyndns_module_$(module): $(if $(SUBDOMAIN_$(module)),/etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net reinstall_dyndns)
|
||||||
|
endef
|
||||||
|
|
||||||
|
define uninstall_dyndns_module_rule =
|
||||||
|
.PHONY: uninstall_dyndns_module_$(module)
|
||||||
|
uninstall_dyndns_module_$(module):
|
||||||
|
$(if $(SUBDOMAIN_$(module)), \
|
||||||
|
rm -f /etc/periodic/daily/dyndns-$(SUBDOMAIN_$(module)).joeac.net
|
||||||
|
)
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(foreach module,$(ALL_MODULES), $(eval $(install_dyndns_module_rule)))
|
||||||
|
$(foreach module,$(ALL_MODULES), $(eval $(reinstall_dyndns_module_rule)))
|
||||||
|
$(foreach module,$(ALL_MODULES), $(eval $(uninstall_dyndns_module_rule)))
|
||||||
|
|
||||||
|
/etc/periodic/daily/dyndns-%joeac.net: /usr/local/bin/dyndns.sh ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
||||||
|
echo "#!/bin/sh" > crontab.tmp
|
||||||
|
echo " /usr/local/bin/dyndns.sh 4 $(*F)joeac.net" >> crontab.tmp
|
||||||
|
echo "CONN_DEVICE_NAME=eth0 /usr/local/bin/dyndns.sh 6 $(*F)joeac.net" >> crontab.tmp
|
||||||
|
sudo mv crontab.tmp $@
|
||||||
|
sudo chmod +x $@
|
||||||
|
|
||||||
.PHONY: uninstall_dyndns
|
.PHONY: uninstall_dyndns
|
||||||
uninstall_dyndns:
|
uninstall_dyndns: $(foreach module,$(ALL_MODULES),$(uninstall_dyndns_module_rule))
|
||||||
sudo rm -rf \
|
sudo rm -rf \
|
||||||
/usr/local/bin/dyndns.sh \
|
/usr/local/bin/dyndns.sh \
|
||||||
/usr/local/bin/get_ip_addr.sh \
|
/usr/local/bin/get_ip_addr.sh \
|
||||||
@@ -29,10 +52,3 @@ uninstall_dyndns:
|
|||||||
mkdir -p ~/.config/dyndns/
|
mkdir -p ~/.config/dyndns/
|
||||||
rm -f ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
rm -f ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
||||||
cp DIGITALOCEAN_TOKEN ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
cp DIGITALOCEAN_TOKEN ~/.config/dyndns/DIGITALOCEAN_TOKEN
|
||||||
|
|
||||||
/etc/periodic/daily/dyndns-%joeac.net: /usr/local/bin/dyndns.sh
|
|
||||||
echo "#!/bin/sh" > crontab.tmp
|
|
||||||
echo " /usr/local/bin/dyndns.sh 4 $(*F)joeac.net" >> crontab.tmp
|
|
||||||
echo "CONN_DEVICE_NAME=eth0 /usr/local/bin/dyndns.sh 6 $(*F)joeac.net" >> crontab.tmp
|
|
||||||
sudo mv crontab.tmp $@
|
|
||||||
sudo chmod +x $@
|
|
||||||
|
|||||||
Reference in New Issue
Block a user