X-Git-Url: http://git.ozo.com/?a=blobdiff_plain;f=package%2Fsystem%2Fprocd%2Ffiles%2Fnand-preinit.sh;fp=package%2Fsystem%2Fprocd%2Ffiles%2Fnand-preinit.sh;h=bd2193c9289b23b04a88bc4eda6af8c1acfe1c62;hb=b049c3f4af69006b96a6c1987b48a35015a01f3a;hp=0000000000000000000000000000000000000000;hpb=a1a8c1a6238ed68ce4f2562db6454e3424b7b04d;p=openwrt-github%2F.git diff --git a/package/system/procd/files/nand-preinit.sh b/package/system/procd/files/nand-preinit.sh new file mode 100644 index 0000000000..bd2193c928 --- /dev/null +++ b/package/system/procd/files/nand-preinit.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright (C) 2014 OpenWrt.org + +nand_takeover() { + . /lib/upgrade/nand.sh + mtd=$(find_mtd_index "$CI_UBIPART") + local file_type="$(identify $2)" + mtd -l 400 dump /dev/mtd$mtd > /tmp/takeover.hdr + MAGIC=$(dd if=/tmp/takeover.hdr bs=1 skip=261 count=5 2> /dev/null) + SIZE=$(printf "%d" 0x$(dd if=/tmp/takeover.hdr bs=4 count=1 2> /dev/null | hexdump -v -n 4 -e '1/1 "%02x"')) + [ "$MAGIC" = "ustar" ] && { + mtd -l $((SIZE + 4)) dump /dev/mtd$mtd | dd bs=1 skip=4 of=/tmp/sysupgrade.tar + nand_do_upgrade_stage2 /tmp/sysupgrade.tar + } +} + +boot_hook_add initramfs nand_takeover