#!/bin/bash
chmod +x adb-mac
kenneth=adb-mac
echo "Don't touch the device or unplug while rooting!"
echo "Push files"
./$kenneth kill-server
./$kenneth wait-for-device
./$kenneth shell rm /data/local/installbusybox
./$kenneth shell rm /data/local/installbusybox2
./$kenneth shell rm /data/local/root
./$kenneth shell rm /data/local/root2
./$kenneth shell rm /data/local/sysro
./$kenneth shell rm /data/local/sysro2
./$kenneth shell rm /data/local/sysrw
./$kenneth shell rm /data/local/sysrw2
./$kenneth shell rm /data/local/unroot
./$kenneth shell rm /data/local/unroot2
./$kenneth shell rm /data/local/busybox
./$kenneth shell rm /data/local/su
./$kenneth shell rm /data/local/Superuser.apk
./$kenneth push busybox /data/local/busybox
./$kenneth push su /data/local/su
./$kenneth push Superuser.apk /data/local/Superuser.apk
./$kenneth shell chmod 777 /data/local/busybox
./$kenneth shell chmod 755 /data/local/su
./$kenneth shell chmod 755 /data/local/Superuser.apk
./$kenneth shell mv /data/local/tmp /data/local/tmp.bak
./$kenneth shell ln -s /data /data/local/tmp
./$kenneth shell rm /data/local.prop
./$kenneth shell "mount -wo remount rootfs /"
./$kenneth shell "mount -o remount,rw -t ext4 /dev/block/mmcblk0p33 /system"
./$kenneth shell "cat /data/local/busybox > /system/xbin/busybox"
./$kenneth shell "chmod 777 /system/xbin/busybox"
./$kenneth shell "/system/xbin/busybox --install -s /system/xbin"
./$kenneth shell "busybox cp /data/local/Superuser.apk /system/app/Superuser.apk"
./$kenneth shell "busybox cp /data/local/su /system/xbin/su"
./$kenneth shell "chown 0.0 /system/xbin/su"
./$kenneth shell "chmod 06755 /system/xbin/su"
./$kenneth shell "chmod 644 /system/app/Superuser.apk"
./$kenneth shell "rm /data/local.prop"
./$kenneth shell "rm /data/local/tmp"
./$kenneth shell "mv /data/local/tmp.bak /data/local/tmp"
echo "Reboot"
./$kenneth reboot