summaryrefslogtreecommitdiff
path: root/Makefile
blob: 19b715885a58e8edc6c8f28d7788d3642f321c6d (plain)
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
all: control equivs-stamp

include src/equivs.mk

control_files = $(wildcard control.d/*.control)

control: src/control.sh $(control_files) .git/refs/heads/master
	./src/control.sh $(control_files) > $@

DD_USER = dyndns
DD_GROUP = dyndns

.PHONY: install all

prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin

scripts = samizdat-ssh-command cryptonomic-dyndns-command
executables = $(addprefix src/, $(scripts))

install: equivs-stamp $(executables)
ifneq ($(shell id -u),0)
	@sudo $(MAKE) MAKEFLAGS=$(MAKEFLAGS) $@
else
	getent passwd $(DD_USER) || useradd --system --create-home $(DD_USER)
	@chown -v root:$(DD_GROUP) /etc/powerdns
	@chown -v pdns:$(DD_GROUP) /etc/powerdns/powerdns.sqlite3
	@chmod -v g+rwx /etc/powerdns
	@chmod -v g+rw /etc/powerdns/powerdns.sqlite3
	$(MAKE) ~$(DD_USER)/.ssh/authorized_keys
	install $(executables) $(bindir)/
endif

define dyndns_authorized_keys_contents
command="$(bindir)/samizdat-ssh-command $(bindir)/cryptonomic-dyndns-command",no-port-forwarding * Samizdat - YES WE CAN
endef

~$(DD_USER)/.ssh/authorized_keys:
	: writing file $@  $(file >$@,$(dyndns_authorized_keys_contents))