Skip to content

Commit

Permalink
lime-proto-bmx6: Add bmx6hosts_dnsmasq_update script
Browse files Browse the repository at this point in the history
Executed by Cron checks if bmx6 hosts file has changed and send HUB to dnmasq

Signed-off-by: Pau Escrich <p4u@dabax.net>
  • Loading branch information
p4u committed Mar 26, 2017
1 parent a134754 commit 4fe8244
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/lime-proto-bmx6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ define Package/$(PKG_NAME)/install
$(CP) ./build/bmx6.lua $(1)/usr/lib/lua/lime/proto/
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./build/bmx2hosts $(1)/usr/bin/
$(INSTALL_BIN) ./build/bmx6hosts $(1)/usr/bin/
$(INSTALL_BIN) ./build/85-add-bmx6-addresses-to-hosts $(1)/etc/uci-defaults/
$(INSTALL_BIN) ./build/bmx6hosts_dnsmasq_update $(1)/usr/bin/bmx6hosts_dnsmasq_update
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
Expand Down
4 changes: 2 additions & 2 deletions packages/lime-proto-bmx6/src/85-add-bmx6-addresses-to-hosts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
echo "adding bmx6 IPv6 addresses to it's own hosts file"
echo "*/5 * * * * bmx2hosts > /var/hosts/bmx6" >> /etc/crontabs/root
echo "adding bmx6 IPv6 addresses to dnsmasq hosts file directory"
echo "*/4 * * * * /usr/bin/bmx6hosts_dnsmasq_update" >> /etc/crontabs/root
File renamed without changes.
11 changes: 11 additions & 0 deletions packages/lime-proto-bmx6/src/bmx6hosts_dnsmasq_update
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
bmx6hosts > /var/hosts/bmx6
new=/tmp/bmx6hosts.new.md5
last=/tmp/bmx6hosts.last.md5
touch $last
md5sum /var/hosts/bmx6| awk '{print $1}' > $new
[ "$(cat $new)" != "$(cat $last)" ] && {
logger -t bmx6hosts "New bmx6 hosts found, updating dnsmasq"
killall -HUP dnsmasq
}
cp -f $new $last

0 comments on commit 4fe8244

Please sign in to comment.