2 # --- T2-COPYRIGHT-NOTE-BEGIN ---
3 # This copyright note is auto-generated by scripts/Create-CopyPatch.
5 # T2 SDE: target/share/livecd/init
6 # Copyright (C) 2020 The T2 SDE Project
8 # More information can be found in the files COPYING and README.
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; version 2 of the License. A copy of the
13 # GNU General Public License can be found in the file COPYING.
14 # --- T2-COPYRIGHT-NOTE-END ---
17 live
="live=live.squash `cat /proc/cmdline`" ; live
=${live##*live=} ; live
=${live%% *}
18 echo "Searching for media with $live image ..."
19 mkdir
-p /{media
,mnt
}/live
21 while [ $i -le 14 ]; do
22 for x
in /sys
/block
/*/device
; do
23 x
=${x%/device}; x
=${x#/sys/block/}
24 [ "$x" = "*" ] && continue
25 # TODO: make option to skip fixed devices
26 #case "`ls -l /sys/block/$x/device`" in
27 # */usb*|*/ieee1394) : ;;
28 # *) [ "`cat /sys/block/$x/removable`" = 1 ] || continue ;;
33 fs
=`disktype $x 2>/dev/null |
34 sed -e '/file system/!d' -e 's/file system.*//' -e 's/ //g' \
35 -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \
36 -e 's/fat.*/vfat/' | sed -n '$p'`
37 [ $i -gt 2 ] && echo "Testing device $x, type $fs ..."
38 if mount
-t $fs -o ro
$x /media
/live
2>/dev
/null
; then
39 [ $i -gt 0 ] && echo "Successfully mounted $x ..."
40 if [ -f /media
/live
/$live ]; then
41 echo "Found the $live image on $x."
43 if losetup
/dev
/loop0
/media
/live
/$live &&
44 mount
-t squashfs
-o ro
/dev
/loop0
/mnt
/live
48 # setup final directory structure
51 mv /bin
/* /sbin
/* /tmp
/bin
/
52 for x
in /mnt
/live
/* ; do
55 dev|proc|sys|media|mnt|tmp
) continue ;;
58 # echo "Removing /$x ..."
61 # echo "Sym-linking /mnt/live/$x /$x"
62 /tmp
/bin
/ln -s /mnt
/live
/$x /$x
65 # /tmp/bin/ls -l / /tmp
66 # /tmp/bin/rm -rf /tmp/bin
70 echo "Failed to loop-mount $live."
74 echo "No $live image found."
84 echo "No live media found, giving up. Debug shell:"