gluon-config-mode: rename configmode to config-mode (except in lua variables where it is still called configmode)

This commit is contained in:
Nils Schneider 2013-10-02 15:24:14 +02:00
parent ae5277ff9f
commit cf6c51ee5e
11 changed files with 102 additions and 108 deletions

View File

@ -0,0 +1,29 @@
#!/bin/sh
wait=3
wait_config_mode() {
sleep $wait
uci set 'config-mode.@wizard[0].enabled=1'
uci commit config-mode
reboot
}
if [ "$BUTTON" = wps -o "$BUTTON" = reset ]; then
case "$ACTION" in
pressed)
wait_config_mode &
PID=$!
echo $PID > /tmp/.wait_config_mode
;;
released)
if [ -r /tmp/.wait_config_mode ]; then
kill $(cat /tmp/.wait_config_mode)
rm /tmp/.wait_config_mode
fi
;;
esac
fi

View File

@ -1,29 +0,0 @@
#!/bin/sh
wait=3
wait_configmode() {
sleep $wait
uci set 'configmode.@wizard[0].enabled=1'
uci commit configmode
reboot
}
if [ "$BUTTON" = wps -o "$BUTTON" = reset ]; then
case "$ACTION" in
pressed)
wait_configmode &
PID=$!
echo $PID > /tmp/.wait_configmode
;;
released)
if [ -r /tmp/.wait_configmode ]; then
kill $(cat /tmp/.wait_configmode)
rm /tmp/.wait_configmode
fi
;;
esac
fi

View File

@ -0,0 +1,54 @@
#!/bin/sh /etc/rc.common
START=12
config_mode_iface=eth0
config_mode_addr=192.168.1.1
config_mode_plen=24
config_mode_dnsname=freifunk
config_mode_dhcp_range=192.168.1.2,192.168.1.254
check_enable() {
config_get enabled "$1" enabled
config_get configured "$1" configured
if [ "$enabled" = 1 -o "$configured" != 1 ]; then
export enable=1
fi
}
start() {
enable=0
config_load config-mode
config_foreach check_enable wizard
if [ "$enable" = '1' ]; then
lua -luci -e 'require "luci.model.uci"; uci_state=luci.model.uci.cursor_state(); uci_state:section("config-mode", "wizard", nil, { running = "1" }); uci_state:save("config-mode")'
uci set 'config-mode.@wizard[0].enabled=0'
uci commit config-mode
ip addr add $config_mode_addr/$config_mode_plen dev $config_mode_iface
ip link set up dev $config_mode_iface
/etc/init.d/haveged start
/etc/init.d/telnet start
/etc/init.d/dropbear start
/etc/init.d/uhttpd start
/etc/init.d/led start
# correctly finish firstboot
/etc/init.d/done boot
echo "$config_mode_addr $config_mode_dnsname" > /tmp/hosts.config-mode
dnsmasq -h -H /tmp/hosts.config-mode -R -F interface:$config_mode_iface,$config_mode_dhcp_range -l /tmp/dhcp.leases -O option:router
. /etc/diag.sh
get_status_led
status_led_set_timer 1000 300
# block further boot
while true; do sleep 1; done
fi
}

View File

@ -1,54 +0,0 @@
#!/bin/sh /etc/rc.common
START=12
configmode_iface=eth0
configmode_addr=192.168.1.1
configmode_plen=24
configmode_dnsname=freifunk
configmode_dhcp_range=192.168.1.2,192.168.1.254
check_enable() {
config_get enabled "$1" enabled
config_get configured "$1" configured
if [ "$enabled" = 1 -o "$configured" != 1 ]; then
export enable=1
fi
}
start() {
enable=0
config_load configmode
config_foreach check_enable wizard
if [ "$enable" = '1' ]; then
lua -luci -e 'require "luci.model.uci"; uci_state=luci.model.uci.cursor_state(); uci_state:section("configmode", "wizard", nil, { running = "1" }); uci_state:save("configmode")'
uci set 'configmode.@wizard[0].enabled=0'
uci commit configmode
ip addr add $configmode_addr/$configmode_plen dev $configmode_iface
ip link set up dev $configmode_iface
/etc/init.d/haveged start
/etc/init.d/telnet start
/etc/init.d/dropbear start
/etc/init.d/uhttpd start
/etc/init.d/led start
# correctly finish firstboot
/etc/init.d/done boot
echo "$configmode_addr $configmode_dnsname" > /tmp/hosts.configmode
dnsmasq -h -H /tmp/hosts.configmode -R -F interface:$configmode_iface,$configmode_dhcp_range -l /tmp/dhcp.leases -O option:router
. /etc/diag.sh
get_status_led
status_led_set_timer 1000 300
# block further boot
while true; do sleep 1; done
fi
}

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
OLD_CFG=/etc/config/config_mode OLD_CFG=/etc/config/config_mode
NEW_CFG=/etc/config/configmode NEW_CFG=/etc/config/config-mode
[ -f $OLD_CFG ] && mv $OLD_CFG $NEW_CFG [ -f $OLD_CFG ] && mv $OLD_CFG $NEW_CFG

