Kill luci-addons package
[project/luci.git] / modules / admin-core / root / etc / init.d / luci_ethers
diff --git a/modules/admin-core/root/etc/init.d/luci_ethers b/modules/admin-core/root/etc/init.d/luci_ethers
new file mode 100755 (executable)
index 0000000..8cf4672
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh /etc/rc.common
+START=59
+
+apply_lease() {
+       local cfg="$1"
+
+       config_get macaddr "$cfg" macaddr
+       config_get ipaddr  "$cfg" ipaddr
+
+       [ -n "$macaddr" -a -n "$ipaddr" ] || return 0
+       
+       echo "$macaddr $ipaddr" >> /var/etc/ethers
+}
+
+start() {
+       if [ ! -L /etc/ethers ]; then
+               test -f /etc/ethers && mv /etc/ethers /etc/ethers.local
+               ln -s /var/etc/ethers /etc/ethers
+       fi
+
+       test -d /var/etc || mkdir -p /var/etc
+       
+       config_load luci_ethers
+       config_foreach apply_lease static_lease
+       
+       test -f /etc/ethers.local && cat /etc/ethers.local >> /var/etc/ethers
+       
+       return 0
+}
+
+stop() {
+       test -f /var/etc/ethers && rm -f /var/etc/ethers
+       
+       return 0
+}