-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (33 loc) · 1.01 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
top:; @date
SHELL := /bin/bash -o pipefail
Makefile:;
include loghost.mk
h := .hashdeep
s := .sig-$(USER)
b := /space/remote_logs
rsync = rsync -aCv
get: $h $s; mkdir -p $^; echo $^ | xargs -n1 | xargs -i $(rsync) $(DRY) root@$(loghost):$b/{} .
put:; $(rsync) $(DRY) --exclude '*$h' $h/ root@$(loghost):$b/$s
month != date +%Y-%m
match ?= $(month)
hashdeep := $(wildcard $h/*$h)
ascsig := $(hashdeep:%=%.asc)
sig: $(ascsig)
chk: $(hashdeep); @echo $^ | xargs -n1 | grep $(match) | xargs -i gpg --verify {}.asc {}
cmp: $(ascsig); @echo $(^:$h/%=%) | xargs -n1 | xargs -i cmp $h/{} $s/{}
$h/%.asc: $h/%; test -f $@ || gpg -ba $< && chmod 444 $@
main := get sig put chk
main: $(main)
cmp := put cmp
full: $(main) $(cmp)
mk := hashdeep_space_remote_log.mk
rmk := /usr/local/bin/$(mk)
sync:; $(rsync) $(RUN) root@$(loghost):$(rmk) .
init:; $(rsync) $(RUN) $(mk) root@$(loghost):$(rmk)
RUN := -n
run := RUN :=
DRY :=
dry := DRY := -n
vartar := dry run
$(vartar):; @: $(eval $($@))
.PHONY: top $(main) cmp sync init $(vartar)