Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-integ / recipes-core / initrdscripts / initramfs-module-setup-live / setup-live
1 #/bin/sh
2
3 _UDEV_DAEMON=`udev_daemon`
4
5 setup_enabled() {
6         return 0
7 }
8
9 setup_run() {
10 ROOT_IMAGE="rootfs.img"
11 ISOLINUX=""
12 ROOT_DISK=""
13 shelltimeout=60
14
15         if [ -z "$bootparam_root" -o "$bootparam_root" = "/dev/ram0" ]; then
16                 echo "Waiting for removable media..."
17                 udevadm trigger --action=add
18                 udevadm settle
19                 echo "Mounted filesystems"
20                 mount |grep media
21                 C=0
22                 while true
23                 do
24                   for i in `ls /run/media 2>/dev/null`; do
25                       if [ -f /run/media/$i/$ROOT_IMAGE ] ; then
26                                 found="yes"
27                                 ROOT_DISK="$i"
28                                 break
29                           elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then
30                                 found="yes"
31                                 ISOLINUX="isolinux"
32                                 ROOT_DISK="$i"
33                                 break
34                       fi
35                   done
36                   if [ "$found" = "yes" ]; then
37                       break;
38                   fi
39                   # don't wait for more than $shelltimeout seconds, if it's set
40                   if [ -n "$shelltimeout" ]; then
41                       echo " " $(( $shelltimeout - $C ))
42                       if [ $C -ge $shelltimeout ]; then
43                            echo "..."
44                            echo "Mounted filesystems"
45                            mount | grep media
46                            echo "Available block devices"
47                            cat /proc/partitions
48                            msg "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell "
49                            /bin/sh
50                       fi
51                       udevadm trigger --action=add
52                       udevadm settle
53                       echo "Mounted filesystems"
54                       mount |grep media
55                       C=$(( C + 1 ))
56                   fi
57                   sleep 1
58                 done
59                 killall -9 "${_UDEV_DAEMON##*/}" 2>/dev/null
60                 # The existing rootfs module has no support for rootfs images. Assign the rootfs image.
61                 bootparam_root="/run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE"
62         fi
63
64         if [ "$bootparam_LABEL" != "boot" -a -f /init.d/$bootparam_LABEL.sh ] ; then
65                 if [ -f /run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE ] ; then
66                     ./init.d/$bootparam_LABEL.sh $ROOT_DISK/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params
67                 else
68                     msg "Could not find $bootparam_LABEL script"
69                     /bin/sh
70                 fi
71
72                 # If we're getting here, we failed...
73                 msg "Target $bootparam_LABEL failed"
74                 /bin/sh
75         fi
76 }