blob: d01bfbbd55f96736aa737de8681a260211aaafb7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/bin/sh /etc/rc.common
START=60
apply_host() {
local cfg="$1"
config_get hostname "$cfg" hostname
config_get ipaddr "$cfg" ipaddr
[ -n "$hostname" -a -n "$ipaddr" ] || return 0
echo "$ipaddr $hostname" >> /var/etc/hosts
}
start() {
if [ ! -L /etc/hosts ]; then
test -f /etc/hosts && mv /etc/hosts /etc/hosts.local
ln -s /var/etc/hosts /etc/hosts
fi
test -d /var/etc || mkdir -p /var/etc
test -f /etc/hosts.local && cat /etc/hosts.local >> /var/etc/hosts
config_load luci_hosts
config_foreach apply_host host
return 0
}
stop() {
test -f /var/etc/hosts && rm -f /var/etc/hosts
return 0
}
|