84 lines
2.2 KiB
Bash
Executable File
84 lines
2.2 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
|
|
START=12
|
|
|
|
|
|
config_mode_addr=192.168.1.1
|
|
config_mode_netmask=255.255.255.0
|
|
|
|
config_mode_dnsname=freifunk
|
|
config_mode_dhcp_range=192.168.1.2,192.168.1.254
|
|
|
|
|
|
. /lib/functions.sh
|
|
. /lib/gluon/functions/sysconfig.sh
|
|
|
|
|
|
delete_interface() {
|
|
[ "$1" = 'loopback' ] || uci_remove network "$1"
|
|
}
|
|
|
|
|
|
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 gluon-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("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
|
|
|
|
mkdir -p /var/gluon/config-mode/config
|
|
mount -o bind /etc/config /var/gluon/config-mode/config
|
|
|
|
touch /var/gluon/config-mode/wireless
|
|
mount -o bind /var/gluon/config-mode/wireless /etc/config/wireless
|
|
|
|
cp /etc/config/network /var/gluon/config-mode
|
|
mount -o bind /var/gluon/config-mode/network /etc/config/network
|
|
|
|
config_load network
|
|
config_foreach delete_interface interface
|
|
|
|
uci_add network interface config
|
|
uci_set network config ifname "$(sysconfig lan_ifname || sysconfig wan_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_commit network
|
|
/etc/init.d/network start
|
|
|
|
/usr/sbin/telnetd -l /lib/gluon/config-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
|
|
|
|
/etc/init.d/led start
|
|
|
|
# correctly finish firstboot
|
|
/etc/init.d/done boot
|
|
|
|
echo "$config_mode_addr $config_mode_dnsname" > /var/gluon/config-mode/hosts
|
|
dnsmasq -h -H /var/gluon/config-mode/hosts -R -F interface:br-config,$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
|
|
}
|