From 51cdefeeb6c7d48c858689f0f7868b31039725b3 Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Wed, 9 Feb 2011 16:07:35 +0200 Subject: [PATCH] flasher: tune error handling and display --- flasher/rootfs/etc/init.d/rc | 6 ++--- flasher/rootfs/etc/updater.sh | 37 ++++++++++++++++++++++++----- flasher/rootfs/etc/updater_funcs.sh | 11 +++++++++ 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/flasher/rootfs/etc/init.d/rc b/flasher/rootfs/etc/init.d/rc index efeddcf..e259af8 100755 --- a/flasher/rootfs/etc/init.d/rc +++ b/flasher/rootfs/etc/init.d/rc @@ -19,9 +19,9 @@ then log "Update FINISHED" log "---------------------------------------------" else - log "---------------------------------------------" - log "Update FAILED" - log "---------------------------------------------" + log_err "---------------------------------------------" + log_err "Update FAILED" + log_err "---------------------------------------------" mkdir -p /mnt/log 2> /dev/null if mount /dev/mmcblk0p1 /mnt/log then diff --git a/flasher/rootfs/etc/updater.sh b/flasher/rootfs/etc/updater.sh index cc4ad6f..6c89886 100755 --- a/flasher/rootfs/etc/updater.sh +++ b/flasher/rootfs/etc/updater.sh @@ -12,6 +12,19 @@ status_uboot_env="already empty" status_uimage="missing" status_rootfs="missing" +cleanup() +{ + cd /tmp + if [ -n "$finalize_mpoint" ] + then + umount $finalize_mpoint 2> /dev/null || true + fi + if [ -n "$rootfs_mpoint" ] + then + umount $rootfs_mpoint 2> /dev/null || true + fi +} + mkdir /mnt/ubifs 2> /dev/null || true if [ ! -e /dev/mmcblk0p1 ] @@ -37,6 +50,21 @@ do continue; fi + if [ -x $mpoint/initialize.sh ] + then + log "" + log "running init script.." + cd $mpoint + if ! ./initialize.sh + then + log "initialize.sh failed." + cleanup + false + fi + log "done." + cd /tmp + fi + for bf in $bootfiles do if [ -e $mpoint/$bf ] @@ -127,6 +155,7 @@ then log $real_md5 else log "INCORRECT" + cleanup false fi @@ -160,16 +189,12 @@ then if ! ./finalize.sh then log "finalize.sh failed." + cleanup false fi log "done." - cd /tmp - umount $finalize_mpoint fi -if [ -n "$rootfs_mpoint" ] -then - umount $rootfs_mpoint 2> /dev/null || true -fi +cleanup exit 0 diff --git a/flasher/rootfs/etc/updater_funcs.sh b/flasher/rootfs/etc/updater_funcs.sh index a13fe4b..ab2c3a3 100644 --- a/flasher/rootfs/etc/updater_funcs.sh +++ b/flasher/rootfs/etc/updater_funcs.sh @@ -7,3 +7,14 @@ log() echo "$@" > $LOG_DEVICE } +log_err() +{ + echo -en "\033[1;31m" + echo "$@" + echo -en "\033[0m" + + echo -en "\033[1;31m" > $LOG_DEVICE + echo "$@" > $LOG_DEVICE + echo -en "\033[0m" > $LOG_DEVICE +} + -- 2.39.2