diff options
author | Andrew Cady <d@jerkface.net> | 2023-05-24 11:36:57 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2023-05-24 11:36:57 -0400 |
commit | 52226dcff6a100a9a816c6c3978729e08ad15fd6 (patch) | |
tree | 1f15232af86b9c6e689205ec227c3499088f7dda | |
parent | c8daee10060554d1692e808c040c1f4263fab361 (diff) |
cleanup makefile
-rw-r--r-- | Makefile | 28 |
1 files changed, 21 insertions, 7 deletions
@@ -1,18 +1,32 @@ | |||
1 | config_dir = /etc/btrfs-backup/remotes | 1 | config_dir = /etc/btrfs-backup/remotes |
2 | remotes = $(notdir $(wildcard $(config_dir)/*.json)) | 2 | main_unit_name = push-btrfs |
3 | 3 | remotes = $(notdir $(basename $(wildcard $(config_dir)/*.json))) | |
4 | timers = $(addprefix $(main_unit_name)@, $(addsuffix .timer, $(remotes))) | ||
5 | services = $(addprefix $(main_unit_name)@, $(addsuffix .service, $(remotes))) | ||
4 | ifeq ($(remotes),) | 6 | ifeq ($(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)>). |
6 | endif | 8 | endif |
7 | 9 | enable_unit = $(main_unit_name).timer | |
8 | unit_files = $(wildcard src/*.service src/*.timer) | 10 | unit_files = $(wildcard src/*.service src/*.timer) |
11 | plain_units = $(enable_unit) $(shell printf '%s\n' $(notdir $(unit_files)) | grep -v '@') | ||
12 | template_units = $(timers) $(services) | ||
13 | units = $(plain_units) $(template_units) | ||
14 | |||
15 | |||
16 | |||
9 | 17 | ||
10 | enable_unit = push-btrfs.timer | ||
11 | 18 | ||
12 | install: | 19 | install: |
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 | |||
24 | status start stop restart: | ||
25 | systemctl $@ $(units) | ||
26 | |||
27 | |||
28 | |||
29 | |||
16 | 30 | ||
17 | go: | 31 | go: |
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 |