source: branches/backfire/package/block-extroot/files/50_determine_usb_root @ 23113

Last change on this file since 23113 was 23113, checked in by cshore, 6 years ago

[base system & package/block-extroot] Merged 23110-23112 which allows block-extroot to be
loaded as a module rather than being required to be in the image. Thanks JoW for pushing
and helping with this.

File size: 1.7 KB
Line 
1#!/bin/sh
2# Copyright (C) 2010 Vertical Communications
3# This is free software, licensed under the GNU General Public License v2.
4# See /LICENSE for more information.
5
6
7determine_external_root() {
8        pi_include /lib/functions/extmount.sh
9        pi_include /lib/functions/mount.sh
10
11        local OLD_UCI_CONFIG_DIR="$UCI_CONFIG_DIR"
12        set_jffs_mp
13        determine_root_device
14
15        # extroot requires extroot and fstab config files, therefore
16        # we assume configuration is incomplete and not to be used if either of them
17        # is missing (for jffs versions of these files on squashfs image)
18        if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then
19                UCI_CONFIG_DIR="/tmp/overlay/etc/config"
20                ER_IS_SQUASHFS=true
21        fi
22
23        # For squashfs on firstboot root_device will be tmpfs for the ramoverlay,
24        # unless there is a saved config, in which case it will be /dev/root,
25        # however in the case of a saved config, it won't be restored until after
26        # this script, so there won't be a config on the first boot after
27        # flashing a squashfs-based filesystem
28        # For ext2, ramdisk, or jffs2 root filesystems root_device is /dev/root
29        # For squashfs after firstboot, root filesystem is /dev/root   
30        # We only use the config from the root or jffs if the root_device is
31        # /dev/root
32        [ "$root_device" = "/dev/root" ] && {
33                er_load_modules
34                [ -n "$extroot_settle_time" ] && [ "$extroot_settle_time" -gt 0 ] && {
35                        sleep $extroot_settle_time
36                } 
37                config_load fstab
38                config_foreach config_mount_by_section mount 1
39               
40                [ "$rootfs_found" = "1" ] && grep -q ' /overlay ' /proc/mounts && { 
41                        pi_extroot_mount_success=true
42                        pi_mount_skip_next=false
43                }
44        }
45        UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
46}
47
48boot_hook_add preinit_mount_root determine_external_root
49
Note: See TracBrowser for help on using the repository browser.