From cf6c51ee5ef5592aa4d40f97ef8cedc395ee4f23 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Wed, 2 Oct 2013 15:24:14 +0200 Subject: [PATCH] gluon-config-mode: rename configmode to config-mode (except in lua variables where it is still called configmode) --- .../etc/config/{configmode => config-mode} | 0 .../files/etc/hotplug.d/button/50-config-mode | 29 ++++++++++ .../files/etc/hotplug.d/button/50-configmode | 29 ---------- .../files/etc/init.d/config-mode | 54 +++++++++++++++++++ .../files/etc/init.d/configmode | 54 ------------------- .../invariant/001-migrate-uci-config | 2 +- .../invariant/001-migrate-uci-config | 6 --- .../config-mode.lua} | 30 +++++------ .../{configmode => config-mode}/wizard.lua | 4 +- .../tools/{configmode.lua => config-mode.lua} | 2 +- .../{configmode => config-mode}/reboot.htm | 0 11 files changed, 102 insertions(+), 108 deletions(-) rename package/gluon-config-mode/files/etc/config/{configmode => config-mode} (100%) create mode 100755 package/gluon-config-mode/files/etc/hotplug.d/button/50-config-mode delete mode 100755 package/gluon-config-mode/files/etc/hotplug.d/button/50-configmode create mode 100755 package/gluon-config-mode/files/etc/init.d/config-mode delete mode 100755 package/gluon-config-mode/files/etc/init.d/configmode delete mode 100755 package/gluon-config-mode/files/lib/gluon/upgrade/configmode/invariant/001-migrate-uci-config rename package/gluon-config-mode/files/usr/lib/lua/luci/controller/{configmode/configmode.lua => config-mode/config-mode.lua} (55%) rename package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/{configmode => config-mode}/wizard.lua (95%) rename package/gluon-config-mode/files/usr/lib/lua/luci/tools/{configmode.lua => config-mode.lua} (95%) rename package/gluon-config-mode/generate/usr/lib/lua/luci/view/{configmode => config-mode}/reboot.htm (100%) diff --git a/package/gluon-config-mode/files/etc/config/configmode b/package/gluon-config-mode/files/etc/config/config-mode similarity index 100% rename from package/gluon-config-mode/files/etc/config/configmode rename to package/gluon-config-mode/files/etc/config/config-mode diff --git a/package/gluon-config-mode/files/etc/hotplug.d/button/50-config-mode b/package/gluon-config-mode/files/etc/hotplug.d/button/50-config-mode new file mode 100755 index 00000000..59dcd7de --- /dev/null +++ b/package/gluon-config-mode/files/etc/hotplug.d/button/50-config-mode @@ -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 diff --git a/package/gluon-config-mode/files/etc/hotplug.d/button/50-configmode b/package/gluon-config-mode/files/etc/hotplug.d/button/50-configmode deleted file mode 100755 index d5032d21..00000000 --- a/package/gluon-config-mode/files/etc/hotplug.d/button/50-configmode +++ /dev/null @@ -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 diff --git a/package/gluon-config-mode/files/etc/init.d/config-mode b/package/gluon-config-mode/files/etc/init.d/config-mode new file mode 100755 index 00000000..3d462c32 --- /dev/null +++ b/package/gluon-config-mode/files/etc/init.d/config-mode @@ -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 +} diff --git a/package/gluon-config-mode/files/etc/init.d/configmode b/package/gluon-config-mode/files/etc/init.d/configmode deleted file mode 100755 index 7055d130..00000000 --- a/package/gluon-config-mode/files/etc/init.d/configmode +++ /dev/null @@ -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 -} diff --git a/package/gluon-config-mode/files/lib/gluon/upgrade/config-mode/invariant/001-migrate-uci-config b/package/gluon-config-mode/files/lib/gluon/upgrade/config-mode/invariant/001-migrate-uci-config index e3ff8f2c..1aa788dc 100755 --- a/package/gluon-config-mode/files/lib/gluon/upgrade/config-mode/invariant/001-migrate-uci-config +++ b/package/gluon-config-mode/files/lib/gluon/upgrade/config-mode/invariant/001-migrate-uci-config @@ -1,6 +1,6 @@ #!/bin/sh 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 diff --git a/package/gluon-config-mode/files/lib/gluon/upgrade/configmode/invariant/001-migrate-uci-config b/package/gluon-config-mode/files/lib/gluon/upgrade/configmode/invariant/001-migrate-uci-config deleted file mode 100755 index e3ff8f2c..00000000 --- a/package/gluon-config-mode/files/lib/gluon/upgrade/configmode/invariant/001-migrate-uci-config +++ /dev/null @@ -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 diff --git a/package/gluon-config-mode/files/usr/lib/lua/luci/controller/configmode/configmode.lua b/package/gluon-config-mode/files/usr/lib/lua/luci/controller/config-mode/config-mode.lua similarity index 55% rename from package/gluon-config-mode/files/usr/lib/lua/luci/controller/configmode/configmode.lua rename to package/gluon-config-mode/files/usr/lib/lua/luci/controller/config-mode/config-mode.lua index 71a1a60f..ac7d7901 100644 --- a/package/gluon-config-mode/files/usr/lib/lua/luci/controller/configmode/configmode.lua +++ b/package/gluon-config-mode/files/usr/lib/lua/luci/controller/config-mode/config-mode.lua @@ -10,54 +10,54 @@ You may obtain a copy of the License at $Id$ ]]-- -module("luci.controller.configmode.configmode", package.seeall) +module("luci.controller.config-mode.config-mode", package.seeall) local meshvpn_name = "mesh_vpn" function index() 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() if not root.target then - root.target = alias("configmode") + root.target = alias("config-mode") root.index = true end page = node() page.lock = true - page.target = alias("configmode") + page.target = alias("config-mode") page.subindex = true page.index = false - page = node("configmode") - page.title = _("Configmode") - page.target = alias("configmode", "wizard") + page = node("config-mode") + page.title = _("Wizard") + page.target = alias("config-mode", "wizard") page.order = 5 page.setuser = "root" page.setgroup = "root" page.index = true - entry({"configmode", "wizard"}, form("configmode/wizard")).index = true - entry({"configmode", "reboot"}, call("action_reboot")) + entry({"config-mode", "wizard"}, form("config-mode/wizard")).index = true + entry({"config-mode", "reboot"}, call("action_reboot")) end end function action_reboot() - local configmode = require "luci.tools.configmode" + local configmode = require "luci.tools.config-mode" local pubkey local uci = luci.model.uci.cursor() local meshvpn_enabled = uci:get("fastd", meshvpn_name, "enabled", "0") if meshvpn_enabled == "1" then pubkey = configmode.get_fastd_pubkey(meshvpn_name) end - luci.template.render("configmode/reboot", {pubkey=pubkey}) + luci.template.render("config-mode/reboot", {pubkey=pubkey}) - uci:foreach("configmode", "wizard", function(s) - uci:set("configmode", s[".name"], "configured", "1") + uci:foreach("config-mode", "wizard", function(s) + uci:set("config-mode", s[".name"], "configured", "1") end) - uci:save("configmode") - uci:commit("configmode") + uci:save("config-mode") + uci:commit("config-mode") luci.sys.reboot() end diff --git a/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/configmode/wizard.lua b/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/config-mode/wizard.lua similarity index 95% rename from package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/configmode/wizard.lua rename to package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/config-mode/wizard.lua index d651a7c7..1e3b8f73 100644 --- a/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/configmode/wizard.lua +++ b/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/config-mode/wizard.lua @@ -1,4 +1,4 @@ -local configmode = require "luci.tools.configmode" +local configmode = require "luci.tools.config-mode" local meshvpn_name = "mesh_vpn" local uci = luci.model.uci.cursor() local f, s, o @@ -75,7 +75,7 @@ function f.handle(self, state, data) uci:save("system") uci:commit("system") - luci.http.redirect(luci.dispatcher.build_url("configmode", "reboot")) + luci.http.redirect(luci.dispatcher.build_url("config-mode", "reboot")) end return true diff --git a/package/gluon-config-mode/files/usr/lib/lua/luci/tools/configmode.lua b/package/gluon-config-mode/files/usr/lib/lua/luci/tools/config-mode.lua similarity index 95% rename from package/gluon-config-mode/files/usr/lib/lua/luci/tools/configmode.lua rename to package/gluon-config-mode/files/usr/lib/lua/luci/tools/config-mode.lua index 3b4c8b6b..4250ddd2 100644 --- a/package/gluon-config-mode/files/usr/lib/lua/luci/tools/configmode.lua +++ b/package/gluon-config-mode/files/usr/lib/lua/luci/tools/config-mode.lua @@ -1,7 +1,7 @@ local luci = require "luci" local io = require "io" -module "luci.tools.configmode" +module "luci.tools.config-mode" function setup_fastd_secret(name) local uci = luci.model.uci.cursor() diff --git a/package/gluon-config-mode/generate/usr/lib/lua/luci/view/configmode/reboot.htm b/package/gluon-config-mode/generate/usr/lib/lua/luci/view/config-mode/reboot.htm similarity index 100% rename from package/gluon-config-mode/generate/usr/lib/lua/luci/view/configmode/reboot.htm rename to package/gluon-config-mode/generate/usr/lib/lua/luci/view/config-mode/reboot.htm