Merge pull request #878 from jow-/lxc-autoconf-fix
[feed/packages.git] / net / ddns-scripts / Makefile
1 include $(TOPDIR)/rules.mk
2
3 PKG_NAME:=ddns-scripts
4 # Version == major.minor.patch
5 # increase on new functionality (minor) or patches (patch)
6 PKG_VERSION:=2.4.0
7 # Release == build
8 # increase on changes of services files or tld_names.dat
9 PKG_RELEASE:=1
10
11 PKG_LICENSE:=GPL-2.0
12 PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
13
14 include $(INCLUDE_DIR)/package.mk
15
16 # no default dependencies
17 PKG_DEFAULT_DEPENDS=
18
19 define Package/$(PKG_NAME)/Default
20 SECTION:=net
21 CATEGORY:=Network
22 SUBMENU:=IP Addresses and Names
23 PKGARCH:=all
24 endef
25
26 ##### **********************************
27 define Package/$(PKG_NAME)
28 $(call Package/$(PKG_NAME)/Default)
29 TITLE:=Dynamic DNS Client scripts (with IPv6 support)
30 endef
31 # shown in LuCI package description
32 define Package/$(PKG_NAME)/description
33 Dynamic DNS Client scripts (with IPv6 support) - Info: http://wiki.openwrt.org/doc/howto/ddns.client
34 endef
35 # shown in menuconfig <Help>
36 define Package/$(PKG_NAME)/config
37 help
38 A highly configurable set of scripts for doing dynamic dns updates.
39 - IPv6 support
40 - force communication to IPv4 or IPv6 only
41 - DNS server support
42 - using BIND host if installed
43 - DNS requests via TCP
44 - Proxy server support
45 - log file support
46 - support to run once
47 .
48 Version: $(PKG_VERSION)-$(PKG_RELEASE)
49 Info : http://wiki.openwrt.org/doc/howto/ddns.client
50 .
51 $(PKG_MAINTAINER)
52 endef
53
54 ##### **********************************
55 define Package/$(PKG_NAME)_cloudflare
56 $(call Package/$(PKG_NAME)/Default)
57 TITLE:=DDNS extension for CloudFlare
58 DEPENDS:=$(PKG_NAME)
59 endef
60 define Package/$(PKG_NAME)_cloudflare/description
61 Dynamic DNS Client scripts extension for CloudFlare
62 endef
63
64 ##### **********************************
65 define Package/$(PKG_NAME)_no-ip_com
66 $(call Package/$(PKG_NAME)/Default)
67 TITLE:=DDNS extension for No-IP.com
68 DEPENDS:=$(PKG_NAME)
69 endef
70 define Package/$(PKG_NAME)_no-ip_com/description
71 Dynamic DNS Client scripts extension for No-IP.com
72 endef
73
74 ##### **********************************
75 define Package/$(PKG_NAME)_nsupdate
76 $(call Package/$(PKG_NAME)/Default)
77 TITLE:=DDNS extension using Bind nsupdate
78 DEPENDS:=$(PKG_NAME) +bind-client
79 endef
80 define Package/$(PKG_NAME)_nsupdate/description
81 Dynamic DNS Client scripts extension for direct updates using Bind nsupdate
82 endef
83 define Package/$(PKG_NAME)_nsupdate/config
84 help
85 The script directly updates a PowerDNS (or maybe bind server) via nsupdate
86 from bind-client package. It requires
87 "option dns_server" to be set to the server to be used by nsupdate.
88 "option username" should be set to the key name and
89 "option password" to the base64 encoded shared secret.
90
91 endef
92
93 ##### **********************************
94 define Build/Configure
95 endef
96 define Build/Compile
97 $(CP) ./files $(PKG_BUILD_DIR)
98 for FILE in `find $(PKG_BUILD_DIR)/files -type f`; do \
99 $(SED) 's/^\s*#/#/' \
100 -e '/^#\s\|^#$$$$/d' \
101 -e 's/\s#\s.*$$$$//' \
102 -e 's/\s*$$$$//' \
103 -e '/^\/\/\s/d' \
104 -e '/^\s*$$$$/d' $$$$FILE; \
105 done
106 endef
107
108 define Package/$(PKG_NAME)/conffiles
109 /etc/config/ddns
110 endef
111
112 ##### **********************************
113 define Package/$(PKG_NAME)/install
114 $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
115 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.hotplug $(1)/etc/hotplug.d/iface/95-ddns
116 $(INSTALL_DIR) $(1)/etc/init.d
117 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/ddns.init $(1)/etc/init.d/ddns
118 $(INSTALL_DIR) $(1)/etc/config
119 $(INSTALL_CONF) $(PKG_BUILD_DIR)/files/ddns.config $(1)/etc/config/ddns
120
121 $(INSTALL_DIR) $(1)/usr/lib/ddns
122 $(INSTALL_DATA) $(PKG_BUILD_DIR)/files/services* $(1)/usr/lib/ddns
123 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/dynamic_*.sh $(1)/usr/lib/ddns
124 endef
125 define Package/$(PKG_NAME)/postinst
126 #!/bin/sh
127 # if run within buildroot exit
128 [ -n "$${IPKG_INSTROOT}" ] && exit 0
129
130 # add new section "ddns" "global" if not exists
131 uci -q get ddns.global > /dev/null || uci -q set ddns.global='ddns'
132 uci -q get ddns.global.date_format > /dev/null || uci -q set ddns.global.date_format='%F %R'
133 uci -q get ddns.global.log_lines > /dev/null || uci -q set ddns.global.log_lines='250'
134 uci -q get ddns.global.allow_local_ip > /dev/null || uci -q set ddns.global.allow_local_ip='0'
135 uci -q commit ddns
136
137 # clear LuCI indexcache
138 rm -f /tmp/luci-indexcache >/dev/null 2>&1
139
140 exit 0
141 endef
142 define Package/$(PKG_NAME)/prerm
143 #!/bin/sh
144 # if run within buildroot exit
145 [ -n "$${IPKG_INSTROOT}" ] && exit 0
146
147 # stop running scripts
148 /etc/init.d/ddns disable
149 /etc/init.d/ddns stop
150
151 # clear LuCI indexcache
152 rm -f /tmp/luci-indexcache >/dev/null 2>&1
153
154 exit 0
155 endef
156
157 ##### **********************************
158 define Package/$(PKG_NAME)_cloudflare/install
159 $(INSTALL_DIR) $(1)/usr/lib/ddns
160 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_CloudFlare.sh $(1)/usr/lib/ddns
161 $(INSTALL_DATA) $(PKG_BUILD_DIR)/files/tld_names.dat $(1)/usr/lib/ddns
162 endef
163 define Package/$(PKG_NAME)_cloudflare/postinst
164 #!/bin/sh
165 echo -e '"CloudFlare"\t"update_CloudFlare.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
166 echo -e '"CloudFlare"\t"update_CloudFlare.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
167 endef
168 define Package/$(PKG_NAME)_cloudflare/prerm
169 #!/bin/sh
170 /bin/sed -i '/update_CloudFlare\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
171 /bin/sed -i '/update_CloudFlare\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
172 endef
173
174 ##### **********************************
175 define Package/$(PKG_NAME)_no-ip_com/install
176 $(INSTALL_DIR) $(1)/usr/lib/ddns
177 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_No-IP.com.sh $(1)/usr/lib/ddns
178 endef
179 define Package/$(PKG_NAME)_no-ip_com/postinst
180 #!/bin/sh
181 echo -e '"No-IP.com"\t"update_No-IP.com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
182 echo -e '"NoIP.com"\t"update_No-IP.com.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
183 endef
184 define Package/$(PKG_NAME)_no-ip_com/prerm
185 #!/bin/sh
186 /bin/sed -i '/update_No-IP\.com\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
187 endef
188
189 ##### **********************************
190 define Package/$(PKG_NAME)_nsupdate/install
191 $(INSTALL_DIR) $(1)/usr/lib/ddns
192 $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/update_nsupdate.sh $(1)/usr/lib/ddns
193 endef
194 define Package/$(PKG_NAME)_nsupdate/postinst
195 #!/bin/sh
196 echo -e '"Bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services
197 echo -e '"Bind-nsupdate"\t"update_nsupdate.sh"' >> $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
198 endef
199 define Package/$(PKG_NAME)_nsupdate/prerm
200 #!/bin/sh
201 /bin/sed -i '/update_nsupdate\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services
202 /bin/sed -i '/update_nsupdate\.sh/ d' $${IPKG_INSTROOT}/usr/lib/ddns/services_ipv6
203 endef
204
205 ##### **********************************
206 $(eval $(call BuildPackage,$(PKG_NAME)))
207 $(eval $(call BuildPackage,$(PKG_NAME)_cloudflare))
208 $(eval $(call BuildPackage,$(PKG_NAME)_no-ip_com))
209 $(eval $(call BuildPackage,$(PKG_NAME)_nsupdate))