From 555c53fbd2cd12845ceaf821a3dd1b5781841f38 Mon Sep 17 00:00:00 2001 From: LukeZGD Date: Sun, 30 May 2021 11:03:39 +0800 Subject: [PATCH] Exit codes and other stuff --- resources/blobs.sh | 2 +- resources/depends.sh | 5 ++--- resources/device.sh | 9 ++++++--- resources/downgrade.sh | 4 ++-- resources/ipsw.sh | 20 +++++++++++--------- restore.sh | 11 +++++------ 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/resources/blobs.sh b/resources/blobs.sh index cfb92cf..87fc8b4 100755 --- a/resources/blobs.sh +++ b/resources/blobs.sh @@ -21,7 +21,7 @@ SaveOTABlobs() { Error "Saving $OSVer blobs failed. Please run the script again" \ "It is also possible that $OSVer for $ProductType is no longer signed" elif [[ ! $SHSH ]]; then - Log "Saving $OSVer blobs failed, but detected existing saved SHSH blobs. Continuing..." + Log "Saving $OSVer blobs failed, but found existing saved SHSH blobs. Continuing..." cp $SHSHExisting . SHSH=$(ls $SHSHChk) else diff --git a/resources/depends.sh b/resources/depends.sh index f2367aa..8ea63b9 100755 --- a/resources/depends.sh +++ b/resources/depends.sh @@ -11,7 +11,6 @@ SetToolPaths() { ipsw="env LD_LIBRARY_PATH=./lib ./tools/ipsw_linux" partialzip="./resources/tools/partialzip_linux" python="$(which python2)" - tsschecker="./resources/tools/tsschecker_linux" ipwndfu="sudo $python ipwndfu" rmsigchks="sudo $python rmsigchks.py" SimpleHTTPServer="sudo $python -m SimpleHTTPServer 80" @@ -27,7 +26,6 @@ SetToolPaths() { ipwnder32="./resources/tools/ipwnder32_macos" partialzip="./resources/tools/partialzip_macos" python="/usr/bin/python" - tsschecker="./resources/tools/tsschecker_macos" ipwndfu="$python ipwndfu" rmsigchks="$python rmsigchks.py" SimpleHTTPServer="$python -m SimpleHTTPServer 80" @@ -43,6 +41,7 @@ SetToolPaths() { SSH="-F ./resources/ssh_config" SCP="$(which scp) $SSH" SSH="$(which ssh) $SSH" + tsschecker="./resources/tools/tsschecker_$platform" Log "Running on platform: $platform $macver" } @@ -142,5 +141,5 @@ InstallDepends() { cd .. Log "Install script done! Please run the script again to proceed" - exit + exit 0 } diff --git a/resources/device.sh b/resources/device.sh index d6dd981..bd81497 100755 --- a/resources/device.sh +++ b/resources/device.sh @@ -103,7 +103,7 @@ GetDeviceValues() { HWModel=$(cat $Firmware/hwmodel) if [[ ! $BasebandURL || ! $HWModel ]]; then - Error "GetDeviceValues: Missing BasebandURL and/or HWModel values. Is the firmware folder missing?" \ + Error "Missing BasebandURL and/or HWModel values. Is the firmware folder missing?" \ "Reinstall dependencies and try again. For more details, read the 'Other Notes' section of the README" fi @@ -182,7 +182,7 @@ Recovery() { if [[ $RecoveryDFU == 'N' || $RecoveryDFU == 'n' ]]; then Log "Exiting recovery mode." $irecovery -n - exit + exit 0 fi Echo "* Hold POWER and HOME button for 8 seconds." @@ -258,7 +258,10 @@ kDFU() { read -p "$(Input 'Enter the IP Address of your device:')" IPAddress Log "Copying stuff to device via SSH..." $SCP resources/tools/$kloader tmp/pwnediBSS root@$IPAddress:/tmp - [[ $? == 1 ]] && Error "Cannot connect to device via SSH." "Please try the steps above to make sure that SSH is successful" + if [[ $? == 1 ]]; then + Error "Cannot connect to device via SSH." \ + "Please try the steps above to make sure that SSH is successful" + fi $SSH root@$IPAddress "/tmp/$kloader /tmp/pwnediBSS" & fi diff --git a/resources/downgrade.sh b/resources/downgrade.sh index 038b86c..58b2415 100755 --- a/resources/downgrade.sh +++ b/resources/downgrade.sh @@ -86,11 +86,11 @@ Downgrade() { $ProductType == "iPad2,7" || $ProductType == "iPod5,1" ]]; then Log "Warning - A5 Rev A device detected. Enabling the jailbreak option might not work for you" read -p "$(Input 'Select Y to continue anyway, N to cancel and exit (y/N):')" Jailbreak - [[ $Jailbreak == 'Y' || $Jailbreak == 'y' ]] && Jailbreak=1 || exit + [[ $Jailbreak == 'Y' || $Jailbreak == 'y' ]] && Jailbreak=1 || exit 0 fi fi - if [[ $Mode == "Downgrade" && $ProductType == iPhone5,1 && $Jailbreak != 1 ]]; then + if [[ $Mode == "Downgrade" && $ProductType == "iPhone5,1" && $Jailbreak != 1 ]]; then Echo "* By default, iOS-OTA-Downgrader now flashes the iOS 8.4.1 baseband to iPhone5,1" Echo "* Flashing the latest baseband is still available as an option but beware of problems it may cause" Echo "* There are potential network issues that with the latest baseband when used on iOS 8.4.1" diff --git a/resources/ipsw.sh b/resources/ipsw.sh index 64339cb..06fd8b4 100755 --- a/resources/ipsw.sh +++ b/resources/ipsw.sh @@ -4,7 +4,7 @@ IPSW32() { local JBFiles local JBMemory local JBSHA1 - local JBS + local JBPartSize if [[ $IPSWRestore == $IPSWCustom ]]; then Log "Found existing Custom IPSW. Skipping IPSW creation." @@ -12,13 +12,13 @@ IPSW32() { fi if [[ $OSVer == 8.4.1 ]]; then - JBFiles=(fstab.tar etasonJB-untether.tar Cydia8.tar) - JBSHA1=6459dbcbfe871056e6244d23b33c9b99aaeca970 - JBS=2305 + JBFiles=("fstab.tar" "etasonJB-untether.tar" "Cydia8.tar") + JBSHA1="6459dbcbfe871056e6244d23b33c9b99aaeca970" + JBPartSize=2305 else - JBFiles=(fstab_rw.tar p0sixspwn.tar Cydia6.tar) - JBSHA1=1d5a351016d2546aa9558bc86ce39186054dc281 - JBS=1260 + JBFiles=("fstab_rw.tar" "p0sixspwn.tar" "Cydia6.tar") + JBSHA1="1d5a351016d2546aa9558bc86ce39186054dc281" + JBPartSize=1260 fi if [[ ! -e resources/jailbreak/${JBFiles[2]} ]]; then cd tmp @@ -38,7 +38,7 @@ IPSW32() { Log "Preparing custom IPSW..." cd resources ln -sf firmware/FirmwareBundles FirmwareBundles - $ipsw ../$IPSW.ipsw ../$IPSWCustom.ipsw $JBMemory -bbupdate -s $JBS ${JBFiles[@]} + $ipsw ../$IPSW.ipsw ../$IPSWCustom.ipsw $JBMemory -bbupdate -s $JBPartSize ${JBFiles[@]} cd .. fi if [[ ! -e $IPSWCustom.ipsw ]]; then @@ -68,7 +68,9 @@ IPSW64() { zip ../$IPSWCustom.ipsw -rq0 * cd .. mv $IPSW $IPSWCustom - [[ ! -e $IPSWCustom.ipsw ]] && Error "Failed to find custom IPSW. Please run the script again" + if [[ ! -e $IPSWCustom.ipsw ]]; then + Error "Failed to find custom IPSW. Please run the script again" + fi Log "Setting restore IPSW to: $IPSWCustom.ipsw" IPSWRestore=$IPSWCustom } diff --git a/restore.sh b/restore.sh index dcdc291..7e0ec70 100755 --- a/restore.sh +++ b/restore.sh @@ -1,5 +1,5 @@ #!/bin/bash -trap "Clean; exit" INT TERM EXIT +trap "Clean" EXIT INT TERM . ./resources/blobs.sh . ./resources/depends.sh @@ -28,7 +28,6 @@ Clean() { ps aux | awk '/python/ {print "sudo kill -9 "$2" 2>/dev/null"}' | bash fi fi - echo } Echo() { @@ -131,7 +130,7 @@ Main() { Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"; read -s; kDFU iBSS; break;; - * ) exit;; + * ) exit 0;; esac done Log "Downgrading $ProductType in kDFU/pwnDFU mode..." @@ -174,7 +173,7 @@ Main() { "Save OTA blobs" ) Mode="SaveOTABlobs"; break;; "Just put device in kDFU mode" ) Mode="kDFU"; break;; "(Re-)Install Dependencies" ) InstallDepends;; - * ) exit;; + * ) exit 0;; esac done fi @@ -185,7 +184,7 @@ Main() { [[ $Mode == "Downgrade" ]] && Downgrade [[ $Mode == "SaveOTABlobs" ]] && SaveOTABlobs [[ $Mode == "kDFU" ]] && kDFU - exit + exit 0 } SelectVersion() { @@ -217,7 +216,7 @@ SelectVersion() { "iOS 8.4.1" ) OSVer="8.4.1"; BuildVer="12H321"; break;; "iOS 6.1.3" ) OSVer="6.1.3"; BuildVer="10B329"; break;; "Other (use SHSH blobs)" ) OSVer="Other"; break;; - *) exit;; + *) exit 0;; esac done }