Always use wlan0 as interface name
[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         fi
139         /bin/cp $card/AndroidApps/* /data/app
140         chown -R 1000:1000 /data/app
141 fi
142
143 if [ ! -d $card/media ] ; then
144         echo You have no media folder, please extract the resources to your SD card android folder
145 fi
146
147 NEW_SYSTEM=0
148 NEW_ROOT=0
149
150 if [ ! -d /data/etc ]; then
151         /bin/mkdir -m 0755 /data/etc
152         /bin/mkdir -p -m 0700 /data/mnt/secure
153 #       /bin/mkdir -p -m 0700 /data/mnt/asec
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 --bind /data/mnt/asec /mnt/asec
171 mount /data/shared_prefs /shared_prefs
172
173 if [ $NEW_SYSTEM -eq 1 ]; then
174         cp -ar /system/etc/* /data/etc
175 fi
176 if [ $NEW_ROOT -eq 1 ]; then
177         cp -ar /init.etc/* /data/etc
178 fi
179
180 mount /data/etc /etc
181
182 LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
183
184 if [ "$LCDDENSITY" != "" ] ; then
185         DENS2=`grep lcd_density /etc/default.prop | sed -e 's/.*=//'`
186         if [ "$LCDDENSITY" != "$DENS2" ]; then
187                 echo Setting ro.sf.lcd_density=$LCDDENSITY
188                 if [ -z "$DENS2" ]; then
189                         echo "ro.sf.lcd_density=$LCDDENSITY" >> /etc/default.prop
190                 else
191                         sed -i /lcd_density/s/=.*/=$LCDDENSITY/ /etc/default.prop
192                 fi
193         fi
194 fi
195
196 mount /sdcard/cache /tmp
197
198
199 KAISER=0
200 DIAMOND=0
201 WIFI_TI=0
202 WIFI_BCM=0
203 XPERIA=0
204 WVGA=0
205 HW=`cat /proc/cpuinfo | grep Hardware`
206 case "$HW" in
207     *Kaiser*)
208         echo "KAISER detected"
209         HW=KAISER
210         KAISER=1
211         WIFI_TI=1
212         ;;
213     *Polaris*)
214         echo "POLARIS detected"
215         HW=POLARIS
216         KAISER=1
217         WIFI_TI=1
218         ;;
219     *Diamond*)
220         echo "DIAMOND detected"
221         HW=DIAMOND
222         DIAMOND=1
223         WIFI_TI=1
224         ;;
225     *Raphael*)
226         echo "RAPHAEL detected"
227         HW=RAPHAEL
228         DIAMOND=1
229         WIFI_TI=1
230         ;;
231     *blackstone*)
232         echo "BLACKSTONE detected"
233         HW=BLACKSTONE
234         DIAMOND=1
235         WIFI_TI=1
236         WVGA=1
237         ;;
238     *Topaz*)
239         echo "TOPAZ detected"
240         HW=TOPAZ
241         DIAMOND=1
242         WIFI_TI=1
243         WVGA=1
244         ;;
245     *Kovsky*)
246         echo "XPERIA detected"
247         HW=KOVSKY
248         XPERIA=1
249         WIFI_TI=1
250         WVGA=1
251         ;;
252     *Rhodium*)
253         echo "RHODIUM detected"
254         HW=RHODIUM
255         DIAMOND=1
256         WIFI_BCM=1
257         WVGA=1
258         ;;
259     *)
260         echo "VOGUE detected"
261         HW=VOGUE
262         ;;
263 esac
264
265 ### Fix su on some builds...
266 mount --bind /bin/su /system/bin/su 2> /dev/null
267 mount --bind /bin/su /system/xbin/su 2> /dev/null
268
269 RCSCRIPT=""
270 RCCONFIG=""
271
272 echo "Checking for build type..."
273 if [ -f /system/hero.build ] ; then
274         echo "Hero build detected"
275         RCSCRIPT="hero"
276         RCCONFIG="hero"
277         ln /data/app_s /system/app
278
279 elif [ -f /system/eclairhero.build ] ; then
280         echo "HERO 2.1 BUILD DETECTED -- ECLAIR"
281         RCSCRIPT="eclairhero"
282         RCCONFIG="eclairhero"
283         mount --bind /lib/eclair/hw /system/lib/hw
284
285 elif [ -f /system/eclair.build ] ; then
286         echo "Eclair build detected"
287         RCSCRIPT="eclair"
288         RCCONFIG="eclair"
289         mount --bind /lib/eclair/hw /system/lib/hw
290
291 elif [ -f /system/froyo.build ] ; then
292         echo "Froyo build detected"
293         RCSCRIPT="froyo"
294         RCCONFIG="froyo"
295         mount --bind /lib/froyo/hw /system/lib/hw
296
297         # vold: Fix sdcard device location for CDMA boards (thanks paalsteek)
298         if [ $NEW_SYSTEM -eq 1 -a -d /sys/devices/platform/msm_sdcc.3 ]; then
299                 /bin/sed -i -e 's:/devices/platform/msm_sdcc\.2:/devices/platform/msm_sdcc.3:g' /etc/vold.fstab
300         fi
301
302 elif [ -f /system/gingerbread.build ] ; then
303         echo "Gingerbread build detected"
304         RCSCRIPT="gingerbread"
305         RCCONFIG="gingerbread"
306
307         # vold: Fix sdcard device location for CDMA boards (thanks paalsteek)
308         if [ $NEW_SYSTEM -eq 1 -a -d /sys/devices/platform/msm_sdcc.3 ]; then
309                 /bin/sed -i -e 's:/devices/platform/msm_sdcc\.2:/devices/platform/msm_sdcc.3:g' /etc/vold.fstab
310         fi
311
312 elif [ -f /system/tattoo.build ] ; then
313         echo "Tattoo build detected"
314         RCSCRIPT="tattoo"
315         RCCONFIG="tattoo"
316
317 elif [ -f /system/donut.build ] ; then
318         echo "Donut build detected"
319         RCSCRIPT="donut"
320         RCCONFIG="donut"
321         mount --bind /lib/donut/hw /system/lib/hw
322
323 elif [ -d /system/lib/donut ] ; then
324         echo "Donut build detected"
325         RCSCRIPT="donut"
326         RCCONFIG="donut"
327
328 elif [ -f /system/xrom.build ] ; then
329         echo "xROM build detected"
330         RCSCRIPT="xrom"
331         RCCONFIG="xrom"
332
333 elif [ -f /system/rogers.build ] ; then
334         echo "Rogers build detected"
335         RCSCRIPT="rogers"
336         RCCONFIG="rogers"
337
338 elif [ -f /system/cyanogen.build ] ; then
339         echo "cyanogen experimental detected.....eating donuts"
340         RCSCRIPT="cyanogen"
341         RCCONFIG="cyanogen"
342
343 elif [ -f /system/custom.build ] ; then
344         echo "Custom init.rc detected"
345         cp /system/sysinit.rc /build.cfg/init.sysinit.rc
346         RCCONFIG="hero"
347         RCSCRIPT="sysinit"
348         
349 else
350         echo "Unknown Android build. Assuming Ion variant"
351         RCSCRIPT="ion"
352         RCCONFIG="ion"
353
354         # for the fake sensors library
355         mount /lib/hw /system/lib/hw -o loop
356         chmod 666 /dev/input/event0
357
358         if [ $DIAMOND -eq 1 ] ; then
359                 RCCONFIG="ion.diamond"
360         fi
361 fi
362
363 if [ $KAISER -eq 1 ] ; then
364         RCSCRIPT="$RCSCRIPT.kaiser"
365 fi
366
367 if [ $NEW_ROOT -eq 1 -a $XPERIA -eq 1 ] ; then
368         echo "ro.sf.hwrotation=180" >> /etc/default.prop
369 fi
370 echo "using /init.$RCSCRIPT.rc as init.rc"
371 echo "using $card/conf/$RCCONFIG.user.conf"
372
373 if [ $NEW_ROOT -eq 1 ]; then
374         cp "/init.cfg/init.$RCSCRIPT.rc" /etc/init.rc
375 fi
376
377 #Assume this rootfs.img will be used only on "good" devices
378 #Meaning raph/diam/blac/
379
380 # echo /dev/block/mmcblk0p2 > /sys/devices/platform/usb_mass_storage/lun0/file
381 ifconfig usb0 192.168.20.1 up
382 busybox telnetd -b 192.168.20.1 -l /bin/sh
383 #chmod 4755 /bin/su
384 #mkdir -m 0777 /smodem
385 mknod /dev/urandom c 1 9
386 if [ -d /data/dropbear/ ] ; then
387         echo "Starting SSH"
388         mknod /dev/random c 1 8
389         /bin/dropbear -r /data/dropbear/dropbear_rsa_host_key -s
390 fi
391
392 if [ "$WIFI_TI" = "1" ] || [ "$WIFI_BCM" = "1" ];then
393         if [ -e "$card/modules-$(uname -r).tar.gz" ] && ! `strings /data/modules/mac80211.ko 2>/dev/null | grep -q "vermagic=$(uname -r)"`; then
394                 echo "Installing $card/modules-$(uname -r).tar.gz"
395                 if [ ! -d "/data/modules" ] ; then
396                         mkdir /data/modules
397                 fi
398                 tar xzf $card/modules-$(uname -r).tar.gz -C /data/modules
399                 ln -s /data/modules /data/modules/`uname -r`
400         else
401                 echo "Modules already unpacked for this kernel version -- skipping installation of $card/modules-$(uname -r).tar.gz"
402         fi
403
404         mount --bind /data/modules /lib/modules
405         mount --bind /data/modules /system/lib/modules
406
407         if [ -f /etc/wifi/wlan.ko ]; then
408         cp -R /etc/wifi/* /data/modules/
409         rm /etc/wifi/wlan.ko
410         depmod
411         fi
412
413         if [ "`grep -c ^wifi /etc/default.prop`" != "2" ]; then
414                 echo "wifi.interface = wlan0" >> /etc/default.prop
415                 echo "wifi.supplicant_scan_interval = 45" >> /etc/default.prop
416         fi
417 fi
418
419 if [ -f /system/eclair.build ]
420 then
421         mount --bind /lib/eclair/libhardware_legacy.so /system/lib/libhardware_legacy.so
422 fi
423
424 # fix PPP data device name
425 if [ $NEW_ROOT -eq 1 ]; then
426         if [ -f /dev/smd7 ]; then
427                 PPPDEV=/dev/smd7
428         else
429                 PPPDEV=/dev/smd1
430         fi
431         sed -i s,PPPDEV,$PPPDEV, /etc/init.rc
432 fi
433
434 if [ "$WIFI_TI" = "1" ];then
435         ip link set dev tiwlan0 name wlan0
436 fi
437
438 if [ "$WIFI_BCM" = "1" ] ;then
439         ip link set dev eth0 name wlan0
440
441         # fyi: firmware is loaded from /etc/wifi/bcm432x/bcm4325-rtecdc.bin, nvram from /data/wifi-nvram.txt
442
443         if [ $NEW_ROOT -eq 1 ]; then
444                 # init.rc: fix wpa_supplicant service
445                 sed -i s/-Dtiwlan0/-Dwext/ /etc/init.rc
446
447                 # init.rc:
448                 sed -i s/user\ wifi/#user\ wifi/ /etc/init.rc
449                 sed -i s/group\ wifi/#group\ wifi/ /etc/init.rc
450         fi
451
452         # extract nvram (todo: clean this up/integrate with TI calibration)
453         if [ ! -e /data/wifi-nvram.txt ]; then
454                 for SKIP in 5744 4736;do
455                         insmod /lib/modules/mtdchar.ko
456                         mknod /dev/mtd0ro c 90 1
457                         mkdir /lib/modules/$(uname -r)
458
459                         dd if=/dev/mtd0ro of=/tmp/tempcal bs=8192 count=1 skip=$SKIP
460                         rm /dev/mtd0ro
461                         rmmod mtdchar
462                         rmdir /lib/modules/$(uname -r)
463                         dd if=/tmp/tempcal of=/data/wifi-nvram.txt bs=1 count=466
464                         rm /tmp/tempcal
465                 
466                         if grep nocrc= /data/wifi-nvram.txt 2>&1 > /dev/null;then 
467                                 break
468                         fi;
469                 done
470                 if [ "$SKIP" = "5744" ];then
471                         echo "CDMA Rhodium detected"
472                 fi;
473                 if [ "$SKIP" = "4736" ];then
474                         echo "GSM Rhodium detected"
475                 fi;
476
477         fi
478 fi
479
480 if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
481         /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
482 else
483         echo "No user config files ($RCCONFIG) found on sdcard"
484 fi
485
486 mount -tdebugfs none /dbgfs
487 #Activate baclight control
488 echo 3 > /sys/class/htc_hw/test
489 #Smooth scroll
490 echo 40 >/sys/devices/system/cpu/cpu0/cpufreq/ondemand/up_threshold
491 #Activate full charging
492 echo 2 > /dbgfs/htc_battery/charger_state
493
494 echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
495
496 if /bin/grep -c 'physkeyboard=fuze' /proc/cmdline >/dev/null ; then
497         echo "USING RAPH110|FUZE LAYOUT"
498         cp -f /init.etc/keymaps/fuze_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
499         cp -f /init.etc/keymaps/fuze_microp-keypad.kl /etc/keymaps/microp-keypad.kl
500         cp -f /init.etc/keymaps/fuze_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
501 elif /bin/grep -c 'physkeyboard=raph' /proc/cmdline >/dev/null ; then
502         echo "USING NEW RAPH LAYOUT"
503         cp -f /init.etc/keymaps/raphfix_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
504 elif /bin/grep -c 'physkeyboard=nordic_raph' /proc/cmdline >/dev/null ; then
505         echo "USING NEW NORDIC RAPH LAYOUT"
506         cp -f /init.etc/keymaps/raphfix_microp-keypad-swedish.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
507 elif /bin/grep -c 'physkeyboard=german_raph' /proc/cmdline >/dev/null ; then
508         echo "USING NEW GERMAN RAPH LAYOUT"
509         cp -f /init.etc/keymaps/microp-german.keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
510 elif /bin/grep -c 'physkeyboard=swiss_raph' /proc/cmdline >/dev/null ; then
511         echo "USING NEW SWISS RAPH LAYOUT"
512         cp -f /init.etc/keymaps/microp-swiss.keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
513 elif /bin/grep -c 'physkeyboard=tilt2' /proc/cmdline >/dev/null ; then
514         echo "USING EXPERIMENTAL TILT2 LAYOUT"
515         cp -f /init.etc/keymaps/tilt2_microp-keypad.kl /etc/keymaps/microp-keypad.kl
516         cp -f /init.etc/keymaps/tilt2_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
517         cp -f /init.etc/keymaps/tilt2_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
518 elif /bin/grep -c 'physkeyboard=rhod210' /proc/cmdline >/dev/null ; then
519         echo "USING EXPERIMENTAL RHOD210 LAYOUT"
520         cp -f /init.etc/keymaps/rhod210_microp-keypad.kl /etc/keymaps/microp-keypad.kl
521         cp -f /init.etc/keymaps/rhod210_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
522         cp -f /init.etc/keymaps/rhod210_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
523 elif /bin/grep -c 'physkeyboard=rhod100_de' /proc/cmdline >/dev/null ; then
524         echo "USING RHOD100 DE LAYOUT"
525         cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kl /etc/keymaps/microp-keypad.kl
526         cp -f /init.etc/keymaps/rhod100_de_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
527         cp -f /init.etc/keymaps/rhod100_de_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
528 elif /bin/grep -c 'physkeyboard=rhod100_fr' /proc/cmdline >/dev/null ; then
529         echo "USING RHOD100 FR LAYOUT"
530         cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kl /etc/keymaps/microp-keypad.kl
531         cp -f /init.etc/keymaps/rhod100_fr_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
532         cp -f /init.etc/keymaps/rhod100_fr_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
533 elif /bin/grep -c 'physkeyboard=rhod100_it' /proc/cmdline >/dev/null ; then
534         echo "USING RHOD100 IT LAYOUT"
535         cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kl /etc/keymaps/microp-keypad.kl
536         cp -f /init.etc/keymaps/rhod100_it_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
537         cp -f /init.etc/keymaps/rhod100_it_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
538 elif /bin/grep -c 'physkeyboard=rhod100_uk' /proc/cmdline >/dev/null ; then
539         echo "USING RHOD100 UK LAYOUT"
540         cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kl /etc/keymaps/microp-keypad.kl
541         cp -f /init.etc/keymaps/rhod100_uk_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
542         cp -f /init.etc/keymaps/rhod100_uk_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
543 elif /bin/grep -c 'physkeyboard=rhod100_nordic' /proc/cmdline >/dev/null ; then
544         echo "USING RHOD100 NORDIC LAYOUT"
545         cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kl /etc/keymaps/microp-keypad.kl
546         cp -f /init.etc/keymaps/rhod100_nordic_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
547         cp -f /init.etc/keymaps/rhod100_nordic_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
548 elif /bin/grep -c 'physkeyboard=rhod400' /proc/cmdline >/dev/null ; then
549         echo "USING EXPERIMENTAL RHOD400 LAYOUT"
550         cp -f /init.etc/keymaps/rhod400_microp-keypad.kl /etc/keymaps/microp-keypad.kl
551         cp -f /init.etc/keymaps/rhod400_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
552         cp -f /init.etc/keymaps/rhod400_navi_pad.kl /etc/keymaps/raph_navi_pad.kl #does not exist, just following example
553 elif /bin/grep -c 'physkeyboard=rhod500' /proc/cmdline >/dev/null ; then
554         echo "USING EXPERIMENTAL RHOD500 LAYOUT"
555         cp -f /init.etc/keymaps/rhod500_microp-keypad.kl /etc/keymaps/microp-keypad.kl
556         cp -f /init.etc/keymaps/rhod500_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
557         cp -f /init.etc/keymaps/rhod500_navi_pad.kl /etc/keymaps/raph_navi_pad.kl #does not exist, just following example
558 elif /bin/grep -c 'physkeyboard=kovsq' /proc/cmdline >/dev/null ; then
559         echo "USING KOVSKY QWERTY LAYOUT"
560         cp -f /init.etc/keymaps/kovsky-qwerty.kl /etc/keymaps/microp-keypad.kl
561         cp -f /init.etc/keymaps/kovsky-qwerty.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
562 elif /bin/grep -c 'physkeyboard=kovsa' /proc/cmdline >/dev/null; then
563         echo "USING KOVSKY AZERTY LAYOUT"
564         cp -f /init.etc/keymaps/kovsky-azerty.kl /etc/keymaps/microp-keypad.kl
565         cp -f /init.etc/keymaps/kovsky-azerty.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
566 else
567         echo "USING OLD KEYMAP"
568         cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kcm.bin /etc/keymaps/microp-keypad.kcm.bin
569         cp -f /init.etc/keymaps/oldqwerty_microp-keypad.kl /etc/keymaps/microp-keypad.kl
570         cp -f /init.etc/keymaps/oldqwerty_raph_navi_pad.kl /etc/keymaps/raph_navi_pad.kl
571 fi
572
573 cp -af /init.etc/keymaps/qwerty.kcm.bin /init.etc/keymaps/qwerty.kl /etc/keymaps/
574 mount --bind /etc/keymaps /system/usr/keychars
575 mount --bind /etc/keymaps /system/usr/keylayout
576
577 for i in /sys/class/input/input* ; do
578         if [ "`cat $i/name`" = "tssc-manager" ] ; then
579                 touchscreendir=$i
580                 echo "Touchscreen device directory is $i"
581         fi
582 done
583
584 if [ -f $card/ts-calibration ] ; then
585         echo "Using Saved Touchscreen Calibration"
586         echo 128,128,1903,128,128,1907,1903,1907,1024,1024 > $touchscreendir/calibration_screen
587         cat $card/ts-calibration > $touchscreendir/calibration_points
588 else
589         mkdir /dev/graphics
590         mknod /dev/graphics/fb0 c 29 0
591         clear
592         echo; echo; echo; echo; echo; echo; echo; echo "Calibrating Touchscreen:"
593         echo "Click the Five Targets in order -- Top Left, Top Right, Middle, Bottom Left, Bottom Right"
594         echo "(Tap lightly. The screen is quite sensitive.)"
595         tssc-calibrate
596         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
597         if [ $? -eq 0 ] ; then
598                 echo "Touchscreen Calibration Failed"
599         else
600                 echo "Touchscreen Calibration Successful; Saving..."
601                 cat $touchscreendir/calibration_points > $card/ts-calibration
602         fi
603 fi
604
605 mkdir /dev/msm_camera
606 mknod /dev/msm_camera/control0 c 250 0
607 mknod /dev/msm_camera/config0 c 250 1
608 mknod /dev/msm_camera/frame0 c 250 2
609 #chmod a+s /bin/pppd
610
611 # Generate a "serial number" for the Android system to identify the device.
612 # Put it in /data so it survives reboots. Won't survive a factory reset, though.
613 [ -f "/data/serialno" ] || echo -e `cat /dev/urandom | tr -dc 'A-Z0-9' | fold -w 12 | head -n 1` >/data/serialno
614
615 SERIALNO=$(cat /data/serialno)
616 cp /proc/cmdline /tmp/cmdline
617 sed -i -e "s:$: androidboot.serialno=${SERIALNO}:" /tmp/cmdline
618 mount --bind /tmp/cmdline /proc/cmdline
619
620 exec /init.android