Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh /etc/rc.common

START=50

USE_PROCD=1

UHTTPD_BIN="/usr/sbin/uhttpd"

start_service() {
procd_open_instance
procd_set_param respawn
procd_set_param command "$UHTTPD_BIN" -f -h /lib/gluon/config-mode/www -x /cgi-bin -A 1 -R -p 0.0.0.0:80
procd_close_instance
}

This file was deleted.

5 changes: 2 additions & 3 deletions package/gluon-setup-mode/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ init_links := \
define Package/gluon-setup-mode/install
$(Gluon/Build/Install)

$(LN) S20network $(1)/lib/gluon/setup-mode/rc.d/K90network

for link in $(init_links); do \
$(LN) "/etc/init.d/$$$${link:3}" "$(1)/lib/gluon/setup-mode/rc.d/$$$${link}"; \
$(LN) "/etc/init.d/$$$${link:3}" "$(1)/lib/gluon/setup-mode/init.d/$$$${link:3}"; \
$(LN) "../init.d/$$$${link:3}" "$(1)/lib/gluon/setup-mode/rc.d/$$$${link}"; \
done

$(INSTALL_BIN) $(PKG_BUILD_DIR)/ash-wrapper $(1)/lib/gluon/setup-mode/dropbear/ash
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh /etc/rc.common

# shellcheck disable=SC1091

if [ -x /etc/init.d/bootcount ] && /etc/init.d/bootcount enabled; then
. /etc/init.d/bootcount
fi
17 changes: 17 additions & 0 deletions package/gluon-setup-mode/files/lib/gluon/setup-mode/init.d/dnsmasq
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh /etc/rc.common

SETUP_MODE_DHCP_RANGE=192.168.1.2,192.168.1.254


START=60

USE_PROCD=1
PROG=/usr/sbin/dnsmasq


start_service() {
procd_open_instance
procd_set_param command $PROG -k -p 0 -F $SETUP_MODE_DHCP_RANGE -l /tmp/dhcp.leases -O option:router
procd_set_param respawn
procd_close_instance
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh /etc/rc.common

# shellcheck disable=SC1091

[ -x /etc/init.d/dropbear ] || return 0
. /etc/init.d/dropbear

start_service() {
hk_generate_as_needed

procd_open_instance
procd_set_param command /lib/gluon/setup-mode/dropbear/dropbear -F -B
procd_set_param respawn
procd_close_instance
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh /etc/rc.common

START=15

boot() {
local enabled configured
enabled="$(uci -q get 'gluon-setup-mode.@setup_mode[0].enabled')"
configured="$(uci -q get 'gluon-setup-mode.@setup_mode[0].configured')"

uci set 'gluon-setup-mode.@setup_mode[0].enabled=0'
uci commit gluon-setup-mode

if [ "$enabled" != 1 ] && [ "$configured" = 1 ]; then
# This can happen after an upgrade from a version before the config file was called gluon-setup-mode
# We'll just reboot to return to the normal mode...
/etc/init.d/done boot
reboot
fi
}
30 changes: 30 additions & 0 deletions package/gluon-setup-mode/files/lib/gluon/setup-mode/init.d/led
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh /etc/rc.common

# shellcheck disable=SC1091,SC2154

START=96

start() {
local custom_led

/etc/init.d/led start

. /etc/diag.sh

get_status_led 2> /dev/null

if [ -z "$status_led" ]; then
status_led="$running"
fi

if [ -z "$status_led" ]; then
status_led="$boot"
fi

custom_led="$(lua -e 'print(require("gluon.setup-mode").get_status_led() or "")')"
if [ -z "$status_led" ]; then
status_led="$custom_led"
fi

status_led_set_timer 1000 300
}
88 changes: 88 additions & 0 deletions package/gluon-setup-mode/files/lib/gluon/setup-mode/init.d/network
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/bin/sh /etc/rc.common

SETUP_MODE_ADDR=192.168.1.1
SETUP_MODE_NETMASK=255.255.255.0

START=20
STOP=90

USE_PROCD=1


delete_interface() {
[ "$1" = 'loopback' ] || uci_remove network "$1"
}

prepare_config() {
(
export UCI_CONFIG_DIR=/var/gluon/setup-mode/config

mkdir -p "$UCI_CONFIG_DIR"

cp /etc/config/network "$UCI_CONFIG_DIR"

config_load network
config_foreach delete_interface interface

uci_add network interface setup
uci_set network setup ifname "$(lua -e 'print(require("gluon.sysconfig").setup_ifname)')"
uci_set network setup macaddr "$(lua -e 'print(require("gluon.sysconfig").primary_mac)')"
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
)
}

init_switch() {
setup_switch() { return 0; }

include /lib/network
setup_switch
}

start_service() {
prepare_config
init_switch
iw reg set "$(lua -e 'print(require("gluon.site").regdom())')"

procd_open_instance
procd_set_param command /sbin/netifd -c /var/gluon/setup-mode/config
procd_set_param respawn
procd_set_param watch network.interface
[ -e /proc/sys/kernel/core_pattern ] && {
procd_set_param limits core="unlimited"
echo '/tmp/%e.%p.%s.%t.core' > /proc/sys/kernel/core_pattern
}
procd_close_instance
}

reload_service() {
init_switch
ubus call network reload
/sbin/wifi reload_legacy
}

stop_service() {
/sbin/wifi down
}

service_running() {
ubus -t 30 wait_for network.interface
/sbin/wifi reload_legacy
}

restart() {
ifdown -a
sleep 1
trap '' TERM
stop "$@"
start "$@"
}

shutdown() {
ifdown -a
stop
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh /etc/rc.common

# shellcheck disable=SC1091

if [ -x /etc/init.d/urngd ] && /etc/init.d/urngd enabled; then
. /etc/init.d/urngd
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# We need the 'exec sh' here because this script will be mounted over /sbin/procd,
# and we can't umount it while it is still running.

exec sh -ec 'umount /sbin/procd && \
exec /sbin/procd \
-I /lib/gluon/setup-mode/init.d \
-R /lib/gluon/setup-mode/rc.d \
"$@"' - "$@"

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading