Split gluon-setup-mode package out of gluon-config-mode
gluon-config-mode retains the luci frontend, all setup scripts and config is moved to the new package.
This commit is contained in:
parent
2ec02a41c2
commit
f93e9b818f
@ -4,7 +4,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gluon-config-mode
|
||||
PKG_VERSION:=3
|
||||
PKG_VERSION:=4
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
@ -13,8 +13,8 @@ include $(GLUONDIR)/include/package.mk
|
||||
define Package/gluon-config-mode
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Luci based config mode for user friendly setup of new meshnodes
|
||||
DEPENDS:=+gluon-luci-core +gluon-lock-password +gluon-node-info +gluon-simple-tc +uhttpd +dnsmasq +ip
|
||||
TITLE:=Luci based config mode for user friendly setup of new mesh nodes
|
||||
DEPENDS:=+gluon-luci-core +gluon-setup-mode +gluon-lock-password +gluon-node-info +gluon-simple-tc
|
||||
endef
|
||||
|
||||
define Package/gluon-config-mode/description
|
||||
|
@ -1,3 +0,0 @@
|
||||
config wizard
|
||||
option enabled '0'
|
||||
option configured '0'
|
@ -1,29 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
wait=3
|
||||
|
||||
|
||||
wait_config_mode() {
|
||||
sleep $wait
|
||||
uci set 'gluon-config-mode.@wizard[0].enabled=1'
|
||||
uci commit gluon-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
|
@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/gluon/functions/sysconfig.sh
|
||||
. /lib/ar71xx.sh
|
||||
|
||||
|
||||
sysconfig_isset config_ifname && exit 0
|
||||
|
||||
|
||||
case "$(ar71xx_board_name)" in
|
||||
nanostation-m)
|
||||
sysconfig_set config_ifname "$(sysconfig wan_ifname || sysconfig lan_ifname)"
|
||||
;;
|
||||
*)
|
||||
sysconfig_set config_ifname "$(sysconfig lan_ifname || sysconfig wan_ifname)"
|
||||
;;
|
||||
esac
|
@ -21,7 +21,7 @@ local meshvpn_name = "mesh_vpn"
|
||||
function index()
|
||||
local uci_state = luci.model.uci.cursor_state()
|
||||
|
||||
if uci_state:get_first("gluon-config-mode", "wizard", "running", "0") == "1" then
|
||||
if uci_state:get_first("gluon-setup-mode", "setup_mode", "running", "0") == "1" then
|
||||
local root = node()
|
||||
if not root.target then
|
||||
root.target = alias("gluon-config-mode")
|
||||
@ -57,9 +57,9 @@ function action_reboot()
|
||||
pubkey = configmode.get_fastd_pubkey(meshvpn_name)
|
||||
end
|
||||
|
||||
uci:set("gluon-config-mode", uci:get_first("gluon-config-mode", "wizard"), "configured", "1")
|
||||
uci:save("gluon-config-mode")
|
||||
uci:commit("gluon-config-mode")
|
||||
uci:set("gluon-setup-mode", uci:get_first("gluon-setup-mode", "setup_mode"), "configured", "1")
|
||||
uci:save("gluon-setup-mode")
|
||||
uci:commit("gluon-setup-mode")
|
||||
|
||||
local hostname = uci:get_first("system", "system", "hostname")
|
||||
|
||||
|
@ -9,11 +9,11 @@ local c = uci.cursor()
|
||||
for _, config in ipairs(site.legacy.config_mode_configs) do
|
||||
local old = c:get_first(config, 'wizard', 'configured')
|
||||
if old == '1' then
|
||||
local wizard = c:get_first('gluon-config-mode', 'wizard')
|
||||
c:set('gluon-config-mode', wizard, 'configured', '1')
|
||||
local setup_mode = c:get_first('gluon-setup-mode', 'setup_mode')
|
||||
c:set('gluon-setup-mode', setup_mode, 'configured', '1')
|
||||
|
||||
c:save('gluon-config-mode')
|
||||
c:commit('gluon-config-mode')
|
||||
c:save('gluon-setup-mode')
|
||||
c:commit('gluon-setup-mode')
|
||||
|
||||
break
|
||||
end
|
@ -17,10 +17,10 @@ module("luci.controller.admin.index", package.seeall)
|
||||
|
||||
function index()
|
||||
local uci_state = luci.model.uci.cursor_state()
|
||||
local configmode = uci_state:get_first("gluon-config-mode", "wizard", "running", "0") == "1"
|
||||
local setup_mode = uci_state:get_first("gluon-setup-mode", "setup_mode", "running", "0") == "1"
|
||||
|
||||
-- Disable gluon-luci-admin when configmode is not enabled
|
||||
if not configmode then
|
||||
-- Disable gluon-luci-admin when setup mode is not enabled
|
||||
if not setup_mode then
|
||||
return
|
||||
end
|
||||
|
||||
@ -32,8 +32,8 @@ function index()
|
||||
|
||||
local page = entry({"admin"}, alias("admin", "index"), "Expert Mode", 10)
|
||||
page.sysauth = "root"
|
||||
if configmode then
|
||||
-- force root to be logged in when running in configmode
|
||||
if setup_mode then
|
||||
-- force root to be logged in when running in setup_mode
|
||||
page.sysauth_authenticator = function() return "root" end
|
||||
else
|
||||
page.sysauth_authenticator = "htmlauth"
|
||||
@ -42,7 +42,7 @@ function index()
|
||||
|
||||
entry({"admin", "index"}, cbi("admin/remote"), "Remotezugriff", 1).ignoreindex = true
|
||||
|
||||
if not configmode then
|
||||
if not setup_mode then
|
||||
entry({"admin", "logout"}, call("action_logout"), "Logout")
|
||||
end
|
||||
end
|
||||
|
38
package/gluon-setup-mode/Makefile
Normal file
38
package/gluon-setup-mode/Makefile
Normal file
@ -0,0 +1,38 @@
|
||||
# Copyright (C) 2012 Nils Schneider <nils at nilsschneider.net>
|
||||
# This is free software, licensed under the Apache 2.0 license.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gluon-setup-mode
|
||||
PKG_VERSION:=1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include $(GLUONDIR)/include/package.mk
|
||||
|
||||
define Package/gluon-setup-mode
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=Setup mode
|
||||
DEPENDS:=+uhttpd +dnsmasq +ip
|
||||
endef
|
||||
|
||||
define Package/gluon-setup-mode/description
|
||||
Offline mode to perform basic setup in a secure manner.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/gluon-setup-mode/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,gluon-setup-mode))
|
@ -0,0 +1,3 @@
|
||||
config setup_mode
|
||||
option enabled '0'
|
||||
option configured '0'
|
29
package/gluon-setup-mode/files/etc/hotplug.d/button/50-gluon-setup-mode
Executable file
29
package/gluon-setup-mode/files/etc/hotplug.d/button/50-gluon-setup-mode
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
wait=3
|
||||
|
||||
|
||||
wait_setup_mode() {
|
||||
sleep $wait
|
||||
uci set 'gluon-setup-mode.@setup_mode[0].enabled=1'
|
||||
uci commit gluon-setup-mode
|
||||
reboot
|
||||
}
|
||||
|
||||
|
||||
if [ "$BUTTON" = wps -o "$BUTTON" = reset ]; then
|
||||
case "$ACTION" in
|
||||
pressed)
|
||||
wait_setup_mode &
|
||||
PID=$!
|
||||
echo $PID > /tmp/.wait_setup_mode
|
||||
;;
|
||||
released)
|
||||
if [ -r /tmp/.wait_setup_mode ]; then
|
||||
kill $(cat /tmp/.wait_setup_mode)
|
||||
rm /tmp/.wait_setup_mode
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
@ -3,10 +3,10 @@
|
||||
START=12
|
||||
|
||||
|
||||
CONFIG_MODE_ADDR=192.168.1.1
|
||||
CONFIG_MODE_NETMASK=255.255.255.0
|
||||
SETUP_MODE_ADDR=192.168.1.1
|
||||
SETUP_MODE_NETMASK=255.255.255.0
|
||||
|
||||
CONFIG_MODE_DHCP_RANGE=192.168.1.2,192.168.1.254
|
||||
SETUP_MODE_DHCP_RANGE=192.168.1.2,192.168.1.254
|
||||
|
||||
|
||||
delete_interface() {
|
||||
@ -25,7 +25,7 @@ check_enable() {
|
||||
|
||||
setup_network() {
|
||||
(
|
||||
export UCI_CONFIG_DIR=/var/gluon/config-mode/config
|
||||
export UCI_CONFIG_DIR=/var/gluon/setup-mode/config
|
||||
|
||||
mkdir -p "$UCI_CONFIG_DIR"
|
||||
|
||||
@ -34,12 +34,12 @@ setup_network() {
|
||||
config_load network
|
||||
config_foreach delete_interface interface
|
||||
|
||||
uci_add network interface config
|
||||
uci_set network config ifname "$(sysconfig config_ifname)"
|
||||
uci_set network config type 'bridge'
|
||||
uci_set network config proto 'static'
|
||||
uci_set network config ipaddr "$CONFIG_MODE_ADDR"
|
||||
uci_set network config netmask "$CONFIG_MODE_NETMASK"
|
||||
uci_add network interface setup
|
||||
uci_set network setup ifname "$(sysconfig setup_ifname)"
|
||||
uci_set network setup type 'bridge'
|
||||
uci_set network setup proto 'static'
|
||||
uci_set network setup ipaddr "$SETUP_MODE_ADDR"
|
||||
uci_set network setup netmask "$SETUP_MODE_NETMASK"
|
||||
|
||||
uci_commit network
|
||||
|
||||
@ -58,22 +58,22 @@ start() {
|
||||
. /lib/gluon/functions/sysconfig.sh
|
||||
|
||||
enable=0
|
||||
config_load gluon-config-mode
|
||||
config_foreach check_enable wizard
|
||||
config_load gluon-setup-mode
|
||||
config_foreach check_enable setup_mode
|
||||
|
||||
if [ "$enable" = '1' ]; then
|
||||
lua -luci -e 'require "luci.model.uci"; uci_state=luci.model.uci.cursor_state(); uci_state:section("gluon-config-mode", "wizard", nil, { running = "1" }); uci_state:save("gluon-config-mode")'
|
||||
uci set 'gluon-config-mode.@wizard[0].enabled=0'
|
||||
uci commit gluon-config-mode
|
||||
lua -luci -e 'require "luci.model.uci"; uci_state=luci.model.uci.cursor_state(); uci_state:section("gluon-setup-mode", "setup_mode", nil, { running = "1" }); uci_state:save("gluon-setup-mode")'
|
||||
uci set 'gluon-setup-mode.@setup_mode[0].enabled=0'
|
||||
uci commit gluon-setup-mode
|
||||
|
||||
setup_network
|
||||
|
||||
/usr/sbin/telnetd -l /lib/gluon/config-mode/ash-login
|
||||
/usr/sbin/telnetd -l /lib/gluon/setup-mode/ash-login
|
||||
/etc/init.d/dropbear start
|
||||
|
||||
/usr/sbin/uhttpd -h /lib/gluon/config-mode/www -x /cgi-bin -A 1 -R -p 0.0.0.0:80
|
||||
/usr/sbin/uhttpd -h /lib/gluon/setup-mode/www -x /cgi-bin -A 1 -R -p 0.0.0.0:80
|
||||
|
||||
/usr/sbin/dnsmasq -p 0 -F $CONFIG_MODE_DHCP_RANGE -l /tmp/dhcp.leases -O option:router
|
||||
/usr/sbin/dnsmasq -p 0 -F $SETUP_MODE_DHCP_RANGE -l /tmp/dhcp.leases -O option:router
|
||||
|
||||
/etc/init.d/led start
|
||||
|
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require 'luci.model.uci'
|
||||
|
||||
local c = uci.cursor()
|
||||
|
||||
|
||||
local old = c:get_first('gluon-config-mode', 'wizard', 'configured')
|
||||
if old == '1' then
|
||||
local setup_mode = c:get_first('gluon-setup-mode', 'setup_mode')
|
||||
c:set('gluon-setup-mode', setup_mode, 'configured', '1')
|
||||
|
||||
c:save('gluon-setup-mode')
|
||||
c:commit('gluon-setup-mode')
|
||||
end
|
||||
|
||||
os.remove('/etc/config/gluon-config-mode')
|
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/gluon/functions/sysconfig.sh
|
||||
. /lib/gluon/functions/model.sh
|
||||
|
||||
|
||||
sysconfig_isset setup_ifname && exit 0
|
||||
|
||||
|
||||
case "$(get_board_name)" in
|
||||
nanostation-m)
|
||||
sysconfig_set setup_ifname "$(sysconfig config_ifname || sysconfig wan_ifname || sysconfig lan_ifname)"
|
||||
;;
|
||||
*)
|
||||
sysconfig_set setup_ifname "$(sysconfig config_ifname || sysconfig lan_ifname || sysconfig wan_ifname)"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Remove the old sysconfig setting
|
||||
sysconfig_unset config_ifname
|
Loading…
Reference in New Issue
Block a user