3 # By Chih-Wei Huang <cwhuang@linux.org.tw>
4 # and Thorsten Glaser <tg@mirbsd.org>
6 # Last updated 2011/02/25
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
55 # FIXME: any way to mount ntfs gracefully?
56 mount -o $RW $@ || mount.ntfs-3g -o rw,force $@
61 mount -o remount,rw /mnt
66 if which mksh >/dev/null 2>&1; then
67 echo Running MirBSD Korn Shell...
68 USER="($1)" mksh -l 2>&1
70 echo Running busybox ash...
75 echo -n Detecting Android-x86...
78 for device in /dev/sr* /dev/sd[a-z]*; do
79 try_mount ro $device /mnt || continue
81 if [ ! -e ramdisk.img -o ! \( -e system.sfs -o -e system.img -o -d system \) ]; then
86 mount -t tmpfs tmpfs /android
88 zcat /mnt/$SRC/ramdisk.img | cpio -id > /dev/null
89 if [ -e /mnt/$SRC/system.sfs ]; then
90 mount -o loop /mnt/$SRC/system.sfs /sfs
91 mount -o loop /sfs/system.img system
92 elif [ -e /mnt/$SRC/system.img ]; then
93 mount -o loop /mnt/$SRC/system.img system
96 mount --bind /mnt/$SRC/system system
98 mkdir cache mnt mnt/sdcard
99 mount -t tmpfs tmpfs cache
100 echo " found at $device"
103 mountpoint -q /android && break
109 ln -s android/system /
110 ln -s ../system/lib/modules /lib
111 ln -s ../system/lib/firmware /lib
113 if [ -n "$INSTALL" ]; then
115 zcat /src/install.img | cpio -iud > /dev/null
118 if [ -n "$DEBUG" -o -n "$BUSYBOX" ]; then
120 system/bin/ln -s android/lib /lib
121 system/bin/ln -s android/bin /bin
122 sed -i 's|\(PATH *\)\(/sbin\)|\1/bin:\2|' init.rc
128 if [ -n "$DEBUG" ]; then
129 echo -e "\nType 'exit' to continue booting...\n"
130 debug_shell debug-found
134 for s in `ls /scripts/* /src/scripts/*`; do
135 test -e "$s" && source $s
138 # A target should provide its detect_hardware function.
139 # On success, return 0 with the following values set.
141 # FB0DEV: framebuffer driver
143 # WIFDEV: wifi driver
144 # SNDDEV: sound driver
145 # CAMDEV: camera driver
146 # PREDEV: any module the drivers depend on but can't be loaded automatically
147 # EXTMOD: any other module
149 [ "$AUTO" != "1" ] && detect_hardware && FOUND=1
151 [ -n "$INSTALL" ] && do_install
159 if [ -n "$DEBUG" ]; then
160 echo -e "\nUse Alt-F1/F2/F3 to switch between virtual consoles"
161 echo -e "Type 'exit' to enter Android...\n"
163 debug_shell debug-late
167 # We must disable mdev before switching to Android
168 # since it conflicts with Android's init
169 echo > /proc/sys/kernel/hotplug
171 exec ${SWITCH:-switch_root} /android /init
176 echo ' Android-x86 console shell. Use only in emergencies.'
178 debug_shell fatal-err