9
0
Fork 0

defenv-2: improve boot script

- add usage information
- add option parsing:
  -v verbose
  -v -v more verbose
  -l list b´possible boot sources
  -d dryrun

The dryrun option sets the global variables necessary for booting
but does not actually boot the system. This way it is possible to
make additional adjustments to the boot variables and then invoke
bootm manually.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2012-07-04 23:50:14 +02:00
parent 4561eae51a
commit 4604923f0c
2 changed files with 40 additions and 3 deletions

View File

@ -508,6 +508,7 @@ config DEFAULT_ENVIRONMENT_GENERIC_NEW
select GLOB_SORT
select CMD_GLOBAL
select CMD_AUTOMOUNT
select CMD_BASENAME
select FLEXIBLE_BOOTARGS
prompt "Generic environment template"

View File

@ -1,5 +1,38 @@
#!/bin/sh
verbose=
dryrun=
usage="
$0 [OPTIONS] [source]\n
-v verbose\n
-d dryrun\n
-l list boot sources\n
-h help"
for i in /env/boot/*; do
basename $i s
sources="$sources$s "
done
while getopt "vdhl" opt; do
if [ ${opt} = v ]; then
if [ -n "$verbose" ]; then
verbose="-v -v"
else
verbose="-v"
fi
elif [ ${opt} = d ]; then
dryrun=1
elif [ ${opt} = l ]; then
echo -e "boot sources:\n$sources"
exit 0
elif [ ${opt} = h ]; then
echo -e "$usage"
exit 0
fi
done
if [ $# = 0 ]; then
scr="$global.boot.default"
else
@ -8,11 +41,14 @@ fi
if [ -n "$scr" ]; then
if [ ! -f /env/boot/$scr ]; then
echo -e "/env/boot/$scr does not exist.\nValid choices:"
ls /env/boot
echo -e "/env/boot/$scr does not exist.Valid choices:\n$sources"
exit
fi
/env/boot/$scr
fi
bootm
if [ -n "$dryrun" ]; then
exit 0
fi
bootm $verbose