From 9867d4f23265fd9f61fb82e10bf055c45962f798 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Wed, 1 Jul 2026 16:51:44 +0100 Subject: [PATCH] pulls out openrc.mk --- Makefile | 55 +------------------------------------------------------ openrc.mk | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 openrc.mk diff --git a/Makefile b/Makefile index c1fee31..8160b55 100644 --- a/Makefile +++ b/Makefile @@ -66,25 +66,12 @@ install_$(module): install_openrc_$(module) $(nginx_module_target) $(dyndns_modu $(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) install) endef -define install_openrc_module_rule = -.PHONY: install_openrc_$(module) -install_openrc_$(module): $(openrc_module_target) openrc_add_$(module) openrc_start_$(module) - -~/.config/rc/init.d/joeac.net.$(module): ~/.config/rc/init.d/joeac.net ~/.config/rc/runlevels/default - ln -s $(shell realpath ~)/.config/rc/init.d/joeac.net ~/.config/rc/init.d/joeac.net.$(module) -endef - define reinstall_module_rule = .PHONY: reinstall_$(module) reinstall_$(module): reinstall_openrc_$(module) $(nginx_module_target) $(dyndns_module_target) $(install_submake_file) $(if $(install_submake_file),$(MAKE) --makefile=$(notdir $(install_submake_file)) --directory=$(dir $(install_submake_file)) reinstall) endef -define reinstall_openrc_module_rule = -.PHONY: reinstall_openrc_$(module) -reinstall_openrc_$(module): $(if $(openrc_module_target),$(openrc_module_target) openrc_restart_$(module)) -endef - define uninstall_module_rule = .PHONY: uninstall_$(module) uninstall_$(module): @@ -103,24 +90,6 @@ uninstall_$(module): ) endef -define openrc_add_rule = -.PHONY: openrc_add_$(module) -openrc_add_$(module): - rc-update -U add joeac.net.$(module) default -endef - -define openrc_start_rule = -.PHONY: openrc_start_$(module) -openrc_start_$(module): - rc-service -U joeac.net.$(module) start -endef - -define openrc_restart_rule = -.PHONY: openrc_restart_$(module) -openrc_restart_$(module): - rc-service -U joeac.net.$(module) restart -endef - ######### # RULES # @@ -158,30 +127,8 @@ uninstall: uninstall_nginx uninstall_dyndns uninstall_joeac.net_service $(foreac $(foreach module,$(MODULES),$(eval $(install_module_rule))) $(foreach module,$(MODULES),$(eval $(reinstall_module_rule))) $(foreach module,$(MODULES),$(eval $(uninstall_module_rule))) -$(foreach module,$(MODULES),$(eval $(install_openrc_module_rule))) -$(foreach module,$(MODULES),$(eval $(reinstall_openrc_module_rule))) -$(foreach module,$(MODULES),$(eval $(openrc_add_rule))) -$(foreach module,$(MODULES),$(eval $(openrc_start_rule))) -$(foreach module,$(MODULES),$(eval $(openrc_restart_rule))) - -~/.config/rc/init.d/joeac.net: openrc/init.d/joeac.net ~/.config/rc/init.d ~/.config/rc/runlevels/default /etc/init.d/user.$(shell whoami) /etc/conf.d/user.$(shell whoami) - rm -f ~/.config/rc/init.d/joeac.net; \ - mkdir -p ~/.config/rc/init.d; \ - cp openrc/init.d/joeac.net ~/.config/rc/init.d/joeac.net - -~/.config/rc/init.d: - mkdir -p ~/.config/rc/init.d - -~/.config/rc/runlevels/default: - mkdir -p ~/.config/rc/runlevels/default - -/etc/init.d/user.$(shell whoami): - sudo ln -s /etc/init.d/user /etc/init.d/user.$(shell whoami) - -/etc/conf.d/user.$(shell whoami): openrc/conf.d/user.$(shell whoami) - sudo cp openrc/conf.d/user.$(shell whoami) /etc/conf.d/user.$(shell whoami) - sudo rc-update add user.$(shell whoami) default +include openrc.mk include nginx.mk include crontab.mk include dyndns.mk diff --git a/openrc.mk b/openrc.mk new file mode 100644 index 0000000..975d119 --- /dev/null +++ b/openrc.mk @@ -0,0 +1,54 @@ +define install_openrc_module_rule = +.PHONY: install_openrc_$(module) +install_openrc_$(module): $(openrc_module_target) openrc_add_$(module) openrc_start_$(module) + +~/.config/rc/init.d/joeac.net.$(module): ~/.config/rc/init.d/joeac.net ~/.config/rc/runlevels/default + ln -s $(shell realpath ~)/.config/rc/init.d/joeac.net ~/.config/rc/init.d/joeac.net.$(module) +endef + +define reinstall_openrc_module_rule = +.PHONY: reinstall_openrc_$(module) +reinstall_openrc_$(module): $(if $(openrc_module_target),$(openrc_module_target) openrc_restart_$(module)) +endef + +define openrc_add_rule = +.PHONY: openrc_add_$(module) +openrc_add_$(module): + rc-update -U add joeac.net.$(module) default +endef + +define openrc_start_rule = +.PHONY: openrc_start_$(module) +openrc_start_$(module): + rc-service -U joeac.net.$(module) start +endef + +define openrc_restart_rule = +.PHONY: openrc_restart_$(module) +openrc_restart_$(module): + rc-service -U joeac.net.$(module) restart +endef + +$(foreach module,$(MODULES),$(eval $(install_openrc_module_rule))) +$(foreach module,$(MODULES),$(eval $(reinstall_openrc_module_rule))) +$(foreach module,$(MODULES),$(eval $(openrc_add_rule))) +$(foreach module,$(MODULES),$(eval $(openrc_start_rule))) +$(foreach module,$(MODULES),$(eval $(openrc_restart_rule))) + +~/.config/rc/init.d/joeac.net: openrc/init.d/joeac.net ~/.config/rc/init.d ~/.config/rc/runlevels/default /etc/init.d/user.$(shell whoami) /etc/conf.d/user.$(shell whoami) + rm -f ~/.config/rc/init.d/joeac.net; \ + mkdir -p ~/.config/rc/init.d; \ + cp openrc/init.d/joeac.net ~/.config/rc/init.d/joeac.net + +~/.config/rc/init.d: + mkdir -p ~/.config/rc/init.d + +~/.config/rc/runlevels/default: + mkdir -p ~/.config/rc/runlevels/default + +/etc/init.d/user.$(shell whoami): + sudo ln -s /etc/init.d/user /etc/init.d/user.$(shell whoami) + +/etc/conf.d/user.$(shell whoami): openrc/conf.d/user.$(shell whoami) + sudo cp openrc/conf.d/user.$(shell whoami) /etc/conf.d/user.$(shell whoami) + sudo rc-update add user.$(shell whoami) default