
# Script Version: 0.5

mount("MTD", "system", "/system");

if(SCRIPT == "s-on");
  ui_print("unrEVOked forever S-ON patch v1.1");
else();
  ui_print("unrEVOked forever S-OFF patch v1.1");

ui_print("Verifying system type...");

assert(getprop("ro.product.device") == "supersonic" ||
       getprop("ro.build.product") == "supersonic" ||
       getprop("ro.product.device") == "inc" ||
       getprop("ro.build.product") == "inc" ||
       getprop("ro.product.device") == "heroc" ||
       getprop("ro.build.product") == "heroc");

ui_print("Verifying current system...");

# nothing interesting here

ui_print("Unpacking patches...");
package_extract_dir("patch", "/tmp/s-off");

# ---- start making changes here ----

ui_print("Removing unneeded files...");
delete("/system/etc/s-on.conf");

ui_print("Patching system files...");

apply_patch("/system/app/EPST.odex", "-",
            096b3a0fb108fae68d6e3d83c7269b54ff22b317, 101337,
            "c29b9f3b78835e7e62fce299a652cea1952a855b:/tmp/s-off/EPST.leak.odex.p");

ui_print("Unpacking new files...");

# nothing interesting here

ui_print("Symlinks and permissions...");

set_perm_recursive(0, 2000, 0755, 0755, "/system/xbin");

# thank god it works for s-on and s-off
htc_diag("security=off", ea80e0b3);

ui_print("Syncing flash...");
run_program("/sbin/busybox", "sync --security");

ui_print("Verifying update...");
assert(htc_diag("security") == "off");

unmount("/system");

ui_print("Update successful.");
ui_print("http://unrevoked.com/");

