Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

phh
Sunday, January 3rd, 2010 at 10:02:46am MST 

  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:/system/bin:/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. if [ -d /sdcard/android ] ; then
  51.         card=/sdcard/android
  52. else
  53.         card=/sdcard
  54. fi
  55.  
  56.  
  57. if [ $notnand = "1" ] ; then
  58.    
  59.     if [ -f $card/data.gz ] ; then
  60.             echo "Please wait... extracting Data Image"
  61.             if [ -f $card/data.img ] ; then
  62.                     rm $card/data.img
  63.             fi
  64.             gzip -df $card/data.gz
  65.             [ $? -eq 0 ] || fail "Failed to extract Data Image"
  66.             mv $card/data $card/data.img
  67.             echo "done"
  68.     fi
  69.    
  70.     PARTITIONED=0
  71.     echo "Checking for partition..."
  72.     if [ -d /sys/block/mmcblk0/mmcblk0p2 ] ; then
  73.             PARTITIONED=1
  74.             if [ -d /sys/block/mmcblk0/mmcblk0p3 ] ; then
  75.                     PARTITIONED=2
  76.             fi
  77.     fi
  78.    
  79.     if [ -f $card/backupsystem/installedsystem.sqsh -o -f $card/backupsystem/installedsystem.img -o -f $card/backupsystem.ext2 ]; then
  80.             echo "Partitioned Build Detected"
  81.     else
  82.             PARTITIONED=0
  83.     fi
  84.    
  85.     if [ $PARTITIONED -lt 2 ] ; then
  86.             
  87.             if [ ! -f $card/data.img ] ; then
  88.                     echo "Creating a new Data store"
  89.                     dd if=/dev/zero of=$card/data.img bs=1048576 count=256
  90.                     [ $? -eq 0 ] || fail "Failed to allocate the storage"
  91.                     mke2fs -F $card/data.img
  92.                     [ $? -eq 0 ] || fail "Failed to format the storage"
  93.             fi
  94.     fi
  95.    
  96.     if [ $PARTITIONED -lt 2 ] ; then
  97.             losetup /dev/block/loop0 $card/data.img
  98.             [ $? -eq 0 ] || fail "Failed to find data.img on SD Card"
  99.             e2fsck -y /dev/block/loop0
  100.             mount -t ext2 -o noatime,nodiratime,sync /dev/block/loop0 /data
  101.     else
  102.             e2fsck -y /dev/block/mmcblk0p3
  103.             mount -t ext2 -o noatime,nodiratime /dev/block/mmcblk0p3 /data
  104.     fi
  105.     [ $? -eq 0 ] || fail "Failed to mount /data"
  106.    
  107.     if [ $PARTITIONED -eq 0 ] ; then
  108.             if      [ -f $card/system.ext2 ] ; then
  109.                     echo "Using uncompressed system"
  110.                     losetup /dev/block/loop1 $card/system.ext2
  111.                     [ $? -eq 0 ] || fail "Failed to reach system.ext2 on SD Card"
  112.                     e2fsck -y /dev/block/loop1
  113.                     mount -t ext2 -o noatime,nodiratime /dev/block/loop1 /system
  114.                     [ $? -eq 0 ] || fail "Failed to mount /system"
  115.             elif   
  116.                     [ -f $card/system.sqsh ] ; then
  117.                     echo "Using SquashFS system"
  118.                     losetup /dev/block/loop1 $card/system.sqsh
  119.                     [ $? -eq 0 ] || fail "Failed to find system.sqsh on SD Card"
  120.                     mount -t squashfs -o ro,noatime,nodiratime /dev/block/loop1 /system
  121.                     [ $? -eq 0 ] || fail "Failed to mount /system"
  122.             else
  123.                     losetup /dev/block/loop1 $card/system.img
  124.                     [ $? -eq 0 ] || fail "Failed to find system.img on SD Card"
  125.                     mount -t cramfs -o ro,noatime,nodiratime /dev/block/loop1 /system
  126.                     [ $? -eq 0 ] || fail "Failed to mount /system"
  127.             fi
  128.     else
  129.             echo "Using partitioned system"
  130.             e2fsck -y /dev/block/mmcblk0p2
  131.             mount -t ext2 -o ro,noatime,nodiratime /dev/block/mmcblk0p2 /system
  132.             [ $? -eq 0 ] || fail "Failed to mount /system"
  133.     fi
  134. fi
  135.  
  136. if [ -d /sdcard/AndroidApps ] ; then
  137.         echo Copying Applications
  138.         if [ ! -d /data/app ] ; then
  139.                 mkdir -m 0771 /data/app
  140.         fi
  141.         /bin/cp /sdcard/AndroidApps/* /data/app
  142.         chown -R 1000:1000 /data/app
  143. fi
  144.  
  145. if [ ! -d /sdcard/android/media ] ; then
  146.         echo You have no media folder, please extract the resources to your SD card android folder
  147. fi
  148.  
  149. SQLITE3="/bin/sqlite3"
  150. DB="/data/data/com.android.providers.telephony/databases/telephony.db"
  151. if [ -f $DB ] ; then
  152.         if [ "`$SQLITE3 $DB 'SELECT numeric FROM carriers;' | grep 310995`" != "310995" ] ; then
  153.                 echo Creating android apn
  154.                 "$SQLITE3" "$DB" "INSERT INTO carriers VALUES(NULL, 'Android' , '310995' , '310' , '995' , 'internet' , '*' , '*' , '*' , NULL, NULL, NULL, NULL, 'null' , 'default' , 1);"
  155.         fi
  156. else
  157.         echo No telephony database. You must have a new data file. I will check for the android apn on the next reboot
  158. fi
  159.  
  160. /bin/rm -rf /data/etc
  161. /bin/mkdir -m 0755 /data/etc
  162. mount /data/etc /etc
  163. cp -a /system/etc/* /etc
  164. cp -ar /init.etc/* /etc/
  165.  
  166. LCDDENSITY=`/bin/grep -o "lcd.density=.*" /proc/cmdline | /bin/sed -e "s/.*lcd.density=//g" -e "s/ .*//g"`
  167.  
  168. if [ "$LCDDENSITY" != "" ] ; then
  169.         echo "ro.sf.lcd_density=$LCDDENSITY" >> /etc/default.prop
  170.         echo Setting ro.sf.lcd_density=$LCDDENSITY
  171. fi
  172.  
  173. if [ ! -d /data/shared_prefs ] ; then
  174.         mkdir -m 0770 /data/shared_prefs
  175. fi
  176. chmod 0770 /data/shared_prefs
  177. chown 1000:1000 /data/shared_prefs
  178. mount /data/shared_prefs /shared_prefs
  179.  
  180. mount /sdcard/cache /tmp
  181.  
  182. cp /system/build.prop /tmp/build.prop
  183. KAISER=0
  184. DIAMOND=0
  185. ### Is this a Kaiser?
  186. if [ "`cat /proc/cpuinfo|grep -o Kaiser`" = "Kaiser" ]; then
  187.         echo "KAISER detected"
  188.         KAISER=1
  189.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  190.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  191.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  192.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  193.         fi
  194.         mount --bind /etc/wifi /system/lib/modules
  195. elif [ "`cat /proc/cpuinfo|grep -o Polaris`" = "Polaris" ]; then
  196.         echo "POLARIS detected"
  197.         KAISER=1
  198.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  199.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  200.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  201.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  202.         fi
  203.         mount --bind /etc/wifi /system/lib/modules
  204. elif [ "`cat /proc/cpuinfo|grep -o Diamond`" = "Diamond" ]; then
  205.         echo "DIAMOND detected"
  206.         DIAMOND=1
  207.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  208.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  209.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  210.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  211.         fi
  212.         mount --bind /etc/wifi /system/lib/modules
  213. elif [ "`cat /proc/cpuinfo|grep -o Raphael`" = "Raphael" ]; then
  214.         echo "RAPHAEL detected"
  215.         DIAMOND=1
  216.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  217.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  218.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  219.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  220.         fi
  221.         mount --bind /etc/wifi /system/lib/modules
  222. elif [ "`cat /proc/cpuinfo|grep -o blackstone`" = "blackstone" ]; then
  223.         echo "BLACKSTONE detected"
  224.         DIAMOND=1
  225.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  226.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  227.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  228.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  229.         fi
  230.         mount --bind /etc/wifi /system/lib/modules
  231. elif [ "`cat /proc/cpuinfo|grep -o Topaz`" = "Topaz" ]; then
  232.         echo "TOPAZ detected"
  233.         DIAMOND=1
  234.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  235.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  236.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  237.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  238.         fi
  239.         mount --bind /etc/wifi /system/lib/modules
  240. elif [ "`cat /proc/cpuinfo|grep -o Rhodium`" = "Rhodium" ]; then
  241.         echo "RHODIUM detected"
  242.         DIAMOND=1
  243.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  244.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  245.                 echo "wifi.interface = tiwlan0" >> /tmp/build.prop
  246.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  247.         fi
  248.         mount --bind /etc/wifi /system/lib/modules
  249. else
  250.         echo "VOGUE detected"
  251.         sed -i s/^wifi/#wifi/ /tmp/build.prop
  252. fi
  253.  
  254. mount --bind /tmp/build.prop /system/build.prop
  255.  
  256. ### Fix su on some builds...
  257. mount --bind /bin/su /system/bin/su
  258. mount --bind /bin/su /system/xbin/su
  259.  
  260. RCSCRIPT=""
  261. RCCONFIG=""
  262.  
  263. echo "Checking for build type..."
  264. if [ -f /system/hero.build ] ; then
  265.         echo "Hero build detected"
  266.         RCSCRIPT="hero"
  267.         RCCONFIG="hero"
  268.         ln /data/app_s /system/app
  269.  
  270. elif [ -f /system/eclairhero.build ] ; then
  271.         echo "HERO 2.1 BUILD DETECTED -- ECLAIR"
  272.         RCSCRIPT="eclairhero"
  273.         RCCONFIG="eclairhero"
  274.  
  275. elif [ -f /system/eclair.build ] ; then
  276.         echo "Eclair build detected"
  277.         RCSCRIPT="eclair"
  278.         RCCONFIG="eclair"
  279.  
  280. elif [ -f /system/tattoo.build ] ; then
  281.         echo "Tattoo build detected"
  282.         RCSCRIPT="tattoo"
  283.         RCCONFIG="tattoo"
  284.  
  285. elif [ -f /system/donut.build ] ; then
  286.         echo "Donut build detected"
  287.         RCSCRIPT="donut"
  288.         RCCONFIG="donut"
  289.  
  290. elif [ -d /system/lib/donut ] ; then
  291.         echo "Donut build detected"
  292.         RCSCRIPT="donut"
  293.         RCCONFIG="donut"
  294.  
  295. elif [ -f /system/xrom.build ] ; then
  296.         echo "xROM build detected"
  297.         RCSCRIPT="xrom"
  298.         RCCONFIG="xrom"
  299.  
  300. elif [ -f /system/rogers.build ] ; then
  301.         echo "Rogers build detected"
  302.         RCSCRIPT="rogers"
  303.         RCCONFIG="rogers"
  304.  
  305. elif [ -f /system/cyanogen.build ] ; then
  306.         echo "cyanogen experimental detected.....eating donuts"
  307.         RCSCRIPT="cyanogen"
  308.         RCCONFIG="cyanogen"
  309.  
  310. elif [ -f /system/custom.build ] ; then
  311.         echo "Custom init.rc detected"
  312.         cp /system/sysinit.rc /build.cfg/init.sysinit.rc
  313.         RCCONFIG="hero"
  314.         RCSCRIPT="sysinit"
  315.        
  316. else
  317.         echo "Unknown Android build. Assuming Ion variant"
  318.         RCSCRIPT="ion"
  319.         RCCONFIG="ion"
  320.  
  321.         # for the fake sensors library
  322.         mount /lib/hw /system/lib/hw -o loop
  323.         chmod 666 /dev/input/event0
  324.  
  325.         if [ $DIAMOND -eq 1 ] ; then
  326.                 RCCONFIG="ion.diamond"
  327.         fi
  328. fi
  329.  
  330. if [ $KAISER -eq 1 ] ; then
  331.         RCSCRIPT="$RCSCRIPT.kaiser"
  332. fi
  333.  
  334. echo "using /init.$RCSCRIPT.rc as init.rc"
  335. echo "using $card/conf/$RCCONFIG.user.conf"
  336.  
  337. cp "/init.cfg/init.$RCSCRIPT.rc" /etc/init.rc
  338.  
  339. #Assume this rootfs.img will be used only on "good" devices
  340. #Meaning raph/diam/blac/...
  341. DIAMOND=1
  342. if [ "$DIAMOND" = "1" ];then
  343.         if [ -e "/sdcard/modules-$(uname -r).tar.gz" ] ;then
  344.                 mkdir /data/modules
  345.                 mount --bind /data/modules /lib/modules
  346.                 tar xzf /sdcard/modules-$(uname -r).tar.gz -C /lib/modules
  347.                 cd /lib/modules
  348.                 for i in xvmalloc ramzswap;do
  349.                         insmod ${i}.ko
  350.                 done
  351.                 cp wlan.ko /etc/wifi
  352.         fi
  353.         sed -i s/^#wifi/wifi/ /tmp/build.prop
  354.         if [ "`grep -c ^wifi /tmp/build.prop`" != "2" ]; then
  355.                 echo "wifi.interface = wlan0" >> /tmp/build.prop
  356.                 echo "wifi.supplicant_scan_interval = 45" >> /tmp/build.prop
  357.         fi
  358.         mount --bind /etc/wifi /system/lib/modules
  359. fi
  360.  
  361.  
  362. if [ -f "$card/conf/$RCCONFIG.user.conf" ]; then
  363.         /bin/userinit.sh -c "$card/conf/$RCCONFIG.user.conf"
  364. else
  365.         echo "No user config files ($RCCONFIG) found on sdcard"
  366. fi
  367.  
  368. # echo /dev/block/mmcblk0p2 > /sys/devices/platform/usb_mass_storage/lun0/file
  369. ifconfig usb0 192.168.20.1 up
  370. busybox telnetd -b 192.168.20.1 -l /bin/sh
  371. #chmod 4755 /bin/su
  372. #mkdir -m 0777 /smodem
  373.  
  374. mount -tdebugfs none /dbgfs
  375. #Activate full charging
  376. echo 2 > /dbgfs/htc_battery/charger_state
  377. echo 1024 > /dbgfs/micropklt_dbg/sleep_leds
  378.  
  379. exec /init.android

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

worth-right
fantasy-obligation