View File

@ -1,6 +0,0 @@
#!/bin/sh
OLD_CFG=/etc/config/config_mode
NEW_CFG=/etc/config/configmode
[ -f $OLD_CFG ] && mv $OLD_CFG $NEW_CFG

View File

@ -10,54 +10,54 @@ You may obtain a copy of the License at
$Id$ $Id$
]]-- ]]--
module("luci.controller.configmode.configmode", package.seeall) module("luci.controller.config-mode.config-mode", package.seeall)
local meshvpn_name = "mesh_vpn" local meshvpn_name = "mesh_vpn"
function index() function index()
local uci_state = luci.model.uci.cursor_state() local uci_state = luci.model.uci.cursor_state()
if uci_state:get_first("configmode", "wizard", "running", "0") == "1" then if uci_state:get_first("config-mode", "wizard", "running", "0") == "1" then
local root = node() local root = node()
if not root.target then if not root.target then
root.target = alias("configmode") root.target = alias("config-mode")
root.index = true root.index = true
end end
page = node() page = node()
page.lock = true page.lock = true
page.target = alias("configmode") page.target = alias("config-mode")
page.subindex = true page.subindex = true
page.index = false page.index = false
page = node("configmode") page = node("config-mode")
page.title = _("Configmode") page.title = _("Wizard")
page.target = alias("configmode", "wizard") page.target = alias("config-mode", "wizard")
page.order = 5 page.order = 5
page.setuser = "root" page.setuser = "root"
page.setgroup = "root" page.setgroup = "root"
page.index = true page.index = true
entry({"configmode", "wizard"}, form("configmode/wizard")).index = true entry({"config-mode", "wizard"}, form("config-mode/wizard")).index = true
entry({"configmode", "reboot"}, call("action_reboot")) entry({"config-mode", "reboot"}, call("action_reboot"))
end end
end end
function action_reboot() function action_reboot()
local configmode = require "luci.tools.configmode" local configmode = require "luci.tools.config-mode"
local pubkey local pubkey
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
local meshvpn_enabled = uci:get("fastd", meshvpn_name, "enabled", "0") local meshvpn_enabled = uci:get("fastd", meshvpn_name, "enabled", "0")
if meshvpn_enabled == "1" then if meshvpn_enabled == "1" then
pubkey = configmode.get_fastd_pubkey(meshvpn_name) pubkey = configmode.get_fastd_pubkey(meshvpn_name)
end end
luci.template.render("configmode/reboot", {pubkey=pubkey}) luci.template.render("config-mode/reboot", {pubkey=pubkey})
uci:foreach("configmode", "wizard", function(s) uci:foreach("config-mode", "wizard", function(s)
uci:set("configmode", s[".name"], "configured", "1") uci:set("config-mode", s[".name"], "configured", "1")
end) end)
uci:save("configmode") uci:save("config-mode")
uci:commit("configmode") uci:commit("config-mode")
luci.sys.reboot() luci.sys.reboot()
end end

View File

@ -1,4 +1,4 @@
local configmode = require "luci.tools.configmode" local configmode = require "luci.tools.config-mode"
local meshvpn_name = "mesh_vpn" local meshvpn_name = "mesh_vpn"
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
local f, s, o local f, s, o
@ -75,7 +75,7 @@ function f.handle(self, state, data)
uci:save("system") uci:save("system")
uci:commit("system") uci:commit("system")
luci.http.redirect(luci.dispatcher.build_url("configmode", "reboot")) luci.http.redirect(luci.dispatcher.build_url("config-mode", "reboot"))
end end
return true return true

View File

@ -1,7 +1,7 @@
local luci = require "luci" local luci = require "luci"
local io = require "io" local io = require "io"
module "luci.tools.configmode" module "luci.tools.config-mode"
function setup_fastd_secret(name) function setup_fastd_secret(name)
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()