3 # By Chih-Wei Huang <cwhuang@linux.org.tw>
4 # and Thorsten Glaser <tg@mirbsd.org>
6 # License: GNU Public License
7 # We explicitely grant the right to use the scripts
8 # with Android-x86 project.
11 PATH=/sbin:/bin:/system/bin:/system/xbin; export PATH
14 [ -n "$AUTO_INSTALL" ] && INSTALL=1
16 # configure debugging output
17 if [ -n "$DEBUG" -o -n "$INSTALL" ]; then
22 test -e "$LOG" || busybox mknod $LOG c 1 3
27 if test x"$HAS_CTTY" != x"Yes"; then
28 # initialise /proc and /sys
29 busybox mount -t proc proc /proc
30 busybox mount -t sysfs sys /sys
31 # let busybox install all applets as symlinks
33 # spawn shells on tty 2 and 3 if debug or installer
34 if test -n "$DEBUG" || test -n "$INSTALL"; then
35 # ensure they can open a controlling tty
37 # create device nodes then spawn on them
38 mknod /dev/tty2 c 4 2 && openvt
39 mknod /dev/tty3 c 4 3 && openvt
41 if test -z "$DEBUG" || test -n "$INSTALL"; then
42 echo 0 0 0 0 > /proc/sys/kernel/printk
44 # initialise /dev (first time)
46 echo /sbin/mdev > /proc/sys/kernel/hotplug
48 # re-run this script with a controlling tty
49 exec env HAS_CTTY=Yes setsid cttyhack /bin/sh "$0" "$@"
52 # now running under a controlling tty; debug output from stderr into log file
64 if [ "${ROOT#*:/}" != "$ROOT" ]; then
65 # for NFS roots, use nolock to avoid dependency to portmapper
66 mount -o $RW,noatime,nolock $@
71 mount.ntfs-3g -o rw,force $@
74 mount -o $RW,noatime $@
84 if [ "`dirname $1`" = "/dev" ]; then
87 [ ! -e /dev/block/$blk ] && ln $1 /dev/block
92 try_mount ro $dev /mnt || return 1
93 if [ -n "$iso" -a -e /mnt/$iso ]; then
94 mount --move /mnt /iso
96 mount -o loop /iso/$iso /mnt/iso
98 if [ -e /mnt/$SRC/$RAMDISK ]; then
99 zcat /mnt/$SRC/$RAMDISK | cpio -id > /dev/null
100 elif [ -b /dev/$RAMDISK ]; then
101 zcat /dev/$RAMDISK | cpio -id > /dev/null
105 if [ -e /mnt/$SRC/system.sfs ]; then
106 mount -o loop,noatime /mnt/$SRC/system.sfs /sfs
107 mount -o loop,noatime /sfs/system.img system
108 elif [ -e /mnt/$SRC/system.img ]; then
110 mount -o loop,noatime /mnt/$SRC/system.img system
111 elif [ -s /mnt/$SRC/system/build.prop ]; then
113 mount --bind /mnt/$SRC/system system
114 elif [ -z "$SRC" -a -s /mnt/build.prop ]; then
115 mount --bind /mnt system
128 # "foo" as mount source is given to workaround a Busybox bug with NFS
129 # - as it's ignored anyways it shouldn't harm for other filesystems.
130 mount -o remount,rw foo /mnt
135 if [ -x system/bin/sh ]; then
136 echo Running MirBSD Korn Shell...
137 USER="($1)" system/bin/sh -l 2>&1
138 [ $? -ne 0 ] && /bin/sh 2>&1
140 echo Running busybox ash...
145 echo -n Detecting Android-x86...
147 [ -z "$SRC" -a -n "$BOOT_IMAGE" ] && SRC=`dirname $BOOT_IMAGE`
148 [ -z "$RAMDISK" ] && RAMDISK=ramdisk.img || RAMDISK=${RAMDISK##/dev/}
150 for c in `cat /proc/cmdline`; do
154 eval `echo $c | cut -b1-3,18-`
161 mount -t tmpfs tmpfs /android
164 for device in ${ROOT:-/dev/[hmnsvx][dmrv][0-9a-z]*}; do
165 check_root $device && break 2
166 mountpoint -q /mnt && umount /mnt
173 ln -s android/system /
174 ln -s ../system/lib/firmware ../system/lib/modules /lib
176 if [ -n "$INSTALL" ]; then
177 zcat /src/install.img | ( cd /; cpio -iud > /dev/null )
180 if [ -x system/bin/ln -a -n "$BUSYBOX" ]; then
182 sed -i 's|\( PATH.*\)|\1:/bin|' init.environ.rc
184 busybox mv /sbin/* sbin
186 ln -s android/bin android/lib android/sbin /
191 for s in `ls /scripts/* /src/scripts/*`; do
192 test -e "$s" && source $s
195 # ensure keyboard driver is loaded
196 if [ -n "$INSTALL" -o -n "$DEBUG" ]; then
197 busybox modprobe -a atkbd hid-apple
201 if [ 0$DEBUG -gt 0 ]; then
202 echo -e "\nType 'exit' to continue booting...\n"
203 debug_shell debug-found
206 # A target should provide its detect_hardware function.
207 # On success, return 0 with the following values set.
208 # return 1 if it wants to use auto_detect
209 [ "$AUTO" != "1" ] && detect_hardware && FOUND=1
211 [ -n "$INSTALL" ] && do_install
220 if [ 0$DEBUG -gt 1 ]; then
221 echo -e "\nUse Alt-F1/F2/F3 to switch between virtual consoles"
222 echo -e "Type 'exit' to enter Android...\n"
224 debug_shell debug-late
225 SETUPWIZARD=${SETUPWIZARD:-0}
228 [ "$SETUPWIZARD" = "0" ] && echo "ro.setupwizard.mode=DISABLED" >> default.prop
230 [ -n "$DEBUG" ] && SWITCH=${SWITCH:-chroot}
232 # We must disable mdev before switching to Android
233 # since it conflicts with Android's init
234 echo > /proc/sys/kernel/hotplug
236 export ANDROID_ROOT=/system
238 exec ${SWITCH:-switch_root} /android /init
243 echo ' Android-x86 console shell. Use only in emergencies.'
245 debug_shell fatal-err