[package]: block-extroot: Fixed hang when no modules in on either squashfs or jffs2...
[openwrt/svn-archive/archive.git] / package / block-extroot / files / 55_determine_extroot_sysupgrade
1 #!/bin/sh
2 # Copyright (C) 2010 Daniel Dickinson
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
5
6
7 check_set_md5sum() {
8 local er_md5sum_file
9 er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
10
11 local er_extroot_md5sum
12 if [ -f $md5sum_file ]; then
13 er_extroot_md5sum="$(cat $er_md5sum_file)"
14 fi
15
16 local er_extroot_overlay_md5sum
17 if [ -f "/overlay/etc/extroot.md5sum" ]; then
18 er_extroot_overlay_md5sum="$(cat /overlay/.extroot.md5sum)"
19 fi
20
21 if [ -z "$er_extroot_overlay_md5sum" ]; then
22 cat $er_md5sum_file >/overlay/.extroot.md5sum
23 elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
24 pi_extroot_mount_success="false"
25 mkdir -p /tmp/overlay-disabled
26 mount --move /overlay /tmp/overlay-disabled
27 fi
28 }
29
30 set_jffs_md5sum() {
31 # We do this anytime block-extroot exists, even on the first boot with
32 # no extroot defined.
33
34 local er_md5sum_file
35 er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
36
37 local er_extroot_md5sum
38 if [ -f $er_md5sum_file ]; then
39 er_extroot_md5sum="$(cat $er_md5sum_file)"
40 fi
41 if [ -z "$er_extroot_md5sum" ]; then
42 dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file
43 fi
44 }
45
46 determine_extroot_sysupgrade() {
47 check_skip || set_jffs_md5sum
48
49 check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
50 check_set_md5sum
51 }
52 }
53
54 boot_hook_add preinit_mount_root determine_extroot_sysupgrade
55