Move install/* to .
[debian6500.git] / bios / update_bios_cfg.sh
diff --git a/bios/update_bios_cfg.sh b/bios/update_bios_cfg.sh
new file mode 100755 (executable)
index 0000000..cbc1102
--- /dev/null
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+PROGNAME=$(basename $0)
+
+# check binary directory
+
+mydir=$(dirname $0)
+mydir=$(cd $mydir; pwd)
+
+# formating functions
+
+_echo () { printf "$@\n"; }
+title () { _echo "\033[0;1m$*\033[0;0m"; }
+pass () { _echo "\033[1;32m$*\033[0;0m"; }
+warn () { _echo "\033[1;33m$*\033[0;0m"; }
+fail () { _echo "\033[1;31m$*\033[0;0m"; }
+
+usage () {
+  echo "usage: $PROGNAME [-h] [-y] [-Y]"
+  echo " -h: help message"
+  echo " -y: really do update"
+  echo " -Y: do not ask for confirmation"
+  exit $@
+}
+
+# do command
+
+do_cmd () {
+  if [ "$DUMMY" = "no" ]; then
+    warn $@
+    { eval $@; } && pass OK || { fail KO; exit 1; }
+  else
+    echo ":: $@"
+  fi
+}
+
+# argument processing
+
+while [ $# -gt 0 ]; do
+  case "$1" in
+  -h) usage 0;;
+  -y) DUMMY=no;;
+  -Y) ANS=yes
+  esac
+  shift
+done
+[ "$DUMMY" = "no" ] && \
+  fail "Real mode, things will really append" || \
+  warn "Dummy mode, nothing will be done"
+if [ ! "$ANS" = "yes" ]; then
+  printf "Press 'y' to continue: "
+  read ANS
+  [ "$ANS" = "y" ] || exit 1
+fi
+
+VERSION=$($mydir/dmidecode | awk '/BIOS Revision/ { print $(NF) }')
+title "BIOS version: $VERSION"
+
+CFG="bios-$VERSION.cfg"
+[ -f $mydir/$CFG ] || { echo "unknown bios version ($VERSION)"; exit 1; }
+
+title "Configure BIOS"
+do_cmd $mydir/SCELNX_64 /i /s $mydir/$CFG /q