Merge pull request #2126 from lynxis/libmicrohttpd
[feed/packages.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.6.4
13 # Release == build
14 # increase on changes of services files or tld_names.dat
15 PKG_RELEASE:=3
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 - force communication to IPv4 or IPv6 only
47 - DNS server support
48 - using BIND host if installed
49 - DNS requests via TCP
50 - Proxy server support
51 - log file support
52 - support to run once
53 Version: $(PKG_VERSION)-$(PKG_RELEASE)
54 Info : http://wiki.openwrt.org/doc/howto/ddns.client
55 $(PKG_MAINTAINER)
56 endef
57
58 ##### **********************************
59 define Package/$(PKG_NAME)_cloudflare
60 $(call Package/$(PKG_NAME)/Default)
61 TITLE:=DDNS extension for CloudFlare.com
62 DEPENDS:=$(PKG_NAME)
63 endef
64 define Package/$(PKG_NAME)_cloudflare/description
65 Dynamic DNS Client scripts extension for CloudFlare.com
66 endef
67
68 ##### **********************************
69 define Package/$(PKG_NAME)_no-ip_com
70 $(call Package/$(PKG_NAME)/Default)
71 TITLE:=DDNS extension for No-IP.com
72 DEPENDS:=$(PKG_NAME)
73 endef
74 define Package/$(PKG_NAME)_no-ip_com/description
75 Dynamic DNS Client scripts extension for No-IP.com
76 endef
77
78 ##### **********************************
79 define Package/$(PKG_NAME)_nsupdate
80 $(call Package/$(PKG_NAME)/Default)
81 TITLE:=DDNS extension using Bind nsupdate
82 DEPENDS:=$(PKG_NAME) +bind-client
83 endef
84 define Package/$(PKG_NAME)_nsupdate/description
85 Dynamic DNS Client scripts extension for direct updates using Bind nsupdate
86 endef
87 define Package/$(PKG_NAME)_nsupdate/config
88 help
89 The script directly updates a PowerDNS (or maybe bind server) via nsupdate
90 from bind-client package. It requires
91 "option dns_server" to be set to the server to be used by nsupdate.
92 "option username" should be set to the key name and
93 "option password" to the base64 encoded shared secret.
94
95 endef
96
97 ##### **********************************
98 define Build/Configure
99 endef
100 define Build/Compile
101 $(CP) ./files $(PKG_BUILD_DIR)
102 for FILE in `find $(PKG_BUILD_DIR)/files -type f`; do \
103 $(SED) 's/^\s*#/#/' \
104 -e '/^#\s\|^#$$$$/d' \
105 -e 's/\s#\s.*$$$$//' \
106 -e 's/\s*$$$$//' \
107 -e '/^\/\/\s/d' \
108 -e '/^\s*$$$$/d' $$$$FILE; \
109 done
110 gzip -f9 $(PKG_BUILD_DIR)/files/tld_names.dat
111 endef
112
113 define Package/$(PKG_NAME)/conffiles
114 /etc/config/ddns
115 endef
116
117 ##### **********************************
118 define Package/$(PKG_NAME)/install
119 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
120 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.hotplug $(1)/etc/hotplug.d/iface/95-ddns
121 $(INSTALL_DIR) $(1)/etc/init.d
122 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.init $(1)/etc/init.d/ddns
123 $(INSTALL_DIR) $(1)/etc/config
124 $(INSTALL_CONF) $(PKG_BUILD_DIR)/files/ddns.config $(1)/etc/config/ddns
125
126 $(INSTALL_DIR) $(1)/usr/lib/ddns
127 $(INSTALL_DATA) $(PKG_BUILD_DIR)/files/services* $(1)/usr/lib/ddns
128 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/dynamic_*.sh $(1)/usr/lib/ddns
129 endef
130 define Package/$(PKG_NAME)/postinst
131 #!/bin/sh
132 # if run within buildroot exit
133 [ -n "$${IPKG_INSTROOT}" ] && exit 0
134
135 # add new section "ddns" "global" if not exists
136 uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
137 uci -q get ddns.global.date_format > /dev/null || uci -q set ddns.global.date_format='%F %R'
138 uci -q get ddns.global.log_lines > /dev/null || uci -q set ddns.global.log_lines='250'
139 uci -q get ddns.global.allow_local_ip > /dev/null || uci -q set ddns.global.allow_local_ip='0'
140 uci -q commit ddns
141
142 # clear LuCI indexcache
143 rm -f /tmp/luci-indexcache >/dev/null 2>&1
144
145 exit 0
146 endef
147 define Package/$(PKG_NAME)/prerm
148 #!/bin/sh
149 # if run within buildroot exit
150 [ -n "$${IPKG_INSTROOT}" ] && exit 0
151
152 # stop running scripts
153 /etc/init.d/ddns disable
154 /etc/init.d/ddns stop
155
156 # clear LuCI indexcache
157 rm -f /tmp/luci-indexcache >/dev/null 2>&1
158
159 exit 0
160 endef
161
162 ##### **********************************
163 define Package/$(PKG_NAME)_cloudflare/install
164 $(INSTALL_DIR) $(1)/usr/lib/ddns
165 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_cloudflare_com.sh $(1)/usr/lib/ddns
166 $(INSTALL_DATA) $(PKG_BUILD_DIR)/files/tld_names.dat.gz $(1)/usr/lib/ddns
167 endef
168 define Package/$(PKG_NAME)_cloudflare/postinst
169 #!/bin/sh
170 echo -e '"cloudflare.com"\t"update_cloudflare_com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
171 echo -e '"cloudflare.com"\t"update_cloudflare_com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
172 /bin/sed -i '/service_name/s/CloudFlare/cloudflare\.com/g' $${IPKG_INSTROOT}/etc/config/ddns
173 endef
174 define Package/$(PKG_NAME)_cloudflare/prerm
175 #!/bin/sh
176 /bin/sed -i '/update_cloudflare_com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
177 /bin/sed -i '/update_cloudflare_com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
178 endef
179
180 ##### **********************************
181 define Package/$(PKG_NAME)_no-ip_com/install
182 $(INSTALL_DIR) $(1)/usr/lib/ddns
183 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_no-ip_com.sh $(1)/usr/lib/ddns
184 endef
185 define Package/$(PKG_NAME)_no-ip_com/postinst
186 #!/bin/sh
187 echo -e '"no-ip.com"\t"update_no-ip_com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
188 /bin/sed -i '/service_name/s/NoIP\.com/no-ip\.com/g' $${IPKG_INSTROOT}/etc/config/ddns
189 /bin/sed -i '/service_name/s/No-IP\.com/no-ip\.com/g' $${IPKG_INSTROOT}/etc/config/ddns
190 endef
191 define Package/$(PKG_NAME)_no-ip_com/prerm
192 #!/bin/sh
193 /bin/sed -i '/update_no-ip_com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
194 endef
195
196 ##### **********************************
197 define Package/$(PKG_NAME)_nsupdate/install
198 $(INSTALL_DIR) $(1)/usr/lib/ddns
199 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_nsupdate.sh $(1)/usr/lib/ddns
200 endef
201 define Package/$(PKG_NAME)_nsupdate/postinst
202 #!/bin/sh
203 echo -e '"bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
204 echo -e '"bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
205 /bin/sed -i '/service_name/s/Bind-nsupdate/bind-nsupdate/g' $${IPKG_INSTROOT}/etc/config/ddns
206 endef
207 define Package/$(PKG_NAME)_nsupdate/prerm
208 #!/bin/sh
209 /bin/sed -i '/update_nsupdate\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
210 /bin/sed -i '/update_nsupdate\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
211 endef
212
213 ##### **********************************
214 $(eval $(call BuildPackage,$(PKG_NAME)))
215 $(eval $(call BuildPackage,$(PKG_NAME)_cloudflare))
216 $(eval $(call BuildPackage,$(PKG_NAME)_no-ip_com))
217 $(eval $(call BuildPackage,$(PKG_NAME)_nsupdate))