modules/admin-core: remove left over references to luci_hosts and luci_ethers
[project/luci.git] / modules / admin-core / root / etc / init.d / luci_dhcp_migrate
1 #!/bin/sh /etc/rc.common
2
3 START=59
4
5 boot() {
6         if [ -f /etc/config/luci_ethers ]; then
7                 logger -t luci_dhcp_migrate "Migrating luci_ethers configuration ..."
8
9                 lua -lluci.model.uci -e '
10                         x=luci.model.uci.cursor()
11                         x:foreach("luci_ethers", "static_lease",
12                         function(s)
13                                 x:section("dhcp", "host", nil, {mac=s.macaddr, ip=s.ipaddr})
14                         end)
15                         x:save("dhcp")
16                         x:commit("dhcp")
17                 '
18
19                 rm -f /etc/config/luci_ethers
20         fi
21
22         if [ -f /etc/config/luci_hosts ]; then
23                 logger -t luci_dhcp_migrate "Migrating luci_hosts configuration ..."
24
25                 lua -lluci.model.uci -e '
26                         x=luci.model.uci.cursor()
27                         x:foreach("luci_hosts", "host",
28                         function(s)
29                                 x:section("dhcp", "domain", nil, {name=s.hostname, ip=s.ipaddr})
30                         end)
31                         x:save("dhcp")
32                         x:commit("dhcp")
33                 '
34
35                 rm -f /etc/config/luci_hosts
36         fi
37 }
38
39 start() { :; }
40 stop() { :; }
41