summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2010-03-09 11:37:12 +0000
committerJo-Philipp Wich <jow@openwrt.org>2010-03-09 11:37:12 +0000
commitacc4524a8468085f52e6dce1e82f5414cc1d5114 (patch)
treea1ab6d788fcb795be05acd72dc317560e9488327
parent95d316a55c541b3576593867f3998f913a7ac8ef (diff)
moodules/admin-core: add luci_{ethers,hosts} -> dhcp config migration
-rwxr-xr-xmodules/admin-core/root/etc/init.d/luci_dhcp_migrate41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/admin-core/root/etc/init.d/luci_dhcp_migrate b/modules/admin-core/root/etc/init.d/luci_dhcp_migrate
new file mode 100755
index 000000000..7fb443527
--- /dev/null
+++ b/modules/admin-core/root/etc/init.d/luci_dhcp_migrate
@@ -0,0 +1,41 @@
+#!/bin/sh /etc/rc.common
+
+START=59
+
+boot() {
+ if [ -f /etc/config/luci_ethers ]; then
+ logger -t luci_dhcp_migrate "Migrating luci_ethers configuration ..."
+
+ lua -lluci.model.uci -e '
+ x=luci.model.uci.cursor()
+ x:foreach("luci_ethers", "static_lease",
+ function(s)
+ x:section("dhcp", "host", nil, {mac=s.macaddr, ip=s.ipaddr})
+ end)
+ x:save("dhcp")
+ x:commit("dhcp")
+ '
+
+ rm -f /etc/config/luci_ethers
+ fi
+
+ if [ -f /etc/config/luci_hosts ]; then
+ logger -t luci_dhcp_migrate "Migrating luci_hosts configuration ..."
+
+ lua -lluci.model.uci -e '
+ x=luci.model.uci.cursor()
+ x:foreach("luci_hosts", "host",
+ function(s)
+ x:section("dhcp", "domain", nil, {name=s.hostname, ip=s.ipaddr})
+ end)
+ x:save("dhcp")
+ x:commit("dhcp")
+ '
+
+ rm -f /etc/config/luci_hosts
+ fi
+}
+
+start() { :; }
+stop() { :; }
+