3 # By Chih-Wei Huang <cwhuang@linux.org.tw>
4 # and Thorsten Glaser <tg@mirbsd.org>
6 # Last updated 2011/08/18
8 # License: GNU Public License
9 # We explicitely grant the right to use the scripts
10 # with Android-x86 project.
13 PATH=/sbin:/bin:/system/bin:/system/xbin; export PATH
15 # configure debugging output
16 if [ -n "$DEBUG" ]; then
21 test -e "$LOG" || busybox mknod $LOG c 1 3
26 if test x"$HAS_CTTY" != x"Yes"; then
27 # initialise /proc and /sys
28 busybox mount -t proc proc /proc
29 busybox mount -t sysfs sys /sys
30 # let busybox install all applets as symlinks
32 # spawn shells on tty 2 and 3 if debug or installer
33 if test -n "$DEBUG" || test -n "$INSTALL"; then
34 # ensure they can open a controlling tty
36 # create device nodes then spawn on them
37 mknod /dev/tty2 c 4 2 && openvt
38 mknod /dev/tty3 c 4 3 && openvt
40 echo 0 0 0 0 > /proc/sys/kernel/printk
42 # initialise /dev (first time)
43 echo /sbin/mdev > /proc/sys/kernel/hotplug
45 # re-run this script with a controlling tty
46 exec env HAS_CTTY=Yes setsid cttyhack /bin/sh "$0" "$@"
49 # now running under a controlling tty; debug output from stderr into log file
61 if [ "${ROOT#*:/}" != "$ROOT" ]; then
62 # for NFS roots, use nolock to avoid dependency to portmapper
65 # FIXME: any way to mount ntfs gracefully?
66 mount -o $RW $@ || mount.ntfs-3g -o rw,force $@
71 try_mount ro $1 /mnt && [ -e /mnt/$SRC/ramdisk.img ]
72 [ $? -ne 0 ] && return 1
73 zcat /mnt/$SRC/ramdisk.img | cpio -id > /dev/null
74 if [ -e /mnt/$SRC/system.sfs ]; then
75 mount -o loop /mnt/$SRC/system.sfs /sfs
76 mount -o loop /sfs/system.img system
77 elif [ -e /mnt/$SRC/system.img ]; then
78 mount -o loop /mnt/$SRC/system.img system
79 elif [ -d /mnt/$SRC/system ]; then
81 mount --bind /mnt/$SRC/system system
86 mkdir cache mnt mnt/sdcard
87 mount -t tmpfs tmpfs cache
93 # "foo" as mount source is given to workaround a Busybox bug with NFS
94 # - as it's ignored anyways it shouldn't harm for other filesystems.
95 mount -o remount,rw foo /mnt
100 if which mksh >/dev/null 2>&1; then
101 echo Running MirBSD Korn Shell...
102 USER="($1)" mksh -l 2>&1
104 echo Running busybox ash...
109 echo -n Detecting Android-x86...
111 mount -t tmpfs tmpfs /android
114 for device in ${ROOT:-/dev/sr* /dev/[hs]d[a-z]*}; do
115 check_root $device && break 2
116 mountpoint -q /mnt && umount /mnt
123 ln -s android/system /
124 ln -s ../system/lib/modules /lib
125 ln -s ../system/lib/firmware /lib
127 if [ -n "$INSTALL" ]; then
129 zcat /src/install.img | cpio -iud > /dev/null
132 if [ -x system/bin/ln -a \( -n "$DEBUG" -o -n "$BUSYBOX" \) ]; then
134 system/bin/ln -s android/lib /lib
135 system/bin/ln -s android/bin /bin
136 sed -i 's|\(PATH *\)\(/sbin\)|\1/bin:\2|' init.rc
142 # ensure keyboard driver is loaded
143 [ -n "$INSTALL" -o -n "$DEBUG" ] && modprobe atkbd
145 if [ -n "$DEBUG" ]; then
146 echo -e "\nType 'exit' to continue booting...\n"
147 debug_shell debug-found
151 for s in `ls /scripts/* /src/scripts/*`; do
152 test -e "$s" && source $s
155 # A target should provide its detect_hardware function.
156 # On success, return 0 with the following values set.
158 # FB0DEV: framebuffer driver
160 # WIFDEV: wifi driver
161 # SNDDEV: sound driver
162 # CAMDEV: camera driver
163 # PREDEV: any module the drivers depend on but can't be loaded automatically
164 # EXTMOD: any other module
166 [ "$AUTO" != "1" ] && detect_hardware && FOUND=1
168 [ -n "$INSTALL" ] && do_install
177 if [ -n "$DEBUG" ]; then
178 echo -e "\nUse Alt-F1/F2/F3 to switch between virtual consoles"
179 echo -e "Type 'exit' to enter Android...\n"
181 debug_shell debug-late
185 # We must disable mdev before switching to Android
186 # since it conflicts with Android's init
187 echo > /proc/sys/kernel/hotplug
189 exec ${SWITCH:-switch_root} /android /init
194 echo ' Android-x86 console shell. Use only in emergencies.'
196 debug_shell fatal-err