Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | #/bin/sh |
| 2 | # Copyright (C) 2011 O.S. Systems Software LTDA. |
| 3 | # Licensed on MIT |
| 4 | |
| 5 | setup_enabled() { |
| 6 | return 0 |
| 7 | } |
| 8 | |
| 9 | setup_run() { |
| 10 | ROOT_IMAGE="rootfs.img" |
| 11 | ISOLINUX="" |
| 12 | ROOT_DISK="" |
| 13 | shelltimeout=30 |
| 14 | |
| 15 | if [ -z "$bootparam_root" -o "$bootparam_root" = "/dev/ram0" ]; then |
| 16 | echo "Waiting for removable media..." |
| 17 | C=0 |
| 18 | while true |
| 19 | do |
| 20 | for i in `ls /run/media 2>/dev/null`; do |
| 21 | if [ -f /run/media/$i/$ROOT_IMAGE ] ; then |
| 22 | found="yes" |
| 23 | ROOT_DISK="$i" |
| 24 | break |
| 25 | elif [ -f /run/media/$i/isolinux/$ROOT_IMAGE ]; then |
| 26 | found="yes" |
| 27 | ISOLINUX="isolinux" |
| 28 | ROOT_DISK="$i" |
| 29 | break |
| 30 | fi |
| 31 | done |
| 32 | if [ "$found" = "yes" ]; then |
| 33 | break; |
| 34 | fi |
| 35 | # don't wait for more than $shelltimeout seconds, if it's set |
| 36 | if [ -n "$shelltimeout" ]; then |
| 37 | echo -n " " $(( $shelltimeout - $C )) |
| 38 | if [ $C -ge $shelltimeout ]; then |
| 39 | echo "..." |
| 40 | echo "Mounted filesystems" |
| 41 | mount | grep media |
| 42 | echo "Available block devices" |
| 43 | cat /proc/partitions |
| 44 | fatal "Cannot find $ROOT_IMAGE file in /run/media/* , dropping to a shell " |
| 45 | fi |
| 46 | C=$(( C + 1 )) |
| 47 | fi |
| 48 | sleep 1 |
| 49 | done |
| 50 | # The existing rootfs module has no support for rootfs images. Assign the rootfs image. |
| 51 | bootparam_root="/run/media/$ROOT_DISK/$ISOLINUX/$ROOT_IMAGE" |
| 52 | fi |
| 53 | |
| 54 | if [ "$bootparam_LABEL" != "boot" -a -f /init.d/$bootparam_LABEL.sh ] ; then |
| 55 | if [ -f /run/media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then |
| 56 | ./init.d/$bootparam_LABEL.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode $console_params |
| 57 | else |
| 58 | fatal "Could not find $bootparam_LABEL script" |
| 59 | fi |
| 60 | |
| 61 | # If we're getting here, we failed... |
| 62 | fatal "Target $bootparam_LABEL failed" |
| 63 | fi |
| 64 | } |