Skip to content

Instantly share code, notes, and snippets.

@weedy
Created November 16, 2012 18:36
Show Gist options
  • Select an option

  • Save weedy/4089728 to your computer and use it in GitHub Desktop.

Select an option

Save weedy/4089728 to your computer and use it in GitHub Desktop.

Revisions

  1. weedy created this gist Nov 16, 2012.
    56 changes: 56 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    #!/sbin/busybox sh
    # Weedy - miuiandroid.com
    # ./usim - "Universal" System Identification & Mounting thingy
    # 0.1 - 12-11-16 - Initial release.
    cwmPid=$(ps | grep -v "grep" | grep -o -E "(.*)update_binary" | cut -d " " -f 3)
    cwmFD=$(ps | grep -v "grep" | grep -o -E "update_binary(.*)" | cut -d " " -f 3)
    logFile="/sdcard/usim-errors.log"
    passedDev="$*"
    recoveryDev=$(awk '/ro.product.device=/ {split($0,dev,"="); print dev[2]}' < /default.prop)
    if [ -z "$passedDev" ]; then passedDev="$recoveryDev"; fi

    failed () {
    touch "$logFile"
    date +%Y-%m-%d\ %H:%M:%S >> "$logFile"
    splitOutput "usim 0.1" >> $logFile
    splitOutput "Your device is not supported or something has gone wrong." >> $logFile
    splitOutput "Please mount /system manually and try this zip again." >> $logFile
    splitOutput "Then give the \"$logFile\" to your dev." >> $logFile
    splitOutput "Device: $passedDev / $recoveryDev" >> $logFile
    splitOutput "System: $(awk '/\/system/ {split($0,dev," "); print dev[1]}' < /proc/mounts)" >> $logFile
    splitOutput "" >> $logFile
    exit 1
    }
    splitOutput () {
    echo "ui_print $* " 1>&$cwmFD;
    echo "ui_print " 1>&$cwmFD;
    echo "$*"
    }

    #splitOutput "USIM Device arg: $passedDev" >> /dev/null
    #splitOutput "USIM Detected: $recoveryDev" >> /dev/null
    case "$passedDev" in
    # Sorted by mount point
    GT-I9100|GT-I9300|m0)
    mount -o rw /dev/block/mmcblk0p9 /system || failed ;;
    endeavoru|hwu8860|LT26i|u8860)
    mount -o rw /dev/block/mmcblk0p12 /system || failed ;;
    pyramid|shooteru)
    mount -o rw /dev/block/mmcblk0p22 /system || failed ;;
    ville)
    mount -o rw /dev/block/mmcblk0p33 /system || failed ;;
    umts_spyder)
    mount -o rw /dev/block/mmcblk1p20 /system || failed ;;
    maguro|toro)
    mount -o rw /dev/block/platform/omap/omap_hsmmc.0/by-name/system /system || failed ;;
    hwu9200|hwu9500|front|viva)
    mount -o rw /dev/block/platform/omap/omap_hsmmc.1/by-name/system /system || failed ;;
    crespo|crespo4g)
    mount -o rw /dev/block/platform/s3c-sdhci.0/by-name/system /system || failed ;;
    grouper|ventana)
    mount -o rw /dev/block/platform/sdhci-tegra.3/by-name/APP /system || failed ;;
    ## Unsupported fallback
    *)
    failed ;;
    esac
    exit 0