e0f2470ade60ef1de19e5285c438cdfadc1ca4ba
[project/luci.git] / contrib / package / luci-addons / dist / etc / init.d / luci_ethers
1 #!/bin/sh /etc/rc.common
2 START=59
3
4 apply_lease() {
5 local cfg="$1"
6
7 config_get macaddr "$cfg" macaddr
8 config_get ipaddr "$cfg" ipaddr
9
10 [ -n "$macaddr" -a -n "$ipaddr" ] || return 0
11
12 echo "$macaddr $ipaddr" >> /var/etc/ethers
13 }
14
15 start() {
16 if [ ! -L /etc/ethers ]; then
17 test -f /etc/ethers && mv /etc/ethers /etc/ethers.local
18 test -d /var/etc || mkdir -p /var/etc
19 ln -s /var/etc/ethers /etc/ethers
20 fi
21
22 config_load luci_ethers
23 config_foreach apply_lease static_lease
24
25 test -f /etc/ethers.local && cat /etc/ethers.local >> /var/etc/ethers
26 }