blob: afbda6c8c222e86dc83a45e2e6b3408c92dc29b4 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
CONFFILE="/etc/network-tools/config/ddns-client.conf"
case "${1}" in
configure)
db_get open-infrastructure-ddns-client/nameservers
NAMESERVERS="${RET}" # string
db_get open-infrastructure-ddns-client/zone
ZONE="${RET}" # string
db_get open-infrastructure-ddns-client/record
RECORD="${RET}" # string
db_get open-infrastructure-ddns-client/ttl
TTL="${RET:-60}" # string (w/o empty)
db_get open-infrastructure-ddns-client/tsig
TSIG="${RET}" # string (w/ empty)
db_stop
if [ ! -e "${CONFFILE}" ]
then
mkdir -p /etc/network-tools/config
cat > "${CONFFILE}" << EOF
# /etc/network-tools/config/ddns-client.conf
NAMESERVERS="${NAMESERVERS}"
ZONE="${ZONE}"
RECORD="${RECORD}"
TTL="${TTL}"
TSIG_KEYFILE=""
EOF
fi
cp -a -f "${CONFFILE}" "${CONFFILE}.tmp"
# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the config file.
test -z "${NAMESERVERS}" || \
grep -Eq '^ *NAMESERVERS=' "${CONFFILE}" || \
echo "NAMESERVERS=" >> "${CONFFILE}"
test -z "${ZONE}" || \
grep -Eq '^ *ZONE=' "${CONFFILE}" || \
echo "ZONE=" >> "${CONFFILE}"
test -z "${RECORD}" || \
grep -Eq '^ *RECORD=' "${CONFFILE}" || \
echo "RECORD=" >> "${CONFFILE}"
test -z "${TTL}" || \
grep -Eq '^ *TTL=' "${CONFFILE}" || \
echo "TTL=" >> "${CONFFILE}"
sed -e "s|^ *NAMESERVERS=.*|NAMESERVERS=\"${NAMESERVERS}\"|" \
-e "s|^ *ZONE=.*|ZONE=\"${ZONE}\"|" \
-e "s|^ *RECORD=.*|RECORD=\"${RECORD}\"|" \
-e "s|^ *TTL=.*|TTL=\"${TTL}\"|" \
< "${CONFFILE}" > "${CONFFILE}.tmp"
mv -f "${CONFFILE}.tmp" "${CONFFILE}"
if [ -n "${TSIG}" ]
then
case "${TSIG}" in
http*)
# tsig is a URL
if command -v wget "${TSIG}" -O /dev/null > /dev/null 2>&1
then
rm -f /etc/network-tools/tsig.key
wget "${TSIG}" -O /etc/network-tools/tsig.key
chmod 0600 /etc/network-tools/tsig.key
TSIG_FILE="/etc/network-tools/tsig.key"
elif command -v curl "${TSIG}" -o /dev/null > /dev/null 2>&1
then
rm -f /etc/network-tools/tsig.key
curl "${TSIG}" -o /etc/network-tools/tsig.key
chmod 0600 /etc/network-tools/tsig.key
TSIG_FILE="/etc/network-tools/tsig.key"
fi
;;
*:*)
# tsig is a string
echo "${TSIG}" > /etc/network-tools/tsig.key
chmod 0600 /etc/network-tools/tsig.key
TSIG_FILE="/etc/network-tools/tsig.key"
;;
*/*)
# tsig is a path
TSIG_FILE="${TSIG}"
;;
*)
echo "'${TSIG}' is neither a valid tsig, nor a path or URL to an existing file - ignoring"
;;
esac
fi
if [ -n "${TSIG_FILE}" ]
then
cp -a -f "${CONFFILE}" "${CONFFILE}.tmp"
# If the admin deleted or commented some variables but then set
# them via debconf, (re-)add them to the config file.
test -z "${TSIG_FILE}" || \
grep -Eq '^ *TSIG_KEYFILE=' "${CONFFILE}" || \
echo "TSIG_KEYFILE=" >> "${CONFFILE}"
sed -e "s|^ *TSIG_KEYFILE=.*|TSIG_KEYFILE=\"${TSIG_FILE}\"|" \
< "${CONFFILE}" > "${CONFFILE}.tmp"
mv -f "${CONFFILE}.tmp" "${CONFFILE}"
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`${1}'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0
|