TegraScript/scripts/systemRestore.te

233 lines
4.3 KiB
Text
Raw Normal View History

2020-04-12 22:30:47 +02:00
setString("BOOT0.bin", $BOOT0Path)
setString("BOOT1.bin", $BOOT1Path)
setString("BCPKG2-1-Normal-Main", $BCPKG1)
setString("BCPKG2-2-Normal-Sub", $BCPKG2)
setString("BCPKG2-3-SafeMode-Main", $BCPKG3)
setString("BCPKG2-4-SafeMode-Sub", $BCPKG4)
setString("Exit
", $menuoption1)
setString("BOOT: ", $menuoption2)
setString("SYSTEM: ", $menuoption3)
setString("
SYSMMC", $menuoption4)
2020-04-05 22:09:33 +02:00
if (@EMUMMC){
2020-04-12 22:30:47 +02:00
setString("EMUMMC", $menuoption5)
2020-04-05 22:09:33 +02:00
}
2020-04-12 22:30:47 +02:00
printf("System restore script")
printf("")
printf("Select what to restore")
printf("And where to restore to")
2020-04-05 22:09:33 +02:00
2020-04-12 22:30:47 +02:00
@selection = setInt(7)
@restoreBOOT = setInt(1)
@restoreSYS = setInt(1)
@maxSelection = setInt(10)
if (@EMUMMC){
@maxSelection = math(@maxSelection, "+", 1)
}
@optionLoop = getPosition()
setPrintPos(0, 6)
@current = setInt(7)
@drawLoop = getPosition()
setColor("WHITE")
setStringIndex(@current, $toDraw)
if (@current, "==", 8){
if (@restoreBOOT){
combineStrings($toDraw, "ON ", $toDraw)
}
if (@restoreBOOT, "==", 0){
combineStrings($toDraw, "OFF", $toDraw)
}
2020-04-05 22:09:33 +02:00
}
2020-04-12 22:30:47 +02:00
if (@current, "==", 9){
if (@restoreSYS){
combineStrings($toDraw, "ON " , $toDraw)
}
if (@restoreSYS, "==", 0){
combineStrings($toDraw, "OFF", $toDraw)
}
}
if (@selection, "==", @current){
setColor("VIOLET")
}
printf($toDraw)
@current = math(@current, "+", 1)
if (@current, "<=", @maxSelection){
goto(@drawLoop)
}
pause()
2020-04-05 22:09:33 +02:00
if (@BTN_VOL-){
2020-04-12 22:30:47 +02:00
if (@selection, "<", @maxSelection){
@selection = math(@selection, "+", 1)
}
}
if (@BTN_VOL+){
if (@selection, ">", 7){
@selection = math(@selection, "-", 1)
}
}
if (@BTN_POWER, "==", 0){
goto(@optionLoop)
}
if (@selection, "==", 7){
exit()
}
if (@selection, "==", 8){
@restoreBOOT = invert(@restoreBOOT)
goto(@optionLoop)
}
if (@selection, "==", 9){
@restoreSYS = invert(@restoreSYS)
goto(@optionLoop)
}
clearscreen()
setColor("WHITE")
printf("System restore script")
printf("")
if (@restoreBOOT){
printf("BOOT: ON")
}
if (@restoreBOOT, "==", 0){
printf("BOOT: OFF")
}
if (@restoreSYS){
printf("SYSTEM: ON")
}
if (@restoreSYS, "==", 0){
printf("SYSTEM: OFF")
}
printf("Checking requirements...")
printf("")
if (@restoreSYS){
fs_combinePath($CURRENTPATH, "SYSTEM", $path)
@check = fs_exists($path)
@checkinv = invert(@check)
if (@checkinv){
printf("System DIR not found!")
printf("Press any button to exit")
pause()
exit()
}
}
if (@restoreBOOT){
fs_combinePath($CURRENTPATH, "boot.bis", $path)
@check = fs_exists($path)
if (@check, "==", 0){
printf("boot.bis not found!")
printf("Press any button to exit")
pause()
exit()
}
fs_mkdir("sd:/tegraexplorer")
fs_mkdir("sd:/tegraexplorer/bisextract")
fs_extractBisFile($path, "sd:/tegraexplorer/bisextract")
}
if (@selection, "==", 10){
printf("Mounting SYSMMC...")
mmc_connect("SYSMMC")
}
if (@selection, "==", 11){
if (@EMUMMC, "==", 0){
exit()
2020-04-05 22:09:33 +02:00
}
2020-04-12 22:30:47 +02:00
printf("Mounting EMUMMC...")
mmc_connect("EMUMMC")
}
printf("Ready!")
setColor("RED")
printf("")
printf("WARNING!!!")
printf("If you do not know exactly what this does")
printf(" STOP!")
printf("")
printf("This will fuck with your system!")
printf("Only do this as")
printf(" a last ditch recovery effort!")
printf("")
setColor("GREEN")
printf("For help go here:")
printf("https://discord.gg/C29hYvh")
setColor("WHITE")
printf("")
wait(10)
printf("Vol+ to continue")
printf("Vol- or power to exit")
pause()
if (@BTN_VOL+, "==", 0){
exit()
}
clearscreen()
printf("GO!")
if (@restoreBOOT){
printf("")
printf("Restoring BIS")
@i = setInt(1)
@loop = getPosition()
setStringIndex(@i, $part)
combineStrings("sd:/tegraexplorer/bisextract/", $part, $path)
mmc_restorePart($path)
if (@RESULT){
setColor("RED")
printf("Restoring went wrong!")
printf("Part:")
printf($part)
pause()
exit()
}
@i = math(@i, "+", 1)
if (@i, "<", 7){
goto(@loop)
}
}
if (@restoreSYS){
printf("")
printf("Restoring SYSTEM")
mmc_mount("SYSTEM")
fs_combinePath($CURRENTPATH, "SYSTEM/Contents/registered", $path)
fs_delRecursive("emmc:/Contents/registered")
fs_copyRecursive($path, "emmc:/Contents")
fs_combinePath($CURRENTPATH, "SYSTEM/save/8000000000000120", $path)
fs_copy($path, "emmc:/save/8000000000000120")
}
printf("")
printf("Done!")
printf("Press any button to exit")
pause()
exit()