root/luci/trunk/modules/admin-core/root/etc/init.d/luci_ethers @ 4174

Revision 4174, 0.7 KB (checked in by jow, 4 years ago)

modules/admin-core: add autogeneartion notice to /var/etc/hosts, /var/etc/ethers

  • Property svn:executable set to *
Line 
1#!/bin/sh /etc/rc.common
2START=59
3
4apply_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
15start() {
16    if [ ! -L /etc/ethers ]; then
17        test -f /etc/ethers && mv /etc/ethers /etc/ethers.local
18        ln -s /var/etc/ethers /etc/ethers
19    fi
20
21    test -d /var/etc || mkdir -p /var/etc
22
23    echo "# This file is autogenerated, use /etc/ethers.local instead" > /var/etc/ethers
24
25    config_load luci_ethers
26    config_foreach apply_lease static_lease
27
28    test -f /etc/ethers.local && cat /etc/ethers.local >> /var/etc/ethers
29
30    return 0
31}
32
33stop() {
34    test -f /var/etc/ethers && rm -f /var/etc/ethers
35
36    return 0
37}
Note: See TracBrowser for help on using the browser.