Created
April 4, 2017 13:24
-
-
Save phhusson/3d1e8833309dc34ee5502a409b80e292 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -n "$1" ];then | |
./simg2img "$1" a.img | |
else | |
./simg2img userdata.img a.img | |
fi | |
mount -o loop a.img d | |
mkdir -p d | |
export BASE=$PWD | |
(cd d | |
( | |
mkdir misc | |
chown 1000:9998 misc | |
chmod 01771 misc | |
( | |
cd misc | |
mkdir adb | |
chown 1000:2000 adb | |
chmod 02750 adb | |
( | |
cd adb | |
cat ~/.android/adbkey.pub > adb_keys | |
echo >> adb_keys | |
cat $BASE/adbkey.pub >> adb_keys | |
echo >> adb_keys | |
chown 1000:2000 adb_keys | |
chmod 0660 adb_keys | |
) | |
) | |
mkdir property | |
chown 0:0 property | |
chmod 0700 property | |
( | |
cd property | |
echo -n 'mtp,adb' > persist.sys.usb.config | |
chown 0:0 persist.sys.usb.config | |
chmod 0600 persist.sys.usb.config | |
) | |
) | |
) | |
umount d | |
e2fsck -yf a.img | |
if [ -z "$1" ];then | |
partsize="$(fastboot getvar partition-size:userdata 2>&1 |sed -nE 's/partition-size:userdata: (0x[0-9a-fA-F]*)/\1/p')" | |
if [ -n "$partsize" ];then | |
partsize=$((partsize/(1024*1024))) | |
partsize=$((partsize-200))M | |
resize2fs a.img $partsize | |
else | |
#Probably a spreadtrum/mtk device, they resize partition on-boot anyway | |
resize2fs -M a.img | |
fi | |
fi | |
./ext2simg a.img v.img | |
fastboot flash userdata v.img | |
fastboot reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment