gluon-setup-mode: provide alternative rc.d directory for procd
This commit is contained in:
parent
60e0a5601c
commit
cd0a932ac0
@ -1,88 +0,0 @@
|
|||||||
#!/bin/sh /etc/rc.common
|
|
||||||
|
|
||||||
START=15
|
|
||||||
|
|
||||||
|
|
||||||
SETUP_MODE_ADDR=192.168.1.1
|
|
||||||
SETUP_MODE_NETMASK=255.255.255.0
|
|
||||||
|
|
||||||
SETUP_MODE_DHCP_RANGE=192.168.1.2,192.168.1.254
|
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_network() {
|
|
||||||
(
|
|
||||||
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 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
|
|
||||||
|
|
||||||
SERVICE_DAEMONIZE=1
|
|
||||||
SERVICE_WRITE_PID=1
|
|
||||||
service_start /sbin/netifd -c "$UCI_CONFIG_DIR"
|
|
||||||
|
|
||||||
setup_switch() { return 0; }
|
|
||||||
|
|
||||||
include /lib/network
|
|
||||||
setup_switch
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
start() {
|
|
||||||
enable=0
|
|
||||||
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-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/setup-mode/ash-login
|
|
||||||
/etc/init.d/dropbear start
|
|
||||||
|
|
||||||
/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 $SETUP_MODE_DHCP_RANGE -l /tmp/dhcp.leases -O option:router
|
|
||||||
|
|
||||||
/etc/init.d/led start
|
|
||||||
|
|
||||||
# correctly finish firstboot
|
|
||||||
/etc/init.d/done boot
|
|
||||||
|
|
||||||
. /etc/diag.sh
|
|
||||||
get_status_led
|
|
||||||
status_led_set_timer 1000 300
|
|
||||||
|
|
||||||
# block further boot
|
|
||||||
while true; do sleep 1; done
|
|
||||||
fi
|
|
||||||
}
|
|
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/dropbear
|
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/K89log
Symbolic link
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/K89log
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/log
|
@ -0,0 +1 @@
|
|||||||
|
S20network
|
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/K98boot
Symbolic link
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/K98boot
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/boot
|
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/umount
|
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/sysfixtime
|
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S10boot
Symbolic link
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S10boot
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/boot
|
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/system
|
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/sysctl
|
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S12log
Symbolic link
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S12log
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/log
|
5
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S13haveged
Executable file
5
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S13haveged
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
if /etc/init.d/haveged enabled; then
|
||||||
|
. /etc/init.d/haveged
|
||||||
|
fi
|
10
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S15gluon-setup-mode
Executable file
10
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S15gluon-setup-mode
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=15
|
||||||
|
|
||||||
|
|
||||||
|
boot() {
|
||||||
|
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
|
||||||
|
}
|
86
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
Executable file
86
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S20network
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/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 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
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/dropbear
|
12
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50telnet
Executable file
12
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50telnet
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=50
|
||||||
|
|
||||||
|
USE_PROCD=1
|
||||||
|
PROG=/usr/sbin/telnetd
|
||||||
|
|
||||||
|
start_service() {
|
||||||
|
procd_open_instance
|
||||||
|
procd_set_param command "$PROG" -F -l /lib/gluon/setup-mode/ash-login
|
||||||
|
procd_close_instance
|
||||||
|
}
|
14
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50uhttpd
Executable file
14
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S50uhttpd
Executable file
@ -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/setup-mode/www -x /cgi-bin -A 1 -R -p 0.0.0.0:80
|
||||||
|
procd_close_instance
|
||||||
|
}
|
17
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S60dnsmasq
Executable file
17
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S60dnsmasq
Executable file
@ -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
|
||||||
|
}
|
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S95done
Symbolic link
1
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S95done
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
/etc/init.d/done
|
9
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S96led
Executable file
9
package/gluon-setup-mode/files/lib/gluon/setup-mode/rc.d/S96led
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
|
||||||
|
START=96
|
||||||
|
|
||||||
|
start() {
|
||||||
|
. /etc/diag.sh
|
||||||
|
get_status_led
|
||||||
|
status_led_set_timer 1000 300
|
||||||
|
}
|
22
package/gluon-setup-mode/files/lib/preinit/90_setup_mode
Normal file
22
package/gluon-setup-mode/files/lib/preinit/90_setup_mode
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
|
||||||
|
check_enable() {
|
||||||
|
local enabled
|
||||||
|
local configured
|
||||||
|
|
||||||
|
config_get enabled "$1" enabled
|
||||||
|
config_get configured "$1" configured
|
||||||
|
|
||||||
|
if [ "$enabled" = 1 -o "$configured" != 1 ]; then
|
||||||
|
echo '/lib/gluon/setup-mode/rc.d' > /tmp/rc_d_path
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
setup_mode_enable() {
|
||||||
|
config_load gluon-setup-mode
|
||||||
|
config_foreach check_enable setup_mode
|
||||||
|
}
|
||||||
|
|
||||||
|
boot_hook_add preinit_main setup_mode_enable
|
Loading…
Reference in New Issue
Block a user