1 |
# DNS |
2 |
# |
3 |
# Douglas Thrift |
4 |
# |
5 |
# $Id$ |
6 |
|
7 |
SHELL := $(shell which bash) |
8 |
update := $(shell hostname -s) |
9 |
|
10 |
ifeq ($(shell [[ -r $(update) ]]; echo $$?),0) |
11 |
dhclient_exit_hooks := dhclient-exit-hooks |
12 |
endif |
13 |
|
14 |
.PHONY: all install clean |
15 |
|
16 |
all: $(dhclient_exit_hooks) |
17 |
|
18 |
dhclient-exit-hooks: dhclient-exit-hooks.in $(update) |
19 |
sed -e "s/^%%hostname%%$$/hostname='$(shell cat $(word 2, $+))'/;s/^%%\([a-z]*\)%%$$/read -p '\1: ' -er \1/" $< > $@ |
20 |
|
21 |
install: all |
22 |
ifndef dhclient_exit_hooks |
23 |
install -pv -g wheel -o root reverse.pl ~root/bin/reverse.pl |
24 |
else |
25 |
install -pv -g wheel -m 0600 -o root /dev/null /etc/dhclient-exit-hooks |
26 |
sed -e "s/^read -p '\(key\): ' -er \1$$/\1='$(shell read -p 'key: ' -er; echo $$REPLY)'/;s/^read -p '\(secret\): ' -er \1$$/\1='$(shell read -p 'secret: ' -er; echo $$REPLY)'/" dhclient-exit-hooks > /etc/dhclient-exit-hooks |
27 |
endif |
28 |
|
29 |
clean: |
30 |
rm -f dhclient-exit-hooks |