flm01/openwrt/package/luci/host/etc/init.d/luci_ethers

38 lines
724 B
Bash
Executable File

#!/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
echo "# This file is autogenerated, use /etc/ethers.local instead" > /var/etc/ethers
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
}