Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@shakalaca
Created October 11, 2014 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shakalaca/09af3dbe72129a026fb9 to your computer and use it in GitHub Desktop.
Save shakalaca/09af3dbe72129a026fb9 to your computer and use it in GitHub Desktop.
upi_ug31xx
#!/system/bin/sh
DATA_PARTITION=/dev/block/mmcblk0p10
SYSTEM_PARTITION=/dev/block/mmcblk0p9
if [ -L /dev/block/platform/intel/by-label/data ]; then
DATA_PARTITION=/dev/block/platform/intel/by-label/data
fi
if [ -L /dev/block/platform/intel/by-label/system ]; then
SYSTEM_PARTITION=/dev/block/platform/intel/by-label/system
fi
# main stuff
CHMOD="/system/bin/chmod"
CHOWN="/system/bin/chown"
MKDIR="/system/bin/mkdir"
RMDIR="/system/bin/rmdir"
CP="/system/bin/cp"
RM="/system/bin/rm"
MV="/system/bin/mv"
CAT="/system/bin/cat"
set_perm() {
$CHOWN $1.$2 $4
$CHOWN $1:$2 $4
$CHMOD $3 $4
}
DATA=/tmp/data
SYSTEM=/tmp/system
BIN=bin
COM=common
# "- Mounting /system, /data and rootfs"
/system/bin/mount -r -w -o remount /
$CHMOD 755 /su/busybox
/su/busybox mount -o rw -t ext4 $DATA_PARTITION $DATA
/su/busybox mount -o rw -t ext4 $SYSTEM_PARTITION $SYSTEM
# " - Extracting files"
cd /su
/su/busybox tar zxf /su/supersu.tgz
# "- Disabling OTA survival"
$CHMOD 0755 $BIN/chattr
$CHMOD 0755 $BIN/chattr.pie
if [ -f $SYSTEM/xbin/su ]; then
$BIN/chattr -i $SYSTEM/xbin/su
$BIN/chattr.pie -i $SYSTEM/xbin/su
fi
if [ -f $SYSTEM/bin/.ext/.su ]; then
$BIN/chattr -i $SYSTEM/bin/.ext/.su
$BIN/chattr.pie -i $SYSTEM/bin/.ext/.su
fi
if [ -f $SYSTEM/xbin/daemonsu ]; then
$BIN/chattr -i $SYSTEM/xbin/daemonsu
$BIN/chattr.pie -i $SYSTEM/xbin/daemonsu
fi
if [ -f $SYSTEM/etc/install-recovery.sh ]; then
$BIN/chattr -i $SYSTEM/etc/install-recovery.sh
$BIN/chattr.pie -i $SYSTEM/etc/install-recovery.sh
fi
# "- Removing old files"
$RM -f $SYSTEM/xbin/su
$RM -f $SYSTEM/xbin/.tmpsu
$RM -f $SYSTEM/xbin/daemonsu
$RM -f $SYSTEM/xbin/sugote
$RM -f $SYSTEM/xbin/sugote-mksh
$RM -f $SYSTEM/bin/.ext/.su
$RM -f $SYSTEM/etc/install-recovery.sh
$RM -f $SYSTEM/etc/install-recovery.sh.bak
$RM -f $SYSTEM/etc/.installed_su_daemon
$RM -f $SYSTEM/app/Superuser.apk
$RM -f $DATA/dalvik-cache/*Superuser.apk*
$RM -f $DATA/dalvik-cache/*eu.chainfire.supersu*
$RM -f $DATA/dalvik-cache/*.oat
$RM -f $DATA/app/eu.chainfire.supersu-*
if [ -f $SYSTEM/bin/asusrmdir1.sh.bak ]; then
$RM -f $SYSTEM/bin/asusrmdir1.sh
$MV $SYSTEM/bin/asusrmdir1.sh.bak $SYSTEM/bin/asusrmdir1.sh
fi
# "- Placing files"
FOLDER=$SYSTEM/bin/.ext
if [ ! -d "$FOLDER" ]; then
$MKDIR -p "$FOLDER"
fi
$CP $BIN/su $SYSTEM/xbin/daemonsu
$CP $BIN/su $SYSTEM/xbin/su
$CP $BIN/su $SYSTEM/xbin/sugote
$CP $SYSTEM/bin/mksh $SYSTEM/xbin/sugote-mksh
$CP $BIN/su $SYSTEM/bin/.ext/.su
$CP $COM/Superuser.apk $SYSTEM/app/Superuser.apk
$CP $COM/install-recovery.sh $SYSTEM/etc/install-recovery.sh
echo 1 > $SYSTEM/etc/.installed_su_daemon
$CP $COM/install-recovery.sh $SYSTEM/etc/install-recovery.sh.bak
$MV $SYSTEM/bin/asusrmdir1.sh $SYSTEM/bin/asusrmdir1.sh.bak
$CP $COM/asusrmdir1.sh $SYSTEM/bin/asusrmdir1.sh
$CAT $SYSTEM/bin/asusrmdir1.sh.bak >> $SYSTEM/bin/asusrmdir1.sh
# "- Setting permissions"
set_perm 0 0 0777 $SYSTEM/bin/.ext
set_perm 0 0 0755 $SYSTEM/bin/.ext/.su
set_perm 0 0 0755 $SYSTEM/xbin/su
set_perm 0 0 0755 $SYSTEM/xbin/sugote
set_perm 0 0 0755 $SYSTEM/xbin/sugote-mksh
set_perm 0 0 0755 $SYSTEM/xbin/daemonsu
set_perm 0 0 0544 $SYSTEM/etc/install-recovery.sh
set_perm 0 0 0644 $SYSTEM/etc/.installed_su_daemon
set_perm 0 0 0644 $SYSTEM/app/Superuser.apk
set_perm 0 2000 0755 $SYSTEM/bin/asusrmdir1.sh
set_perm 0 0 0755 $SYSTEM/etc/install-recovery.sh.bak
# "- Post-installation script"
$SYSTEM/xbin/su --install
$SYSTEM/bin/reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment