summaryrefslogtreecommitdiffstats
path: root/defaultenv
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-01-15 11:00:18 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-02-14 15:01:52 +0100
commit4b06ebc820aa9a46dfb73c7050b073d8224b4b70 (patch)
tree6b3388addb42700a7a4ff96b268733e9366c1c64 /defaultenv
parent9f5c1f2a99c5d417a1d332771c4dc7afb92bc50e (diff)
downloadbarebox-4b06ebc820aa9a46dfb73c7050b073d8224b4b70.tar.gz
barebox-4b06ebc820aa9a46dfb73c7050b073d8224b4b70.tar.xz
defaultenv/boot: add getopt option support to select boot mode
boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>] options - kernel nand, nor, nfs, tftp, disk - rootfs nand, nor, net, disk - ip dhcp, none, empty mode option mode kernel rootfs nand nand nand nor nor nor nfs nfs net tftp fttp net disk disk disk default mode are used from the /env/config Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'defaultenv')
-rw-r--r--defaultenv/bin/_boot_help18
-rw-r--r--defaultenv/bin/boot26
2 files changed, 39 insertions, 5 deletions
diff --git a/defaultenv/bin/_boot_help b/defaultenv/bin/_boot_help
new file mode 100644
index 000000000..e7f7f16f1
--- /dev/null
+++ b/defaultenv/bin/_boot_help
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+echo "boot: boot [-m <mode>] [-k <kernel_option>] [-r <rootfs_option>] [-i <ip_mode>]"
+echo ""
+echo "options"
+echo " - kernel nand, nor, nfs, tftp, disk"
+echo " - rootfs nand, nor, net, disk"
+echo " - ip dhcp, none, empty"
+echo ""
+echo "mode option"
+echo " mode kernel rootfs"
+echo " nand nand nand"
+echo " nor nor nor"
+echo " nfs nfs net"
+echo " tftp fttp net"
+echo " disk disk disk"
+echo ""
+echo "default mode are used from the /env/config"
diff --git a/defaultenv/bin/boot b/defaultenv/bin/boot
index 11207573c..d37eca86a 100644
--- a/defaultenv/bin/boot
+++ b/defaultenv/bin/boot
@@ -6,19 +6,35 @@ if [ x$kernel_loc = xnet ]; then
kernel_loc=tftp
fi
-if [ x$1 = xnand ]; then
+while getopt "hk:r:i:m:" Option
+do
+if [ ${Option} = k ]; then
+ kernel_loc=${OPTARG}
+elif [ ${Option} = r ]; then
+ rootfs_loc=${OPTARG}
+elif [ ${Option} = i ]; then
+ ip=${OPTARG}
+elif [ ${Option} = m ]; then
+ mode=${OPTARG}
+else
+ . /env/bin/_boot_help
+ exit 0
+fi
+done
+
+if [ x$mode = xnand ]; then
rootfs_loc=nand
kernel_loc=nand
-elif [ x$1 = xnor ]; then
+elif [ x$mode = xnor ]; then
rootfs_loc=nor
kernel_loc=nor
-elif [ x$1 = xnfs ]; then
+elif [ x$mode = xnfs ]; then
rootfs_loc=net
kernel_loc=nfs
-elif [ x$1 = xtftp ]; then
+elif [ x$mode = xtftp ]; then
rootfs_loc=net
kernel_loc=tftp
-elif [ x$1 = xdisk ]; then
+elif [ x$mode = xdisk ]; then
rootfs_loc=disk
kernel_loc=disk
fi