summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-05-24 11:36:57 -0400
committerAndrew Cady <d@jerkface.net>2023-05-24 11:36:57 -0400
commit52226dcff6a100a9a816c6c3978729e08ad15fd6 (patch)
tree1f15232af86b9c6e689205ec227c3499088f7dda
parentc8daee10060554d1692e808c040c1f4263fab361 (diff)
cleanup makefile
-rw-r--r--Makefile28
1 files changed, 21 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 03387dd..d812c9b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,18 +1,32 @@
1config_dir = /etc/btrfs-backup/remotes 1config_dir = /etc/btrfs-backup/remotes
2remotes = $(notdir $(wildcard $(config_dir)/*.json)) 2main_unit_name = push-btrfs
3 3remotes = $(notdir $(basename $(wildcard $(config_dir)/*.json)))
4timers = $(addprefix $(main_unit_name)@, $(addsuffix .timer, $(remotes)))
5services = $(addprefix $(main_unit_name)@, $(addsuffix .service, $(remotes)))
4ifeq ($(remotes),) 6ifeq ($(remotes),)
5$(error You must put at least one *.json configuration file into <file:///$(config_dir)>). 7$(error You must put at least one *.json configuration file into <file:///$(config_dir)>).
6endif 8endif
7 9enable_unit = $(main_unit_name).timer
8unit_files = $(wildcard src/*.service src/*.timer) 10unit_files = $(wildcard src/*.service src/*.timer)
11plain_units = $(enable_unit) $(shell printf '%s\n' $(notdir $(unit_files)) | grep -v '@')
12template_units = $(timers) $(services)
13units = $(plain_units) $(template_units)
14
15
16
9 17
10enable_unit = push-btrfs.timer
11 18
12install: 19install:
13 systemctl link $(addprefix ./, $(unit_files)) 20 systemctl link $(addprefix ./, $(unit_files))
14 systemctl reset-failed $(notdir $(enable_unit)) 21 systemctl reset-failed $(units)
15 systemctl enable --now $(notdir $(enable_unit)) 22 systemctl enable --now $(enable_unit)
23
24status start stop restart:
25 systemctl $@ $(units)
26
27
28
29
16 30
17go: 31go:
18 for remote in $(remotes); do bash$(if $(verbose), -x) push-btrfs $$remote$(if $(verbose),;, &) done; wait 32 for remote in $(remotes); do bash$(if $(verbose), -x) $(main_unit_name) $$remote$(if $(verbose),;, &) done; wait