Import from Clearcase LIV_TRC6500_V2.2.3
[debian6500.git] / install / bios / update_bios_cfg.sh
1 #!/bin/sh
2
3 PROGNAME=$(basename $0)
4
5 # check binary directory
6
7 mydir=$(dirname $0)
8 mydir=$(cd $mydir; pwd)
9
10 # formating functions
11
12 _echo () { [ "$(echo -e '')" ] && echo $@ || echo -e $@; }
13 title () { _echo "\033[0;1m$*\033[0;0m"; }
14 pass () { _echo "\033[1;32m$*\033[0;0m"; }
15 warn () { _echo "\033[1;33m$*\033[0;0m"; }
16 fail () { _echo "\033[1;31m$*\033[0;0m"; }
17
18 usage () {
19 echo "usage: $PROGNAME [-h] [-y] [-Y]"
20 echo " -h: help message"
21 echo " -y: really do update"
22 echo " -Y: do not ask for confirmation"
23 exit $@
24 }
25
26 # do command
27
28 do_cmd () {
29 if [ "$DUMMY" = "no" ]; then
30 warn $@
31 { eval $@; } && pass OK || { fail KO; exit 1; }
32 else
33 echo ":: $@"
34 fi
35 }
36
37 # argument processing
38
39 while [ $# -gt 0 ]; do
40 case "$1" in
41 -h) usage 0;;
42 -y) DUMMY=no;;
43 -Y) ANS=yes
44 esac
45 shift
46 done
47 [ "$DUMMY" = "no" ] && \
48 fail "Real mode, things will really append" || \
49 warn "Dummy mode, nothing will be done"
50 if [ ! "$ANS" = "yes" ]; then
51 read -p "Press 'y' to continue: " ANS
52 [ "$ANS" = "y" ] || exit 1
53 fi
54
55 VERSION=$($mydir/dmidecode | awk '/BIOS Revision/ { print $(NF) }')
56 title "BIOS version: $VERSION"
57
58 case "$VERSION" in
59 1.0b) CFG="bios-1.0b.cfg";;
60 3.0) CFG="bios-3.0.cfg";;
61 *) echo "unknown bios version ($VERSION)"; exit 1;;
62 esac
63
64 title "Configure BIOS"
65 do_cmd $mydir/SCELNX_64 /i /s $mydir/$CFG /q