summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initrdscripts/files/init-live.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/initrdscripts/files/init-live.sh')
-rw-r--r--meta/recipes-core/initrdscripts/files/init-live.sh92
1 files changed, 92 insertions, 0 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
new file mode 100644
index 0000000000..c96b1f47c3
--- /dev/null
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -0,0 +1,92 @@
1#!/bin/sh
2
3ROOT_MOUNT="/rootfs/"
4ROOT_IMAGE=rootfs.img
5MOUNT="/bin/mount"
6UMOUNT="/bin/umount"
7
8early_setup() {
9 mkdir /proc
10 mkdir /sys
11 mount -t proc proc /proc
12 mount -t sysfs sysfs /sys
13 udevd --daemon
14}
15
16read_args() {
17 [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline`
18 for arg in $CMDLINE; do
19 optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
20 case $arg in
21 root=*)
22 ROOT_DEVICE=$optarg ;;
23 rootfstype=*)
24 ROOT_FSTYPE=$optarg ;;
25 rootdelay=*)
26 rootdelay=$optarg ;;
27 LABEL=*)
28 label=$optarg ;;
29 video=*)
30 video_mode=$arg ;;
31 vga=*)
32 vga_mode=$arg ;;
33 esac
34 done
35}
36
37boot_live_root() {
38 killall udevd
39 cd $ROOT_MOUNT
40 exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init
41}
42
43fatal() {
44 echo $1 >$CONSOLE
45 echo >$CONSOLE
46 exec sh
47}
48
49early_setup
50
51[ -z "$CONSOLE" ] && CONSOLE="/dev/console"
52
53read_args
54
55echo "Waiting for removable media..."
56while true
57do
58 for i in `ls /media 2>/dev/null`; do
59 if [ -f /media/$i/$ROOT_IMAGE ] ; then
60 found="yes"
61 break
62 fi
63 done
64 if [ "$found" = "yes" ]; then
65 break;
66 fi
67 sleep 1
68done
69
70case $label in
71 boot)
72 mkdir $ROOT_MOUNT
73 mknod /dev/loop0 b 7 0
74
75 if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ROOT_IMAGE $ROOT_MOUNT ; then
76 fatal "Couldnt mount rootfs image"
77 else
78 boot_live_root
79 fi
80 ;;
81 install)
82 if [ -f /media/$i/$ROOT_IMAGE ] ; then
83 ./install.sh $i $ROOT_IMAGE $video_mode $vga_mode
84 else
85 fatal "Couldnt find install script"
86 fi
87
88 # If we're getting here, we failed...
89 fatal "Installation image failed"
90 ;;
91esac
92