diff options
author | cshore <cshore@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2010-12-03 20:01:23 +0000 |
---|---|---|
committer | cshore <cshore@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2010-12-03 20:01:23 +0000 |
commit | d4c88de4acc582d6929dc36fc2eb97d0c3f9785d (patch) | |
tree | 19b741f8ab573440129f9c1632ccae4029608041 /package/block-extroot/files/55_determine_extroot_sysupgrade | |
parent | 7873df547d0423a7da9a3e6c7810b2fc4c30eb3a (diff) |
[package] block-extroot: Added md5sum to extroot and underlying root filesystem. This is used to ensure that the extroot is not mounted as the rootfs after a sysupgrade *until the user deals with the extroot).
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24230 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/block-extroot/files/55_determine_extroot_sysupgrade')
-rw-r--r-- | package/block-extroot/files/55_determine_extroot_sysupgrade | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/package/block-extroot/files/55_determine_extroot_sysupgrade b/package/block-extroot/files/55_determine_extroot_sysupgrade new file mode 100644 index 000000000..21af8b018 --- /dev/null +++ b/package/block-extroot/files/55_determine_extroot_sysupgrade @@ -0,0 +1,55 @@ +#!/bin/sh +# Copyright (C) 2010 Daniel Dickinson +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. + + +check_set_md5sum() { + local er_md5sum_file + er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum" + + local er_extroot_md5sum + if [ -f $md5sum_file ]; then + er_extroot_md5sum="$(cat $er_md5sum_file)" + fi + + local er_extroot_overlay_md5sum + if [ -f "/overlay/etc/extroot.md5sum" ]; then + er_extroot_overlay_md5sum="$(cat /overlay/.extroot.md5sum)" + fi + + if [ -z "$er_extroot_overlay_md5sum" ]; then + cat $er_md5sum_file >/overlay/.extroot.md5sum + elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then + pi_extroot_mount_success="false" + mkdir -p /tmp/overlay-disabled + mount --move /overlay /tmp/overlay-disabled + fi +} + +set_jffs_md5sum() { + # We do this anytime block-extroot exists, even on the first boot with + # no extroot defined. + + local er_md5sum_file + er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum" + + local er_extroot_md5sum + if [ -f $er_md5sum_file ]; then + er_extroot_md5sum="$(cat $er_md5sum_file)" + fi + if [ -z "$er_extroot_md5sum" ]; then + dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file + fi +} + +determine_extroot_sysupgrade() { + check_skip || set_jffs_md5sum + + check_skip || [ "$pi_extroot_mount_success" != "true" ] || { + check_set_md5sum + } +} + +boot_hook_add preinit_mount_root determine_extroot_sysupgrade + |