summaryrefslogtreecommitdiffstats
path: root/defaultenv
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-02-20 10:19:25 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2014-02-21 17:06:50 +0100
commitb850dbad6557c4cd0e03c9b83be88579412cdd3f (patch)
tree482bf33f0f795da74243167520c9794523abad6f /defaultenv
parent464a531423f61b5d2c5108843e12ab7057a935bb (diff)
downloadbarebox-b850dbad6557c4cd0e03c9b83be88579412cdd3f.tar.gz
move defaultenv-2 to defaultenv/defaultenv-2-*
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'defaultenv')
-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
-rw-r--r--defaultenv/defaultenv-2-base/boot/net19
-rw-r--r--defaultenv/defaultenv-2-base/config25
-rw-r--r--defaultenv/defaultenv-2-base/data/ansi-colors30
-rw-r--r--defaultenv/defaultenv-2-base/data/boot-template14
-rw-r--r--defaultenv/defaultenv-2-base/init/automount22
-rw-r--r--defaultenv/defaultenv-2-base/init/ps17
-rw-r--r--defaultenv/defaultenv-2-base/network/eth016
-rw-r--r--defaultenv/defaultenv-2-menu/menu/boot-entries-collect13
-rw-r--r--defaultenv/defaultenv-2-menu/menu/boot-entries-edit20
-rw-r--r--defaultenv/defaultenv-2-menu/menu/boot-entries-remove18
-rw-r--r--defaultenv/defaultenv-2-menu/menu/boot-menu-add-entry5
-rw-r--r--defaultenv/defaultenv-2-menu/menu/boot-menu-new-boot-entry21
-rw-r--r--defaultenv/defaultenv-2-menu/menu/init-entries-collect9
-rw-r--r--defaultenv/defaultenv-2-menu/menu/init-entries-edit20
-rw-r--r--defaultenv/defaultenv-2-menu/menu/init-menu-add-entry3
-rw-r--r--defaultenv/defaultenv-2-menu/menu/mainmenu23
-rw-r--r--defaultenv/defaultenv-2-menu/menu/settings21
21 files changed, 493 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 0000000..2d4486c
--- /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 0000000..37b986c
--- /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 0000000..3a0e93b
--- /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 0000000..58c9fa7
--- /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
diff --git a/defaultenv/defaultenv-2-base/boot/net b/defaultenv/defaultenv-2-base/boot/net
new file mode 100644
index 0000000..05bb728
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/boot/net
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ boot-menu-add-entry "$0" "network (tftp, nfs)"
+ exit
+fi
+
+path="/mnt/tftp"
+
+global.bootm.image="${path}/${global.user}-linux-${global.hostname}"
+
+oftree="${path}/${global.user}-oftree-${global.hostname}"
+if [ -f "${oftree}" ]; then
+ global.bootm.oftree="$oftree"
+fi
+
+nfsroot="/home/${global.user}/nfsroot/${global.hostname}"
+bootargs-ip
+global.linux.bootargs.dyn.root="root=/dev/nfs nfsroot=$nfsroot,v3,tcp"
diff --git a/defaultenv/defaultenv-2-base/config b/defaultenv/defaultenv-2-base/config
new file mode 100644
index 0000000..784ae52
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/config
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+# change network settings in /env/network/eth0
+# change mtd partition settings and automountpoints in /env/init/*
+
+#global.hostname=
+
+# set to false if you do not want to have colors
+#global.allow_color=true
+
+# user (used for network filenames)
+#global.user=none
+
+# timeout in seconds before the default boot entry is started
+#global.autoboot_timeout=3
+
+# list of boot entries. These are executed in order until one
+# succeeds. An entry can be:
+# - a filename in /env/boot/
+# - a full path to a directory. All files in this directory are
+# treated as boot files and executed in alphabetical order
+#global.boot.default=net
+
+# base bootargs
+#global.linux.bootargs.base="console=ttyS0,115200"
diff --git a/defaultenv/defaultenv-2-base/data/ansi-colors b/defaultenv/defaultenv-2-base/data/ansi-colors
new file mode 100644
index 0000000..6365329
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/data/ansi-colors
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+if [ ${global.allow_color} != "true" ]; then
+ exit
+fi
+
+# Colors
+export RED='\e[1;31m'
+export BLUE='\e[1;34m'
+export GREEN='\e[1;32m'
+export CYAN='\e[1;36m'
+export YELLOW='\e[1;33m'
+export PINK='\e[1;35m'
+export WHITE='\e[1;37m'
+
+export DARK_RED='\e[2;31m'
+export DARK_BLUE='\e[2;34m'
+export DARK_GREEN='\e[2;32m'
+export DARK_CYAN='\e[2;36m'
+export DARK_YELLOW='\e[2;33m'
+export DARK_PINK='\e[2;35m'
+export DARK_WHITE='\e[2;37m'
+
+export RED_INV='\e[1;41m'
+export BLUE_INV='\e[1;44m'
+export GREEN_INV='\e[1;42m'
+export CYAN_INV='\e[1;46m'
+export ORANGE_INV='\e[1;43m'
+export PINK_INV='\e[1;45m'
+export NC='\e[0m' # No Color
diff --git a/defaultenv/defaultenv-2-base/data/boot-template b/defaultenv/defaultenv-2-base/data/boot-template
new file mode 100644
index 0000000..9297499
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/data/boot-template
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ boot-menu-add-entry "$0" "<menu text here>"
+ exit
+fi
+
+global.bootm.image=<path to image>
+#global.bootm.oftree=<path to oftree>
+#global.bootm.initrd=<path to initrd>
+
+#bootargs-ip
+
+global.linux.bootargs.dyn.root="root=<rootfs here>"
diff --git a/defaultenv/defaultenv-2-base/init/automount b/defaultenv/defaultenv-2-base/init/automount
new file mode 100644
index 0000000..fe56d92
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/init/automount
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [ "$1" = menu ]; then
+ init-menu-add-entry "$0" "Automountpoints"
+ exit
+fi
+
+# automount tftp server based on $eth0.serverip
+
+mkdir -p /mnt/tftp
+automount /mnt/tftp 'ifup eth0 && mount -t tftp $eth0.serverip /mnt/tftp'
+
+# automount nfs server example
+
+#nfshost=somehost
+#mkdir -p /mnt/${nfshost}
+#automount /mnt/$nfshost "ifup eth0 && mount -t nfs ${nfshost}:/tftpboot /mnt/${nfshost}"
+
+# FAT on usb disk example
+
+#mkdir -p /mnt/fat
+#automount -d /mnt/fat 'usb && [ -e /dev/disk0.0 ] && mount /dev/disk0.0 /mnt/fat'
diff --git a/defaultenv/defaultenv-2-base/init/ps1 b/defaultenv/defaultenv-2-base/init/ps1
new file mode 100644
index 0000000..02d7b4b
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/init/ps1
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ ${global.allow_color} = "true" ]; then
+ export PS1="\e[1;32mbarebox@\e[1;36m\h:\w\e[0m "
+else
+ export PS1="barebox@\h:\w "
+fi
diff --git a/defaultenv/defaultenv-2-base/network/eth0 b/defaultenv/defaultenv-2-base/network/eth0
new file mode 100644
index 0000000..7e731ca
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/network/eth0
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+# ip setting (static/dhcp)
+ip=dhcp
+global.dhcp.vendor_id=barebox-${global.hostname}
+
+# static setup used if ip=static
+ipaddr=
+netmask=
+gateway=
+serverip=
+
+# MAC address if needed
+#ethaddr=xx:xx:xx:xx:xx:xx
+
+# put code to discover eth0 (i.e. 'usb') to /env/network/eth0-discover
diff --git a/defaultenv/defaultenv-2-menu/menu/boot-entries-collect b/defaultenv/defaultenv-2-menu/menu/boot-entries-collect
new file mode 100644
index 0000000..c066c93
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/boot-entries-collect
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+cd /env/boot
+
+./$global.boot.default menu
+
+for i in *; do
+ if [ "$i" != "$global.boot.default" ]; then
+ ./$i menu
+ fi
+done
+
+cd /
diff --git a/defaultenv/defaultenv-2-menu/menu/boot-entries-edit b/defaultenv/defaultenv-2-menu/menu/boot-entries-edit
new file mode 100644
index 0000000..c4e1c3d
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/boot-entries-edit
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+ menu -a -m boot_entries_edit -d "\e[1;36mEdit boot entries\e[0m"
+
+ boot-entries-collect
+
+ menu -e -a -m boot_entries_edit -c "boot-menu-new-boot-entry" -d "Add a new entry"
+ menu -e -a -m boot_entries_edit -c "boot-entries-remove" -d "Remove an entry"
+ menu -e -a -m boot_entries_edit -c "menu_exit=true" -d "back"
+
+ menu -s -m boot_entries_edit
+ menu -r -m boot_entries_edit
+
+ if [ $menu_exit = true ]; then
+ exit
+ fi
+done
diff --git a/defaultenv/defaultenv-2-menu/menu/boot-entries-remove b/defaultenv/defaultenv-2-menu/menu/boot-entries-remove
new file mode 100644
index 0000000..566be9d
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/boot-entries-remove
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+ menu -a -m boot_entries_remove -d "\e[1;36mRemove Boot entry\e[0m"
+
+ boot-entries-collect
+
+ menu -e -a -m boot_entries_remove -c "menu_exit=true" -d "back"
+
+ menu -s -m boot_entries_remove
+ menu -r -m boot_entries_remove
+
+ if [ $menu_exit = true ]; then
+ exit
+ fi
+done
diff --git a/defaultenv/defaultenv-2-menu/menu/boot-menu-add-entry b/defaultenv/defaultenv-2-menu/menu/boot-menu-add-entry
new file mode 100644
index 0000000..f06c524
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/boot-menu-add-entry
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+menu -e -a -m boot -c "boot -v $1; echo; readline \"press enter to continue\" a " -d "Boot: ${GREEN}$2${NC}"
+menu -e -a -m boot_entries_edit -c "$global.editcmd /env/boot/$1" -d "${GREEN}$2${NC}"
+menu -e -a -m boot_entries_remove -c "rm /env/boot/$1" -d "${GREEN}$2${NC}"
diff --git a/defaultenv/defaultenv-2-menu/menu/boot-menu-new-boot-entry b/defaultenv/defaultenv-2-menu/menu/boot-menu-new-boot-entry
new file mode 100644
index 0000000..c5e982c
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/boot-menu-new-boot-entry
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+name=
+
+readline "Name of the new entry: " name
+
+if [ -z "$name" ]; then
+ exit 1
+fi
+
+if [ -e "/env/boot/$name" ]; then
+ echo "entry $name already exists"
+ readline "<enter>" unused
+ exit 1
+fi
+
+cp /env/data/boot-template /env/boot/$name
+
+edit /env/boot/$name
+
+boot-menu-show rebuild
diff --git a/defaultenv/defaultenv-2-menu/menu/init-entries-collect b/defaultenv/defaultenv-2-menu/menu/init-entries-collect
new file mode 100644
index 0000000..dbb7757
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/init-entries-collect
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+cd /env/init
+
+for i in *; do
+ ./$i menu
+done
+
+cd /
diff --git a/defaultenv/defaultenv-2-menu/menu/init-entries-edit b/defaultenv/defaultenv-2-menu/menu/init-entries-edit
new file mode 100644
index 0000000..fc02b32
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/init-entries-edit
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+ menu -a -m init_entries_edit -d "\e[1;36mEdit init entries\e[0m"
+
+ menu -e -a -m init_entries_edit -R -c "true" -d ">> Reset board to let changes here take effect <<"
+
+ init-entries-collect
+
+ menu -e -a -m init_entries_edit -c "menu_exit=true" -d "back"
+
+ menu -s -m init_entries_edit
+ menu -r -m init_entries_edit
+
+ if [ $menu_exit = true ]; then
+ exit
+ fi
+done
diff --git a/defaultenv/defaultenv-2-menu/menu/init-menu-add-entry b/defaultenv/defaultenv-2-menu/menu/init-menu-add-entry
new file mode 100644
index 0000000..7cb5686
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/init-menu-add-entry
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+menu -e -a -m init_entries_edit -c "$global.editcmd /env/init/$1" -d "\e[1;32m$2\e[0m"
diff --git a/defaultenv/defaultenv-2-menu/menu/mainmenu b/defaultenv/defaultenv-2-menu/menu/mainmenu
new file mode 100644
index 0000000..f10f67a
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/mainmenu
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+savepath=$PATH
+export menupath=$PATH:/env/menu
+
+. /env/data/ansi-colors
+
+while true; do
+ export PATH=${menupath}
+
+ echo $PATH
+
+ menu -a -m boot -d "${CYAN}Welcome to Barebox${NC}"
+
+ boot-entries-collect
+
+ menu -e -a -m boot -c "settings" -d "Settings"
+ menu -e -a -m boot -c 'PATH=$savepath; echo "enter exit to return to menu"; sh' -d "${DARK_YELLOW}Shell${NC}"
+ menu -e -a -m boot -c reset -d "${RED}Reset${NC}"
+
+ menu -s -m boot
+ menu -r -m boot
+done
diff --git a/defaultenv/defaultenv-2-menu/menu/settings b/defaultenv/defaultenv-2-menu/menu/settings
new file mode 100644
index 0000000..db619af
--- /dev/null
+++ b/defaultenv/defaultenv-2-menu/menu/settings
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+export menu_exit=false
+
+while true; do
+ menu -a -m settings -d "${CYAN}Settings${NC}"
+
+ menu -e -a -R -m settings -c "$global.editcmd /env/network/eth0" -d "Network settings"
+ menu -e -a -R -m settings -c "$global.editcmd /env/config" -d "Config settings"
+ menu -e -a -m settings -c "boot-entries-edit" -d "Edit boot entries"
+ menu -e -a -m settings -c "init-entries-edit" -d "Edit init entries"
+ menu -e -a -R -m settings -c "saveenv || echo \"failed to save environment\" && sleep 2" -d "Save settings"
+ menu -e -a -m settings -c "menu_exit=true" -d "back"
+
+ menu -s -m settings
+ menu -r -m settings
+
+ if [ $menu_exit = true ]; then
+ exit
+ fi
+done