summaryrefslogtreecommitdiffstats
path: root/defaultenv
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-02-25 12:26:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-04-24 12:25:21 +0200
commit90df2a955e3c66fee2c59f67d9274e6a9addd9ce (patch)
treead72395e2356aefb3b4a994679040d992d8a7132 /defaultenv
parent5455198d56153b6ca39819c07cf9358ad02883fd (diff)
downloadbarebox-90df2a955e3c66fee2c59f67d9274e6a9addd9ce.tar.gz
defaultenv: Convert init script to C
It's hard to get more complicated things right in hush. This commit converts the /env/bin/init script to C code. With this we get a better error handling and better control what is being done. If /env/bin/init exists in the environment then it is still executed instead of the corresponding C code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'defaultenv')
-rw-r--r--defaultenv/defaultenv-2-base/bin/init79
1 files changed, 0 insertions, 79 deletions
diff --git a/defaultenv/defaultenv-2-base/bin/init b/defaultenv/defaultenv-2-base/bin/init
deleted file mode 100644
index a5d3a98..0000000
--- a/defaultenv/defaultenv-2-base/bin/init
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/sh
-
-export PATH=/env/bin
-
-global hostname
-global user
-global autoboot_timeout
-global autoboot_abort_key
-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.autoboot_abort_key}" ] && global.autoboot_abort_key=any
-magicvar -a global.autoboot_abort_key "key to abort automatic booting (valid options: any, ctrl-c)"
-[ -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 [ "${global.autoboot_abort_key}" = "ctrl-c" ]; then
- abort_string="ctrl-c"
- abort_args="-c"
-else
- abort_string="any key"
- abort_args="-a"
-fi
-
-if [ -e /env/menu ]; then
- echo -e -n "\nHit m for menu or $abort_string to stop autoboot: "
-else
- echo -e -n "\nHit $abort_string to stop autoboot: "
-fi
-
-if [ "$autoboot" = 0 ]; then
- timeout $abort_args $global.autoboot_timeout -v key
- autoboot="$?"
-fi
-
-global.console.ctrlc_allowed=true
-
-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