Cleanup app install. keyboard selection
[xdandroid:rootfs.git] / init
1 #!/bin/sh
2 fail() {
3         /bin/echo "Failed"
4                 /bin/echo "$1"
5                 exec /bin/sh
6 }
7
8 /bin/mount -o remount,rw / /
9
10 PATH=/sbin:/system/sbin:/bin:/system/bin:/system/xbin:/system/xbin/bb:/data/local/bin
11
12 /bin/echo "Rootfs loaded."
13
14 /bin/mount -t proc proc /proc
15 /bin/mount -t sysfs sys /sys
16
17 /bin/mount | grep mtd
18 notnand=$?
19
20 if [ $notnand = "0" ] ; then
21   echo "running from NAND"
22   /bin/mount -t yaffs2 /dev/block/mtdblock2 /system
23   /bin/mount -t yaffs2 /dev/block/mtdblock3 /data
24 fi
25
26 partition=mmcblk0p1
27
28 # Try unpartitioned card
29 if [ ! -d /sys/block/mmcblk0/$partition ] ; then
30         partition=mmcblk0
31 fi
32
33 if [ -f /sys/class/vogue_hw/gsmphone ] ; then
34         echo "GSM phone found"
35 fi
36
37 #mkdir -m 0777 /sdcard
38 #fsck already done in initrd
39 mount -t vfat -o fmask=0000,dmask=0000,rw,flush,relatime,utf8 /dev/block/$partition /sdcard
40 [ $? -eq 0 ] || fail "Failed to mount the SD card. Cannot continue."
41
42 if [ ! -d /sdcard/cache ] ; then
43         mkdir /sdcard/cache
44 fi
45
46 #mkdir -m 0777 /cache
47 mount /sdcard/cache /cache
48
49 CARD_PATH=`/bin/grep -o "rel_path=.*" /proc/cmdline | /bin/sed -e "s/.*rel_path=//g" -e "s/ .*//g"`
50 if [ "$CARD_PATH" = "" ];then
51         CARD_PATH="andboot"
52 fi;
53 if [ -d /sdcard/$CARD_PATH ] ; then
54         card=/sdcard/$CARD_PATH
55 else
56         card=/sdcard
57 fi
58
59
60 if [ $notnand = "1" ] ; then
61     
62     if [ -f $card/data.gz ] ; then
63             echo "Please wait... extracting Data Image"
64             if [ -f $card/data.img ] ; then
65                     rm $card/data.img
66             fi
67             gzip -df $card/data.gz
68             [ $? -eq 0 ] || fail "Failed to extract Data Image"
69             mv $card/data $card/data.img
70             echo "done"
71     fi
72     
73     if [ -d /sys/block/mmcblk0/mmcblk0p4 ] && /bin/grep -q -v no_partitions /proc/cmdline ; then
74             echo "Using partitioned system"
75             /bin/e2fsck -y /dev/block/mmcblk0p3
76             mount -t ext2 -o ro,relatime /dev/block/mmcblk0p3 /system
77             /bin/e2fsck -y /dev/block/mmcblk0p4
78             mount -t ext2 -o relatime /dev/block/mmcblk0p4 /data
79     else
80             echo "Using loopback filesystems"
81             if [ ! -f $card/data.img ] ; then
82                     echo "Creating a new Data store"
83                     dd if=/dev/zero of=$card/data.img bs=1048576 count=256
84                     [ $? -eq 0 ] || fail "Failed to allocate the storage"
85                     mke2fs -F $card/data.img
86                     [ $? -eq 0 ] || fail "Failed to format the storage"
87             fi
88
89             losetup /dev/block/loop0 $card/data.img
90             [ $? -eq 0 ] || fail "Failed to find data.img on SD Card"
91             e2fsck -y /dev/block/loop0
92             mount -t ext2 -o relatime /dev/block/loop0 /data
93
94             if      [ -f $card/system.ext2 ] ; then
95                     echo "Using uncompressed system"
96                     losetup /dev/block/loop1 $card/system.ext2
97                     [ $? -eq 0 ] || fail "Failed to reach system.ext2 on SD Card"
98                     e2fsck -y /dev/block/loop1
99                     mount -t ext2 -o relatime /dev/block/loop1 /system
100                     [ $? -eq 0 ] || fail "Failed to mount /system"
101             elif    
102                     [ -f $card/system.sqsh ] ; then
103                     echo "Using SquashFS system"
104                     losetup /dev/block/loop1 $card/system.sqsh
105                     [ $? -eq 0 ] || fail "Failed to find system.sqsh on SD Card"
106                     mount -t squashfs -o ro,relatime /dev/block/loop1 /system
107                     [ $? -eq 0 ] || fail "Failed to mount /system"
108                     SQUASH=1
109             else
110                     losetup /dev/block/loop1 $card/system.img
111                     [ $? -eq 0 ] || fail "Failed to find system.img on SD Card"
112                     mount -t cramfs -o ro,relatime /dev/block/loop1 /system
113                     [ $? -eq 0 ] || fail "Failed to mount /system"
114             fi
115     fi
116 fi
117
118 if [ -f "$card/update.zip" ] && [ ! -f "/sdcard/cache/recovery/intent" ] && [ -z "$SQUASH" ]
119 then
120         RECOVERYCARD=$(echo $card | sed -e 's:/sdcard/:SDCARD\::')
121
122         echo "STARTING OTA UPDATE SYSTEM"
123         cp /init.cfg/init.recovery.rc /etc/init.rc
124         mkdir /cache/recovery
125         echo "--update_package=${RECOVERYCARD}/update.zip" >/cache/recovery/command
126         echo "--send_intent=complete" >>/cache/recovery/command
127         exec /init.android
128 fi
129
130 # If not updating, ensure old recovery.intent and update.zip files are removed so we can update again later.
131 rm -f /sdcard/cache/recovery/intent
132 rm -f $card/update.zip
133
134 if [ -d $card/AndroidApps ] ; then
135         echo Copying Applications
136         if [ ! -d /data/app ] ; then
137                 mkdir -m 0771 /data/app
138                 chown -R 1000:1000 /data/app
139         fi
140         (cd $card/AndroidApps; for i in *; do if [ "$i" -nt "/data/app/$i" ]; then \
141                 cp "$i" /data/app; fi done)
142 fi
143
144 if [ ! -d $card/media ] ; then
145         echo You have no media folder, please extract the resources to your SD card android folder
146 fi
147
148 NEW_SYSTEM=0
149 NEW_ROOT=0
150
151 if [ ! -d /data/etc ]; then
152         /bin/mkdir -m 0755 /data/etc
153         /bin/mkdir -p -m 0700 /data/mnt/secure
154         mkdir -m 0770 /data/shared_prefs
155         chown 1000:1000 /data/shared_prefs
156         NEW_SYSTEM=1
157         NEW_ROOT=1
158 else
159         CHK_SYS=etc/event-log-tags
160         if [ ! -f /data/$CHK_SYS -o /system/$CHK_SYS -nt /data/$CHK_SYS ]; then
161                 NEW_SYSTEM=1
162         fi
163         CHK_ROOT=etc/wifi/Fw1251r1c.bin
164         if [ ! -f /data/$CHK_ROOT -o /init.$CHK_ROOT -nt /data/$CHK_ROOT ]; then
165                 NEW_ROOT=1
166         fi
167 fi
168
169 mount --bind /data/mnt/secure /mnt/secure
170 mount /data/shared_prefs /shared_prefs
171
172 if [ $NEW_SYSTEM -eq 1 ]; then
173         cp -ar /system/etc/* /data/etc
174 fi
175 if [ $NEW_ROOT -eq 1 ]; then
176         cp -ar /init.etc/* /data/etc
177 fi
178
179 mount /data/etc /etc
180
181 LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
182
183 if [ "$LCDDENSITY" != "" ] ; then
184         DENS2=`grep lcd_density /etc/default.prop | sed -e 's/.*=//'`
185         if [ "$LCDDENSITY" != "$DENS2" ]; then
186                 echo Setting ro.sf.lcd_density=$LCDDENSITY
187                 if [ -z "$DENS2" ]; then
188                         echo "ro.sf.lcd_density=$LCDDENSITY" >> /etc/default.prop
189                 else
190                         sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /etc/default.prop
191                 fi
192         fi
193 fi
194
195 mount /sdcard/cache /tmp
196
197 KAISER=0
198 DIAMOND=0
199 WIFI_TI=0
200 WIFI_BCM=0
201 XPERIA=0
202 WVGA=0
203 HW=`cat /proc/cpuinfo | grep Hardware`
204 case "$HW" in
205     *Kaiser*)
206         echo "KAISER detected"
207         HW=KAISER
208         KAISER=1
209         WIFI_TI=1
210         ;;
211     *Polaris*)
212         echo "POLARIS detected"
213         HW=POLARIS
214         KAISER=1
215         WIFI_TI=1
216         ;;
217     *Diamond*)
218         echo "DIAMOND detected"
219         HW=DIAMOND
220         DIAMOND=1
221         WIFI_TI=1
222         ;;
223     *Raphael*)
224         echo "RAPHAEL detected"
225         HW=RAPHAEL
226         DIAMOND=1
227         WIFI_TI=1
228         ;;
229     *blackstone*)
230         echo "BLACKSTONE detected"
231         HW=BLACKSTONE
232         DIAMOND=1
233         WIFI_TI=1
234         WVGA=1
235         ;;
236     *Topaz*)
237         echo "TOPAZ detected"
238         HW=TOPAZ
239         DIAMOND=1
240         WIFI_TI=1
241         WVGA=1
242         ;;
243     *Kovsky*)
244         echo "XPERIA detected"
245         HW=KOVSKY
246         XPERIA=1
247         WIFI_TI=1
248         WVGA=1
249         ;;
250     *Rhodium*)
251         echo "RHODIUM detected"
252         HW=RHODIUM
253         DIAMOND=1
254         WIFI_BCM=1
255         WVGA=1
256         ;;
257     *)
258         echo "VOGUE detected"
259         HW=VOGUE
260         ;;
261 esac
262
263 ### Fix su on some builds...
264 mount --bind /bin/su /system/bin/su 2> /dev/null
265 mount --bind /bin/su /system/xbin/su 2> /dev/null
266
267 RCSCRIPT=""
268 RCCONFIG=""
269
270 echo "Checking for build type..."
271 if [ -f /system/hero.build ] ; then
272         echo "Hero build detected"
273         RCSCRIPT="hero"
274         RCCONFIG="hero"
275         ln /data/app_s /system/app
276
277 elif [ -f /system/eclairhero.build ] ; then
278         echo "HERO 2.1 BUILD DETECTED -- ECLAIR"
279         RCSCRIPT="eclairhero"
280         RCCONFIG="eclairhero"
281         mount --bind /lib/eclair/hw /system/lib/hw
282
283 elif [ -f /system/eclair.build ] ; then
284         echo "Eclair build detected"
285         RCSCRIPT="eclair"
286         RCCONFIG="eclair"
287         mount --bind /lib/eclair/hw /system/lib/hw
288
289 elif [ -f /system/froyo.build ] ; then
290         echo "Froyo build detected"
291         RCSCRIPT="froyo"
292         RCCONFIG="froyo"
293         mount --bind /lib/froyo/hw /system/lib/hw
294
295         # vold: Fix sdcard device location for CDMA boards (thanks paalsteek)
296         if [ $NEW_SYSTEM -eq 1 -a -d /sys/devices/platform/msm_sdcc.3 ]; then
297                 /bin/sed -i -e 's:/devices/platform/msm_sdcc\.2:/devices/platform/msm_sdcc.3:g' /etc/vold.fstab
298         fi
299
300 elif [ -f /system/gingerbread.build ] ; then
301         echo "Gingerbread build detected"
302         RCSCRIPT="gingerbread"
303         RCCONFIG="gingerbread"
304
305         # vold: Fix sdcard device location for CDMA boards (thanks paalsteek)
306         if [ $NEW_SYSTEM -eq 1 -a -d /sys/devices/platform/msm_sdcc.3 ]; then
307                 /bin/sed -i -e 's:/devices/platform/msm_sdcc\.2:/devices/platform/msm_sdcc.3:g' /etc/vold.fstab
308         fi
309
310 elif [ -f /system/tattoo.build ] ; then
311         echo "Tattoo build detected"
312         RCSCRIPT="tattoo"
313         RCCONFIG="tattoo"
314
315 elif [ -f /system/donut.build ] ; then
316         echo "Donut build detected"
317         RCSCRIPT="donut"
318         RCCONFIG="donut"
319         mount --bind /lib/donut/hw /system/lib/hw
320
321 elif [ -d /system/lib/donut ] ; then
322         echo "Donut build detected"
323         RCSCRIPT="donut"
324         RCCONFIG="donut"
325
326 elif [ -f /system/xrom.build ] ; then
327         echo "xROM build detected"
328         RCSCRIPT="xrom"
329         RCCONFIG="xrom"
330
331 elif [ -f /system/rogers.build ] ; then
332         echo "Rogers build detected"
333         RCSCRIPT="rogers"
334         RCCONFIG="rogers"
335
336 elif [ -f /system/cyanogen.build ] ; then
337         echo "cyanogen experimental detected.....eating donuts"
338         RCSCRIPT="cyanogen"
339         RCCONFIG="cyanogen"
340
341 elif [ -f /system/custom.build ] ; then
342         echo "Custom init.rc detected"
343         cp /system/sysinit.rc /build.cfg/init.sysinit.rc
344         RCCONFIG="hero"
345         RCSCRIPT="sysinit"
346         
347 else
348         echo "Unknown Android build. Assuming Ion variant"
349         RCSCRIPT="ion"
350         RCCONFIG="ion"
351
352         # for the fake sensors library
353         mount /lib/hw /system/lib/hw -o loop
354         chmod 666 /dev/input/event0
355
356         if [ $DIAMOND -eq 1 ] ; then
357                 RCCONFIG="ion.diamond"
358         fi
359 fi
360
361 if [ $KAISER -eq 1 ] ; then
362         RCSCRIPT="$RCSCRIPT.kaiser"
363 fi
364
365 if [ $NEW_ROOT -eq 1 -a $XPERIA -eq 1 ] ; then
366         echo "ro.sf.hwrotation=180" >> /etc/default.prop
367 fi
368 echo "using /init.$RCSCRIPT.rc as init.rc"
369 echo "using $card/conf/$RCCONFIG.user.conf"
370
371 if [ $NEW_ROOT -eq 1 ]; then
372         cp "/init.cfg/init.$RCSCRIPT.rc" /etc/init.rc
373 fi
374
375 #Assume this rootfs.img will be used only on "good" devices
376 #Meaning raph/diam/blac/
377
378 # echo /dev/block/mmcblk0p2 > /sys/devices/platform/usb_mass_storage/lun0/file
379 ifconfig usb0 192.168.20.1 up
380 busybox telnetd -b 192.168.20.1 -l /bin/sh
381 #chmod 4755 /bin/su
382 #mkdir -m 0777 /smodem
383 mknod /dev/urandom c 1 9
384 if [ -d /data/dropbear/ ] ; then
385         echo "Starting SSH"
386         mknod /dev/random c 1 8
387         /bin/dropbear -r /data/dropbear/dropbear_rsa_host_key -s
388 fi
389
390 if [ "$WIFI_TI" = "1" ] || [ "$WIFI_BCM" = "1" ];then
391         if [ -e "$card/modules-$(uname -r).tar.gz" ] && ! `strings /data/modules/mac80211.ko 2>/dev/null | grep -q "vermagic=$(uname -r)"`; then
392                 echo "Installing $card/modules-$(uname -r).tar.gz"
393                 if [ ! -d "/data/modules" ] ; then
394                         mkdir /data/modules
395                 fi
396                 tar xzf $card/modules-$(uname -r).tar.gz -C /data/modules
397                 ln -s /data/modules /data/modules/`uname -r`
398         else
399                 echo "Modules already unpacked for this kernel version -- skipping installation of $card/modules-$(uname -r).tar.gz"
400         fi
401
402         mount --bind /data/modules /lib/modules
403         mount --bind /data/modules /system/lib/modules
404
405         if [ -f /etc/wifi/wlan.ko ]; then
406         cp -R /etc/wifi/* /data/modules/
407         rm /etc/wifi/wlan.ko
408         depmod
409         fi
410
411         if [ "`grep -c ^wifi /etc/default.prop`" != "2" ]; then
412                 echo "wifi.interface = wlan0" >> /etc/default.prop
413                 echo "wifi.supplicant_scan_interval = 45" >> /etc/default.prop
414         fi
415 fi
416
417 if [ -f /system/eclair.build ]
418 then
419         mount --bind /lib/eclair/libhardware_legacy.so /system/lib/libhardware_legacy.so
420 fi
421
422 # fix PPP data device name
423 if [ $NEW_ROOT -eq 1 ]; then
424         if [ -f /dev/smd7 ]; then
425                 PPPDEV=/dev/smd7
426         else
427                 PPPDEV=/dev/smd1
428         fi
429         sed -i s,PPPDEV,$PPPDEV, /etc/init.rc
430 fi
431
432 if [ "$WIFI_TI" = "1" ];then
433         ip link set dev tiwlan0 name wlan0
434 fi
435
436 if [ "$WIFI_BCM" = "1" ] ;then
437         ip link set dev eth0 name wlan0
438
439         # fyi: firmware is loaded from /etc/wifi/bcm432x/bcm4325-rtecdc.bin, nvram from /data/wifi-nvram.txt
440
441         if [ $NEW_ROOT -eq 1 ]; then
442                 # init.rc: fix wpa_supplicant service
443                 sed -i s/-Dtiwlan0/-Dwext/ /etc/init.rc
444
445                 # init.rc:
446                 sed -i s/user\ wifi/#user\ wifi/ /etc/init.rc
447                 sed -i s/group\ wifi/#group\ wifi/ /etc/init.rc
448         fi
449
450         # extract nvram (todo: clean this up/integrate with TI calibration)
451         if [ ! -e /data/wifi-nvram.txt ]; then
452                 for SKIP in 5744 4736;do
453                         insmod /lib/modules/mtdchar.ko
454                         mknod /dev/mtd0ro c 90 1
455                         mkdir /lib/modules/$(uname -r)
456
457                         dd if=/dev/mtd0ro of=/tmp/tempcal bs=8192 count=1 skip=$SKIP
458                         rm /dev/mtd0ro
459                         rmmod mtdchar
460                         rmdir /lib/modules/$(uname -r)
461                         dd if=/tmp/tempcal of=/data/wifi-nvram.txt bs=1 count=466
462                         rm /tmp/tempcal
463                 
464                         if grep nocrc= /data/wifi-nvram.txt 2>&1 > /dev/null;then 
465                                 break
466                         fi;
467                 done
468                 if [ "$SKIP" = "5744" ];then
469                         echo "CDMA Rhodium detected"
470                 fi;
471                 if [ "$SKIP" = "4736" ];then
472                         echo "GSM Rhodium detected"
473                 fi;
474
475         fi
476 fi
477
478 if [ -f "$card/local.prop" -a "$card/local.prop" -nt /data/local.prop ]; then
479         cp "$card/local.prop" /data/local.prop
480 fi
481
482 if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
483         /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
484 else
485         echo "No user config files ($RCCONFIG) found on sdcard"
486 fi
487
488 mount -tdebugfs none /dbgfs
489 #Activate baclight control
490 echo 3 > /sys/class/htc_hw/test
491 #Smooth scroll
492 echo 40 >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
493 #Activate full charging
494 echo 2 > /dbgfs/htc_battery/charger_state
495
496 echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
497
498 if [ $NEW_ROOT -eq 1 ]; then
499 KBD=`sed 's/.*physkeyboard=\([0-9a-z_]*\).*/\1/' /proc/cmdline`
500 case "$KBD" in
501     fuse)
502         echo "USING RAPH110|FUZE LAYOUT"
503         cp -f /init.etc/keymaps/fuze_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
504         cp -f /init.etc/keymaps/fuze_microp-keypad.kl /etc/keymaps/microp-keypad.kl
505         cp -f /init.etc/keymaps/fuze_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
506         ;;
507     raph)
508         echo "USING NEW RAPH LAYOUT"
509         cp -f /init.etc/keymaps/raphfix_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
510         ;;
511     nordic_raph)
512         echo "USING NEW NORDIC RAPH LAYOUT"
513         cp -f /init.etc/keymaps/raphfix_microp-keypad-swedish.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
514         ;;
515     german_raph)
516         echo "USING NEW GERMAN RAPH LAYOUT"
517         cp -f /init.etc/keymaps/microp-german.keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
518         ;;
519     swiss_raph)
520         echo "USING NEW SWISS RAPH LAYOUT"
521         cp -f /init.etc/keymaps/microp-swiss.keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
522         ;;
523     tilt2)
524         echo "USING EXPERIMENTAL TILT2 LAYOUT"
525         cp -f /init.etc/keymaps/tilt2_microp-keypad.kl /etc/keymaps/microp-keypad.kl
526         cp -f /init.etc/keymaps/tilt2_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
527         cp -f /init.etc/keymaps/tilt2_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
528         ;;
529     rhod210)
530         echo "USING EXPERIMENTAL RHOD210 LAYOUT"
531         cp -f /init.etc/keymaps/rhod210_microp-keypad.kl /etc/keymaps/microp-keypad.kl
532         cp -f /init.etc/keymaps/rhod210_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
533         cp -f /init.etc/keymaps/rhod210_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
534         ;;
535     rhod100_de)
536         echo "USING RHOD100 DE LAYOUT"
537         cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kl /etc/keymaps/microp-keypad.kl
538         cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
539         cp -f /init.etc/keymaps/rhod100_de_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
540         ;;
541     rhod100_fr)
542         echo "USING RHOD100 FR LAYOUT"
543         cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kl /etc/keymaps/microp-keypad.kl
544         cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
545         cp -f /init.etc/keymaps/rhod100_fr_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
546         ;;
547     rhod100_it)
548         echo "USING RHOD100 IT LAYOUT"
549         cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kl /etc/keymaps/microp-keypad.kl
550         cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
551         cp -f /init.etc/keymaps/rhod100_it_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
552         ;;
553     rhod100_uk)
554         echo "USING RHOD100 UK LAYOUT"
555         cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kl /etc/keymaps/microp-keypad.kl
556         cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
557         cp -f /init.etc/keymaps/rhod100_uk_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
558         ;;
559     rhod100_nordic)
560         echo "USING RHOD100 NORDIC LAYOUT"
561         cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kl /etc/keymaps/microp-keypad.kl
562         cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
563         cp -f /init.etc/keymaps/rhod100_nordic_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
564         ;;
565     rhod400)
566         echo "USING EXPERIMENTAL RHOD400 LAYOUT"
567         cp -f /init.etc/keymaps/rhod400_microp-keypad.kl /etc/keymaps/microp-keypad.kl
568         cp -f /init.etc/keymaps/rhod400_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
569         cp -f /init.etc/keymaps/rhod400_navi_pad.kl /etc/keymaps/raph_navi_pad.kl #does not exist, just following example
570         ;;
571     rhod500)
572         echo "USING EXPERIMENTAL RHOD500 LAYOUT"
573         cp -f /init.etc/keymaps/rhod500_microp-keypad.kl /etc/keymaps/microp-keypad.kl
574         cp -f /init.etc/keymaps/rhod500_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
575         cp -f /init.etc/keymaps/rhod500_navi_pad.kl /etc/keymaps/raph_navi_pad.kl #does not exist, just following example
576         ;;
577     kovsq)
578         echo "USING KOVSKY QWERTY LAYOUT"
579         cp -f /init.etc/keymaps/kovsky-qwerty.kl /etc/keymaps/microp-keypad.kl
580         cp -f /init.etc/keymaps/kovsky-qwerty.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
581         ;;
582     kovsa)
583         echo "USING KOVSKY AZERTY LAYOUT"
584         cp -f /init.etc/keymaps/kovsky-azerty.kl /etc/keymaps/microp-keypad.kl
585         cp -f /init.etc/keymaps/kovsky-azerty.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
586         ;;
587     *)
588         echo "USING OLD KEYMAP"
589         cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
590         cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kl /etc/keymaps/microp-keypad.kl
591         cp -f /init.etc/keymaps/oldqwerty_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
592         ;;
593 esac
594
595 cp -af /init.etc/keymaps/qwerty.kcm.bin /init.etc/keymaps/qwerty.kl /etc/keymaps/
596 fi
597
598 mount --bind /etc/keymaps /system/usr/keychars
599 mount --bind /etc/keymaps /system/usr/keylayout
600
601 for i in /sys/class/input/input* ; do
602         if [ "`cat $i/name`" = "tssc-manager" ] ; then
603                 touchscreendir=$i
604                 echo "Touchscreen device directory is $i"
605         fi
606 done
607
608 if [ -f $card/ts-calibration ] ; then
609         echo "Using Saved Touchscreen Calibration"
610         echo 128,128,1903,128,128,1907,1903,1907,1024,1024 > $touchscreendir/calibration_screen
611         cat $card/ts-calibration > $touchscreendir/calibration_points
612 else
613         mkdir /dev/graphics
614         mknod /dev/graphics/fb0 c 29 0
615         clear
616         echo; echo; echo; echo; echo; echo; echo; echo "Calibrating Touchscreen:"
617         echo "Click the Five Targets in order -- Top Left, Top Right, Middle, Bottom Left, Bottom Right"
618         echo "(Tap lightly. The screen is quite sensitive.)"
619         tssc-calibrate
620         echo 0,0,0,0,0,0,0,0,0,0 | cmp -s $touchscreendir/calibration_points # determine if calibration is still null -- means failed calibration
621         if [ $? -eq 0 ] ; then
622                 echo "Touchscreen Calibration Failed"
623         else
624                 echo "Touchscreen Calibration Successful; Saving..."
625                 cat $touchscreendir/calibration_points > $card/ts-calibration
626         fi
627 fi
628
629 mkdir /dev/msm_camera
630 mknod /dev/msm_camera/control0 c 250 0
631 mknod /dev/msm_camera/config0 c 250 1
632 mknod /dev/msm_camera/frame0 c 250 2
633
634 # Generate a "serial number" for the Android system to identify the device.
635 # Put it in /data so it survives reboots. Won't survive a factory reset, though.
636 [ -f "/data/serialno" ] || echo -e `cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 12 | head -n 1` >/data/serialno
637
638 SERIALNO=$(cat /data/serialno)
639 cp /proc/cmdline /tmp/cmdline
640 sed -i -e "s:$: androidboot.serialno=${SERIALNO}:" /tmp/cmdline
641 mount --bind /tmp/cmdline /proc/cmdline
642
643 exec /init.android