summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base/bin/init
blob: 6f3a34dbacacd28d8f3db35cac45f77214dae797 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh

export PATH=/env/bin

global hostname
global user
global autoboot_timeout
global boot.default
global linux.bootargs.base
global linux.bootargs.console
#linux.bootargs.dyn.* will be cleared at the beginning of boot
global linux.bootargs.dyn.ip
global linux.bootargs.dyn.root
global editcmd

[ -z "${global.hostname}" ] && global.hostname=generic
[ -z "${global.user}" ] && global.user=none
magicvar -a global.user "username (used in network filenames)"
[ -z "${global.autoboot_timeout}" ] && global.autoboot_timeout=3
magicvar -a global.autoboot_timeout "timeout in seconds before automatic booting"
[ -z "${global.boot.default}" ] && global.boot.default=net
[ -z "${global.editcmd}" ] && global.editcmd=sedit

[ -e /env/config-board ] && /env/config-board
/env/config

# allow to stop the boot before execute the /env/init/*
# but without waiting
timeout -s -a -v key 0
autoboot="$?"

echo -e -n "\e[?25h"
if [ "${key}" = "q" ]; then
	exit
fi

for i in /env/init/*; do
	. $i
done

if [ -e /env/menu ]; then
	echo -e -n "\nHit m for menu or any other key to stop autoboot: "
else
	echo -e -n "\nHit any key to stop autoboot: "
fi

if [ "$autoboot" = 0 ]; then
	timeout -a $global.autoboot_timeout -v key
	autoboot="$?"
fi

if [ "${key}" = "q" ]; then
	exit
fi

if [ "$autoboot" = 0 ]; then
	boot
fi

if [ -e /env/menu ]; then
	if [ "${key}" != "m" ]; then
		echo -e "\ntype exit to get to the menu"
		sh
	fi
	/env/menu/mainmenu
fi