First Commit
[librecmc/package-feed.git] / net / ddns-scripts / Makefile
1 #
2 # Copyright (C) 2008-2016 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 #
6
7 include $(TOPDIR)/rules.mk
8
9 PKG_NAME:=ddns-scripts
10 # Version == major.minor.patch
11 # increase on new functionality (minor) or patches (patch)
12 PKG_VERSION:=2.7.6
13 # Release == build
14 # increase on changes of services files or tld_names.dat
15 PKG_RELEASE:=4
16
17 PKG_LICENSE:=GPL-2.0
18 PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
19
20 include $(INCLUDE_DIR)/package.mk
21
22 # no default dependencies
23 PKG_DEFAULT_DEPENDS=
24
25 define Package/$(PKG_NAME)/Default
26     SECTION:=net
27     CATEGORY:=Network
28     SUBMENU:=IP Addresses and Names
29     PKGARCH:=all
30 endef
31
32 ###### *************************************************************************
33 define Package/$(PKG_NAME)
34     $(call Package/$(PKG_NAME)/Default)
35     TITLE:=Dynamic DNS Client scripts (with IPv6 support)
36 endef
37 # shown in LuCI package description
38 define Package/$(PKG_NAME)/description
39     Dynamic DNS Client scripts (with IPv6 support) - Info: http://wiki.openwrt.org/doc/howto/ddns.client
40 endef
41 # shown in menuconfig <Help>
42 define Package/$(PKG_NAME)/config
43         help
44                 A highly configurable set of scripts for doing dynamic dns updates.
45                   - IPv6 support
46                   - DNS server support
47                   - Glue Record support (require BIND host or KNOT host)
48                   - DNS requests via TCP
49                   - Proxy server support
50                   - log file support
51                   - support to run once
52                 Version: $(PKG_VERSION)-$(PKG_RELEASE)
53                 Info   : http://wiki.openwrt.org/doc/howto/ddns.client
54 endef
55
56 ###### *************************************************************************
57 define Package/$(PKG_NAME)_cloudflare
58     $(call Package/$(PKG_NAME)/Default)
59     TITLE:=CloudFlare.com API v1 (deprecated)
60     DEPENDS:=$(PKG_NAME)
61 endef
62 define Package/$(PKG_NAME)_cloudflare/description
63     Dynamic DNS Client scripts extension for CloudFlare.com API-v1 (deprecated)
64 endef
65
66 ###### *************************************************************************
67 define Package/$(PKG_NAME)_cloudflare.com-v4
68     $(call Package/$(PKG_NAME)/Default)
69     TITLE:=CloudFlare.com API v4 (require cURL)
70     DEPENDS:=$(PKG_NAME) +curl
71 endef
72 define Package/$(PKG_NAME)_cloudflare.com-v4/description
73     Dynamic DNS Client scripts extension for CloudFlare.com API-v4 (require/install cURL)
74 endef
75
76 ###### *************************************************************************
77 define Package/$(PKG_NAME)_godaddy.com-v1
78     $(call Package/$(PKG_NAME)/Default)
79     TITLE:=GoDaddy.com (require cURL)
80     DEPENDS:=$(PKG_NAME) +curl
81 endef
82 define Package/$(PKG_NAME)_godaddy.com-v1/description
83     Dynamic DNS Client scripts extension for GoDaddy.com (require/install cURL)
84 endef
85
86 ###### *************************************************************************
87 define Package/$(PKG_NAME)_no-ip_com
88     $(call Package/$(PKG_NAME)/Default)
89     TITLE:=DDNS extension for No-IP.com
90     DEPENDS:=$(PKG_NAME)
91 endef
92 define Package/$(PKG_NAME)_no-ip_com/description
93     Dynamic DNS Client scripts extension for No-IP.com
94 endef
95
96 ###### *************************************************************************
97 define Package/$(PKG_NAME)_nsupdate
98     $(call Package/$(PKG_NAME)/Default)
99     TITLE:=DDNS extension using Bind nsupdate
100     DEPENDS:=$(PKG_NAME) +bind-client
101 endef
102 define Package/$(PKG_NAME)_nsupdate/description
103     Dynamic DNS Client scripts extension for direct updates using Bind nsupdate
104 endef
105 define Package/$(PKG_NAME)_nsupdate/config
106     help
107         The script directly updates a PowerDNS (or maybe bind server) via nsupdate
108         from bind-client package. It requires
109         "option dns_server" to be set to the server to be used by nsupdate.
110         "option username" should be set to the key name and
111         "option password" to the base64 encoded shared secret.
112
113 endef
114
115 ###### *************************************************************************
116 define Build/Configure
117 endef
118 define Build/Compile
119         $(CP) ./files $(PKG_BUILD_DIR)
120         for FILE in `find $(PKG_BUILD_DIR)/files -type f`; do \
121                 $(SED) 's/^\s*#/#/' \
122                 -e '/^#\s\|^#$$$$/d' \
123                 -e 's/\s#\s.*$$$$//' \
124                 -e 's/\s*$$$$//' \
125                 -e '/^\/\/\s/d' \
126                 -e '/^\s*$$$$/d'        $$$$FILE; \
127         done
128         # ensure that VERSION inside dynamic_dns_functions.sh reflect PKG_VERSION of Makefile
129         $(SED) '/^VERSION=*/s/.*/VERSION="$(PKG_VERSION)"/' $(PKG_BUILD_DIR)/files/dynamic_dns_functions.sh
130         $(CP) ./tools $(PKG_BUILD_DIR)
131         chmod 755 $(PKG_BUILD_DIR)/tools/*
132         $(PKG_BUILD_DIR)/tools/public_suffix_list.sh
133         mv -f $(PKG_BUILD_DIR)/tools/public_suffix_list.dat.gz \
134                 $(PKG_BUILD_DIR)/files/public_suffix_list.dat.gz
135 endef
136
137 define Package/$(PKG_NAME)/conffiles
138 /etc/config/ddns
139 endef
140
141 ###### *************************************************************************
142 define Package/$(PKG_NAME)/preinst
143         #!/bin/sh
144         # if NOT run buildroot and PKG_UPGRADE then stop service
145         [ -z "$${IPKG_INSTROOT}" -a "$${PKG_UPGRADE}" = "1" ] && /etc/init.d/ddns stop >/dev/null 2>&1
146         exit 0  # suppress errors
147 endef
148 define Package/$(PKG_NAME)/install
149         $(INSTALL_DIR)  $(1)/etc/uci-defaults
150         $(INSTALL_BIN)  $(PKG_BUILD_DIR)/files/ddns.defaults $(1)/etc/uci-defaults/ddns
151         $(INSTALL_DIR)  $(1)/etc/hotplug.d/iface
152         $(INSTALL_BIN)  $(PKG_BUILD_DIR)/files/ddns.hotplug $(1)/etc/hotplug.d/iface/95-ddns
153         $(INSTALL_DIR)  $(1)/etc/init.d
154         $(INSTALL_BIN)  $(PKG_BUILD_DIR)/files/ddns.init $(1)/etc/init.d/ddns
155         $(INSTALL_DIR)  $(1)/etc/config
156         $(INSTALL_CONF) $(PKG_BUILD_DIR)/files/ddns.config $(1)/etc/config/ddns
157
158         $(INSTALL_DIR)  $(1)/etc/ddns
159         $(INSTALL_DATA) $(PKG_BUILD_DIR)/files/services* $(1)/etc/ddns
160
161         $(INSTALL_DIR)  $(1)/usr/lib/ddns
162         $(INSTALL_BIN)  $(PKG_BUILD_DIR)/files/dynamic_dns_*.sh $(1)/usr/lib/ddns
163 endef
164 define Package/$(PKG_NAME)/postinst
165         #!/bin/sh
166         # if NOT run buildroot and PKG_UPGRADE then (re)start service if enabled
167         [ -z "$${IPKG_INSTROOT}" -a "$${PKG_UPGRADE}" = "1" ] \
168                 && /etc/init.d/ddns enabled \
169                 && /etc/init.d/ddns start >/dev/null 2>&1
170         exit 0  # suppress errors
171 endef
172 define Package/$(PKG_NAME)/prerm
173         #!/bin/sh
174         # if run within buildroot exit
175         [ -n "$${IPKG_INSTROOT}" ] && exit 0
176
177         # stop running scripts
178         /etc/init.d/ddns stop
179         /etc/init.d/ddns disable
180
181         # clear LuCI indexcache
182         rm -f /tmp/luci-indexcache >/dev/null 2>&1
183
184         exit 0  # suppress errors
185 endef
186
187 ###### *************************************************************************
188 define Package/$(PKG_NAME)_cloudflare/preinst
189         #!/bin/sh
190         # if NOT run buildroot then stop service
191         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1
192         exit 0  # suppress errors
193 endef
194 define Package/$(PKG_NAME)_cloudflare/install
195         $(INSTALL_DIR)  $(1)/etc/uci-defaults
196         $(INSTALL_BIN)  $(PKG_BUILD_DIR)/files/ddns.defaults $(1)/etc/uci-defaults/ddns_cloudflare
197         $(INSTALL_DIR)  $(1)/usr/lib/ddns
198         $(INSTALL_BIN)  $(PKG_BUILD_DIR)/files/update_cloudflare_com_v1.sh $(1)/usr/lib/ddns
199         $(INSTALL_DIR)  $(1)/usr/share
200         $(INSTALL_DATA) $(PKG_BUILD_DIR)/files/public_suffix_list.dat.gz $(1)/usr/share
201 endef
202 define Package/$(PKG_NAME)_cloudflare/postinst
203         #!/bin/sh
204         # if NOT upgrading add entries
205         [ "$${PKG_UPGRADE}" = "1" ] || {
206                 printf "%s\\t%s\\n" '"cloudflare.com-v1"' '"update_cloudflare_com_v1.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services
207                 printf "%s\\t%s\\n" '"cloudflare.com-v1"' '"update_cloudflare_com_v1.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services_ipv6
208         }
209         # on real system restart service if enabled
210         [ -z "$${IPKG_INSTROOT}" ] \
211                 && /etc/init.d/ddns enabled \
212                 && /etc/init.d/ddns start >/dev/null 2>&1
213         exit 0  # suppress errors
214 endef
215 define Package/$(PKG_NAME)_cloudflare/prerm
216         #!/bin/sh
217         # if NOT run buildroot then stop service
218         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop                             >/dev/null 2>&1
219         /bin/sed -i '/cloudflare\.com-v1/d' $${IPKG_INSTROOT}/etc/ddns/services         >/dev/null 2>&1
220         /bin/sed -i '/cloudflare\.com-v1/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6    >/dev/null 2>&1
221         exit 0  # suppress errors
222 endef
223
224 ###### *************************************************************************
225 define Package/$(PKG_NAME)_cloudflare.com-v4/preinst
226         #!/bin/sh
227         # if NOT run buildroot then stop service
228         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1
229         exit 0  # suppress errors
230 endef
231 define Package/$(PKG_NAME)_cloudflare.com-v4/install
232         $(INSTALL_DIR) $(1)/etc/uci-defaults
233         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.defaults $(1)/etc/uci-defaults/ddns_cloudflare.com-v4
234         $(INSTALL_DIR) $(1)/usr/lib/ddns
235         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_cloudflare_com_v4.sh $(1)/usr/lib/ddns
236 endef
237 define Package/$(PKG_NAME)_cloudflare.com-v4/postinst
238         #!/bin/sh
239         # if NOT upgrading add entries
240         [ "$${PKG_UPGRADE}" = "1" ] || {
241                 printf "%s\\t%s\\n" '"cloudflare.com-v4"' '"update_cloudflare_com_v4.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services
242                 printf "%s\\t%s\\n" '"cloudflare.com-v4"' '"update_cloudflare_com_v4.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services_ipv6
243         }
244         # on real system restart service if enabled
245         [ -z "$${IPKG_INSTROOT}" ] \
246                 && /etc/init.d/ddns enabled \
247                 && /etc/init.d/ddns start >/dev/null 2>&1
248         exit 0  # suppress errors
249 endef
250 define Package/$(PKG_NAME)_cloudflare.com-v4/prerm
251         #!/bin/sh
252         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop                             >/dev/null 2>&1
253         /bin/sed -i '/cloudflare\.com-v4/d' $${IPKG_INSTROOT}/etc/ddns/services         >/dev/null 2>&1
254         /bin/sed -i '/cloudflare\.com-v4/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6    >/dev/null 2>&1
255         exit 0  # suppress errors
256 endef
257
258 ###### *************************************************************************
259 define Package/$(PKG_NAME)_godaddy.com-v1/preinst
260         #!/bin/sh
261         # if NOT run buildroot then stop service
262         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1
263         exit 0  # suppress errors
264 endef
265 define Package/$(PKG_NAME)_godaddy.com-v1/install
266         $(INSTALL_DIR) $(1)/etc/uci-defaults
267         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.defaults $(1)/etc/uci-defaults/ddns_godaddy.com-v1
268         $(INSTALL_DIR) $(1)/usr/lib/ddns
269         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_godaddy_com_v1.sh $(1)/usr/lib/ddns
270 endef
271 define Package/$(PKG_NAME)_godaddy.com-v1/postinst
272         #!/bin/sh
273         # if NOT upgrading add entries
274         [ "$${PKG_UPGRADE}" = "1" ] || {
275                 printf "%s\\t%s\\n" '"godaddy.com-v1"' '"update_godaddy_com_v1.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services
276                 printf "%s\\t%s\\n" '"godaddy.com-v1"' '"update_godaddy_com_v1.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services_ipv6
277         }
278         # on real system restart service if enabled
279         [ -z "$${IPKG_INSTROOT}" ] \
280                 && /etc/init.d/ddns enabled \
281                 && /etc/init.d/ddns start >/dev/null 2>&1
282         exit 0  # suppress errors
283 endef
284 define Package/$(PKG_NAME)_godaddy.com-v1/prerm
285         #!/bin/sh
286         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop                             >/dev/null 2>&1
287         /bin/sed -i '/godaddy\.com-v1/d' $${IPKG_INSTROOT}/etc/ddns/services            >/dev/null 2>&1
288         /bin/sed -i '/godaddy\.com-v1/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6       >/dev/null 2>&1
289         exit 0  # suppress errors
290 endef
291
292 ###### *************************************************************************
293 define Package/$(PKG_NAME)_no-ip_com/preinst
294         #!/bin/sh
295         # if NOT run buildroot then stop service
296         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1
297         exit 0  # suppress errors
298 endef
299 define Package/$(PKG_NAME)_no-ip_com/install
300         $(INSTALL_DIR) $(1)/etc/uci-defaults
301         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.defaults $(1)/etc/uci-defaults/ddns_no-ip_com
302         $(INSTALL_DIR) $(1)/usr/lib/ddns
303         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_no-ip_com.sh $(1)/usr/lib/ddns
304 endef
305 define Package/$(PKG_NAME)_no-ip_com/postinst
306         #!/bin/sh
307         # if NOT upgrading add entries
308         [ "$${PKG_UPGRADE}" = "1" ] || {
309                 printf "%s\\t%s\\n" '"no-ip.com"' '"update_no-ip_com.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services
310         }
311         # on real system restart service if enabled
312         [ -z "$${IPKG_INSTROOT}" ] \
313                 && /etc/init.d/ddns enabled \
314                 && /etc/init.d/ddns start >/dev/null 2>&1
315         exit 0  # suppress errors
316 endef
317 define Package/$(PKG_NAME)_no-ip_com/prerm
318         #!/bin/sh
319         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop             >/dev/null 2>&1
320         /bin/sed -i '/no-ip\.com/d' $${IPKG_INSTROOT}/etc/ddns/services >/dev/null 2>&1
321         exit 0  # suppress errors
322 endef
323
324 ###### *************************************************************************
325 define Package/$(PKG_NAME)_nsupdate/preinst
326         #!/bin/sh
327         # if NOT run buildroot then stop service
328         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop >/dev/null 2>&1
329         exit 0  # suppress errors
330 endef
331 define Package/$(PKG_NAME)_nsupdate/install
332         $(INSTALL_DIR) $(1)/etc/uci-defaults
333         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.defaults $(1)/etc/uci-defaults/ddns_nsupdate
334         $(INSTALL_DIR) $(1)/usr/lib/ddns
335         $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_nsupdate.sh $(1)/usr/lib/ddns
336 endef
337 define Package/$(PKG_NAME)_nsupdate/postinst
338         #!/bin/sh
339         # if NOT upgrading add entries
340         [ "$${PKG_UPGRADE}" = "1" ] || {
341                 printf "%s\\t%s\\n" '"bind-nsupdate"' '"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services
342                 printf "%s\\t%s\\n" '"bind-nsupdate"' '"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/etc/ddns/services_ipv6
343         }
344         # on real system restart service if enabled
345         [ -z "$${IPKG_INSTROOT}" ] \
346                 && /etc/init.d/ddns enabled \
347                 && /etc/init.d/ddns start >/dev/null 2>&1
348         exit 0  # suppress errors
349 endef
350 define Package/$(PKG_NAME)_nsupdate/prerm
351         #!/bin/sh
352         [ -z "$${IPKG_INSTROOT}" ] && /etc/init.d/ddns stop                     >/dev/null 2>&1
353         /bin/sed -i '/bind-nsupdate/d' $${IPKG_INSTROOT}/etc/ddns/services      >/dev/null 2>&1
354         /bin/sed -i '/bind-nsupdate/d' $${IPKG_INSTROOT}/etc/ddns/services_ipv6 >/dev/null 2>&1
355         exit 0  # suppress errors
356 endef
357
358 ###### *************************************************************************
359 $(eval $(call BuildPackage,$(PKG_NAME)))
360 $(eval $(call BuildPackage,$(PKG_NAME)_cloudflare))
361 $(eval $(call BuildPackage,$(PKG_NAME)_cloudflare.com-v4))
362 $(eval $(call BuildPackage,$(PKG_NAME)_godaddy.com-v1))
363 $(eval $(call BuildPackage,$(PKG_NAME)_no-ip_com))
364 $(eval $(call BuildPackage,$(PKG_NAME)_nsupdate))