summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base/bin
diff options
context:
space:
mode:
Diffstat (limited to 'defaultenv/defaultenv-2-base/bin')
-rw-r--r--defaultenv/defaultenv-2-base/bin/bootargs-ip11
-rw-r--r--defaultenv/defaultenv-2-base/bin/ifup67
-rw-r--r--defaultenv/defaultenv-2-base/bin/init80
-rw-r--r--defaultenv/defaultenv-2-base/bin/mtdparts-add49
4 files changed, 207 insertions, 0 deletions
diff --git a/defaultenv/defaultenv-2-base/bin/bootargs-ip b/defaultenv/defaultenv-2-base/bin/bootargs-ip
new file mode 100644
index 0000000000..2d4486caf8
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/bootargs-ip
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+# pass either static ip or dhcp to kernel based on barebox settings
+
+. /env/network/eth0
+
+if [ $ip = dhcp ]; then
+ global.linux.bootargs.dyn.ip="ip=dhcp"
+else
+ global.linux.bootargs.dyn.ip="ip=$ipaddr:$serverip:$gateway:$netmask::eth0:"
+fi
diff --git a/defaultenv/defaultenv-2-base/bin/ifup b/defaultenv/defaultenv-2-base/bin/ifup
new file mode 100644
index 0000000000..37b986c44b
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/ifup
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+mkdir -p /tmp/network
+
+if [ $# != 1 ]; then
+ echo "usage: ifup <interface>"
+ exit 1
+fi
+
+interface="$1"
+
+if [ -f /tmp/network/$interface ]; then
+ exit 0
+fi
+
+cmd=/env/network/$interface
+
+if [ ! -e $cmd ]; then
+ echo "$f: no such file"
+ exit 1
+fi
+
+ip=
+ipaddr=
+netmask=
+gateway=
+serverip=
+ethaddr=
+
+. $cmd
+
+if [ $? != 0 ]; then
+ echo "failed to bring up $interface"
+ exit 1
+fi
+
+if [ -f /env/network/${interface}-discover ]; then
+ /env/network/${interface}-discover
+ if [ $? != 0 ]; then
+ echo "failed to discover eth0"
+ exit 1
+ fi
+fi
+
+if [ -n "$ethaddr" ]; then
+ ${interface}.ethaddr=$ethaddr
+fi
+
+if [ "$ip" = static ]; then
+ ${interface}.ipaddr=$ipaddr
+ ${interface}.netmask=$netmask
+ ${interface}.serverip=$serverip
+ ${interface}.gateway=$gateway
+ ret=0
+elif [ "$ip" = dhcp ]; then
+ dhcp
+ ret=$?
+ if [ $ret = 0 -a -n "$serverip" ]; then
+ ${interface}.serverip=$serverip
+ fi
+fi
+
+if [ $ret = 0 ]; then
+ echo -o /tmp/network/$interface up
+fi
+
+exit $ret
diff --git a/defaultenv/defaultenv-2-base/bin/init b/defaultenv/defaultenv-2-base/bin/init
new file mode 100644
index 0000000000..3a0e93b49d
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/init
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+export PATH=/env/bin
+
+global hostname
+global user
+global autoboot_timeout
+global boot.default
+global allow_color
+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
+[ -z "${global.autoboot_timeout}" ] && global.autoboot_timeout=3
+[ -z "${global.boot.default}" ] && global.boot.default=net
+[ -z "${global.allow_color}" ] && global.allow_color=true
+[ -z "${global.editcmd}" ] && global.editcmd=sedit
+
+[ -e /env/config-board ] && /env/config-board
+/env/config
+
+# request password to login if a timeout is specified and password set
+if [ -n ${global.login.timeout} ]; then
+ [ ${global.login.timeout} -gt 0 ] && login_cmd=login
+fi
+# allow the input if not
+[ -n ${global.console.input_allow} ] && global.console.input_allow=1
+
+# allow to stop the boot before execute the /env/init/*
+# but without waiting
+timeout -s -a -v key 0
+
+if [ "${key}" = "q" ]; then
+ ${login_cmd}
+ exit
+fi
+
+[ -n ${login_cmd} ] && global.console.input_allow=0
+
+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
+
+[ -n ${login_cmd} ] && global.console.input_allow=1
+
+timeout -a $global.autoboot_timeout -v key
+autoboot="$?"
+
+[ -n ${login_cmd} ] && global.console.input_allow=0
+
+if [ "${key}" = "q" ]; then
+ ${login_cmd}
+ exit
+fi
+
+if [ "$autoboot" = 0 ]; then
+ boot
+fi
+
+if [ -e /env/menu ]; then
+ ${login_cmd}
+ if [ "${key}" != "m" ]; then
+ echo -e "\ntype exit to get to the menu"
+ sh
+ fi
+ /env/menu/mainmenu
+fi
+
+${login_cmd}
diff --git a/defaultenv/defaultenv-2-base/bin/mtdparts-add b/defaultenv/defaultenv-2-base/bin/mtdparts-add
new file mode 100644
index 0000000000..58c9fa7a21
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/mtdparts-add
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+mkdir -p /tmp/mtdparts
+
+parts=
+device=
+kernelname=
+bbdev=
+
+while getopt "p:d:k:b" opt; do
+ if [ ${opt} = p ]; then
+ parts=${OPTARG}
+ elif [ ${opt} = d ]; then
+ device=${OPTARG}
+ elif [ ${opt} = k ]; then
+ kernelname=${OPTARG}
+ elif [ ${opt} = b ]; then
+ bbdev=true
+ fi
+done
+
+if [ -z "${device}" ]; then
+ echo "$0: no device given"
+ exit
+fi
+
+if [ -z "${parts}" ]; then
+ echo "$0: no partitions given"
+ exit
+fi
+
+if [ -e /tmp/mtdparts/${device} ]; then
+ if [ -n "/dev/${device}.*.bb" ]; then
+ nand -d /dev/${device}.*.bb
+ fi
+ delpart /dev/${device}.*
+fi
+
+addpart -n /dev/${device} "$parts" || exit
+mkdir -p /tmp/mtdparts/${device}
+
+if [ -n "${bbdev}" ]; then
+ nand -a /dev/${device}.*
+fi
+
+if [ -n ${kernelname} ]; then
+ global linux.mtdparts.${device}
+ global.linux.mtdparts.${device}="${kernelname}:${parts}"
+fi