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