aboutsummaryrefslogtreecommitdiffstats
path: root/package/block-mount/files/55_determine_extroot_sysupgrade
diff options
context:
space:
mode:
authorDaniel Dickinson <daniel@cshore.neomailbox.net>2011-03-27 06:40:51 +0000
committerDaniel Dickinson <daniel@cshore.neomailbox.net>2011-03-27 06:40:51 +0000
commit012ea4a5a39c8d59c599e7753727950fa5f83809 (patch)
treed29172975565825b660caeecebf697d1404fac1e /package/block-mount/files/55_determine_extroot_sysupgrade
parent116c7cd9bea08f3b6695f7855e04eec2d6c34083 (diff)
downloadupstream-012ea4a5a39c8d59c599e7753727950fa5f83809.tar.gz
upstream-012ea4a5a39c8d59c599e7753727950fa5f83809.tar.bz2
upstream-012ea4a5a39c8d59c599e7753727950fa5f83809.zip
[package] block-mount: Merged block-mount, block-extroot, and block-hotplug into a single binary package called block-mount.
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@26314 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/block-mount/files/55_determine_extroot_sysupgrade')
-rw-r--r--package/block-mount/files/55_determine_extroot_sysupgrade63
1 files changed, 63 insertions, 0 deletions
diff --git a/package/block-mount/files/55_determine_extroot_sysupgrade b/package/block-mount/files/55_determine_extroot_sysupgrade
new file mode 100644
index 0000000000..b0cd9036c2
--- /dev/null
+++ b/package/block-mount/files/55_determine_extroot_sysupgrade
@@ -0,0 +1,63 @@
+#!/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_disabled
+ if [ "${ER_OVERLAY_ROM}" = "/rom" ]; then
+ er_disabled=/tmp/whole_root-disabled
+ else
+ er_disabled=/tmp${ER_OVERLAY_ROM}-disabled
+ fi
+
+ local er_extroot_md5sum
+ if [ -f $md5sum_file ]; then
+ er_extroot_md5sum="$(cat $er_md5sum_file)"
+ fi
+
+ local er_overlay_file="${ER_OVERLAY_ROM}/etc/extroot.md5sum"
+
+ local er_extroot_overlay_md5sum
+ if [ -f "$er_overlay_file" ]; then
+ er_extroot_overlay_md5sum="$(cat $er_overlay_file)"
+ fi
+
+ if [ -z "$er_extroot_overlay_md5sum" ]; then
+ cat $er_md5sum_file >$er_overlay_file
+ elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
+ pi_extroot_mount_success="false"
+ mkdir -p $er_disabled
+ mount --move ${ER_OVERLAY_ROM} $er_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
+