3 # By Chih-Wei Huang <cwhuang@linux.org.tw>
4 # and Thorsten Glaser <tg@mirbsd.org>
6 # Last updated 2011/01/01
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)
44 # re-run this script with a controlling tty
45 exec env HAS_CTTY=Yes setsid cttyhack /bin/sh "$0" "$@"
48 # now running under a controlling tty; debug output from stderr into log file
54 # FIXME: any way to mount ntfs gracefully?
55 mount -o $RW $@ || mount.ntfs-3g -o rw,force $@
60 mount -o remount,rw /mnt
65 if which mksh >/dev/null 2>&1; then
66 echo Running MirBSD Korn Shell...
67 USER="($1)" mksh -l 2>&1
69 echo Running busybox ash...
74 echo -n Detecting Android-x86...
79 for device in /dev/sr* /dev/sd[a-z]*; do
80 try_mount ro $device /mnt || continue
82 if [ ! -e ramdisk.img -o ! \( -e system.sfs -o -e system.img -o -d system \) ]; then
87 mount -t tmpfs tmpfs /android
89 zcat /mnt/$SRC/ramdisk.img | cpio -id > /dev/null
90 if [ -e /mnt/$SRC/system.sfs ]; then
91 mount -o loop /mnt/$SRC/system.sfs /sfs
92 mount -o loop /sfs/system.img system
93 elif [ -e /mnt/$SRC/system.img ]; then
94 mount -o loop /mnt/$SRC/system.img system
97 mount --bind /mnt/$SRC/system system
99 mkdir cache mnt mnt/sdcard
100 mount -t tmpfs tmpfs cache
101 echo " found at $device"
104 mountpoint -q /android && break
109 ln -s android/system /
111 ln -s ../system/lib/modules /lib
113 if [ -n "$INSTALL" ]; then
115 zcat /mnt/$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/* /mnt/$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
164 exec chroot /android /init
166 exec switch_root /android /init
172 echo ' Android-x86 console shell. Use only in emergencies.'
174 debug_shell fatal-err