Makefile 15 KB

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