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