Do not use "function"

This commit is contained in:
LukeZGD 2021-05-01 14:21:29 +08:00
parent dd66193a10
commit e00264f5e5
2 changed files with 21 additions and 21 deletions

View File

@ -5,11 +5,11 @@ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pk
echo "This script can be used to compile tools used by iOS-OTA-Downgrader for Linux" echo "This script can be used to compile tools used by iOS-OTA-Downgrader for Linux"
function Clone { Clone() {
git clone $3 https://github.com/$1/$2 git clone $3 https://github.com/$1/$2
} }
function Compile { Compile() {
[[ $3 == --recursive ]] && Clone $1 $2 $3 || Clone $1 $2 [[ $3 == --recursive ]] && Clone $1 $2 $3 || Clone $1 $2
cd $2 cd $2
[[ -e autogen.sh ]] && ./autogen.sh $3 $4 [[ -e autogen.sh ]] && ./autogen.sh $3 $4

View File

@ -8,30 +8,30 @@ if [[ $1 != 'NoColor' ]] && [[ $2 != 'NoColor' ]]; then
Color_N=$(tput sgr0) Color_N=$(tput sgr0)
fi fi
function Clean { Clean() {
rm -rf iP*/ shsh/ tmp/ ${UniqueChipID}_${ProductType}_*.shsh2 ${UniqueChipID}_${ProductType}_${HWModel}ap_*.shsh *.im4p *.bbfw BuildManifest.plist rm -rf iP*/ shsh/ tmp/ ${UniqueChipID}_${ProductType}_*.shsh2 ${UniqueChipID}_${ProductType}_${HWModel}ap_*.shsh *.im4p *.bbfw BuildManifest.plist
} }
function Echo { Echo() {
echo "${Color_B}$1 ${Color_N}" echo "${Color_B}$1 ${Color_N}"
} }
function Error { Error() {
echo -e "\n${Color_R}[Error] $1 ${Color_N}" echo -e "\n${Color_R}[Error] $1 ${Color_N}"
[[ ! -z $2 ]] && echo "${Color_R}* $2 ${Color_N}" [[ ! -z $2 ]] && echo "${Color_R}* $2 ${Color_N}"
echo echo
exit 1 exit 1
} }
function Input { Input() {
echo "${Color_Y}[Input] $1 ${Color_N}" echo "${Color_Y}[Input] $1 ${Color_N}"
} }
function Log { Log() {
echo "${Color_G}[Log] $1 ${Color_N}" echo "${Color_G}[Log] $1 ${Color_N}"
} }
function Main { Main() {
clear clear
Echo "******* iOS-OTA-Downgrader *******" Echo "******* iOS-OTA-Downgrader *******"
Echo " Downgrader script by LukeZGD " Echo " Downgrader script by LukeZGD "
@ -187,7 +187,7 @@ function Main {
SelectVersion SelectVersion
} }
function SelectVersion { SelectVersion() {
if [[ $ProductType == iPad4* ]] || [[ $ProductType == iPhone6* ]]; then if [[ $ProductType == iPad4* ]] || [[ $ProductType == iPhone6* ]]; then
OSVer='10.3.3' OSVer='10.3.3'
BuildVer='14G60' BuildVer='14G60'
@ -218,7 +218,7 @@ function SelectVersion {
Action Action
} }
function Action { Action {
Log "Option: $Mode" Log "Option: $Mode"
if [[ $OSVer == 'Other' ]]; then if [[ $OSVer == 'Other' ]]; then
Echo "* Move/copy the IPSW and SHSH to the directory where the script is located" Echo "* Move/copy the IPSW and SHSH to the directory where the script is located"
@ -255,7 +255,7 @@ function Action {
exit exit
} }
function SaveOTABlobs { SaveOTABlobs() {
Log "Saving $OSVer blobs with tsschecker..." Log "Saving $OSVer blobs with tsschecker..."
BuildManifest="resources/manifests/BuildManifest_${ProductType}_${OSVer}.plist" BuildManifest="resources/manifests/BuildManifest_${ProductType}_${OSVer}.plist"
if [[ $A7Device == 1 ]]; then if [[ $A7Device == 1 ]]; then
@ -282,7 +282,7 @@ function SaveOTABlobs {
fi fi
} }
function kDFU { kDFU() {
if [ ! -e saved/$ProductType/$iBSS.dfu ]; then if [ ! -e saved/$ProductType/$iBSS.dfu ]; then
Log "Downloading iBSS..." Log "Downloading iBSS..."
$partialzip $(cat $Firmware/$iBSSBuildVer/url) Firmware/dfu/$iBSS.dfu $iBSS.dfu $partialzip $(cat $Firmware/$iBSSBuildVer/url) Firmware/dfu/$iBSS.dfu $iBSS.dfu
@ -347,7 +347,7 @@ function kDFU {
kill $iproxyPID kill $iproxyPID
} }
function Recovery { Recovery() {
[[ $($irecovery -q 2>/dev/null | grep 'MODE' | cut -c 7-) == "Recovery" ]] && RecoveryDevice=1 [[ $($irecovery -q 2>/dev/null | grep 'MODE' | cut -c 7-) == "Recovery" ]] && RecoveryDevice=1
if [[ $RecoveryDevice != 1 ]]; then if [[ $RecoveryDevice != 1 ]]; then
Log "Entering recovery mode..." Log "Entering recovery mode..."
@ -379,7 +379,7 @@ function Recovery {
Error "Failed to detect device in DFU mode. Please run the script again" Error "Failed to detect device in DFU mode. Please run the script again"
} }
function CheckM8 { CheckM8() {
DFUManual=1 DFUManual=1
[[ $A7Device == 1 ]] && echo -e "\n$(Log 'Device in DFU mode detected.')" [[ $A7Device == 1 ]] && echo -e "\n$(Log 'Device in DFU mode detected.')"
if [[ $platform == macos ]]; then if [[ $platform == macos ]]; then
@ -432,7 +432,7 @@ function CheckM8 {
fi fi
} }
function Downgrade { Downgrade() {
if [[ $OSVer != 'Other' ]]; then if [[ $OSVer != 'Other' ]]; then
[[ $ProductType == iPad4* ]] && IPSWType="iPad_64bit" [[ $ProductType == iPad4* ]] && IPSWType="iPad_64bit"
[[ $ProductType == iPhone6* ]] && IPSWType="iPhone_4.0_64bit" [[ $ProductType == iPhone6* ]] && IPSWType="iPhone_4.0_64bit"
@ -613,7 +613,7 @@ function Downgrade {
Log "Downgrade script done!" Log "Downgrade script done!"
} }
function InstallDependencies { InstallDependencies() {
mkdir tmp 2>/dev/null mkdir tmp 2>/dev/null
cd resources cd resources
rm -rf firmware ipwndfu lib/* libimobiledevice* libirecovery rm -rf firmware ipwndfu lib/* libimobiledevice* libirecovery
@ -700,7 +700,7 @@ function InstallDependencies {
exit exit
} }
function Compile { Compile() {
git clone --depth 1 https://github.com/$1/$2.git git clone --depth 1 https://github.com/$1/$2.git
cd $2 cd $2
./autogen.sh --prefix="$(cd ../.. && pwd)/resources/$2" ./autogen.sh --prefix="$(cd ../.. && pwd)/resources/$2"
@ -709,7 +709,7 @@ function Compile {
sudo rm -rf $2 sudo rm -rf $2
} }
function SaveExternal { SaveExternal() {
ExternalURL="https://github.com/LukeZGD/$1.git" ExternalURL="https://github.com/LukeZGD/$1.git"
External=$1 External=$1
[[ $1 == "iOS-OTA-Downgrader-Keys" ]] && External="firmware" [[ $1 == "iOS-OTA-Downgrader-Keys" ]] && External="firmware"
@ -731,14 +731,14 @@ function SaveExternal {
cd .. cd ..
} }
function SaveFile { SaveFile() {
curl -L $1 -o $2 curl -L $1 -o $2
if [[ $(shasum $2 | awk '{print $1}') != $3 ]]; then if [[ $(shasum $2 | awk '{print $1}') != $3 ]]; then
Error "Verifying failed. Please run the script again" "./restore.sh Install" Error "Verifying failed. Please run the script again" "./restore.sh Install"
fi fi
} }
function SavePkg { SavePkg() {
if [[ ! -d ../saved/lib ]]; then if [[ ! -d ../saved/lib ]]; then
Log "Downloading packages..." Log "Downloading packages..."
SaveFile https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/depends2_linux.zip depends_linux.zip 38cf1db21c9aba88f0de95a1a7959ac2ac53c464 SaveFile https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/depends2_linux.zip depends_linux.zip 38cf1db21c9aba88f0de95a1a7959ac2ac53c464
@ -748,7 +748,7 @@ function SavePkg {
cp ../saved/lib/* . cp ../saved/lib/* .
} }
function BasebandDetect { BasebandDetect() {
Firmware=resources/firmware/$ProductType Firmware=resources/firmware/$ProductType
BasebandURL=$(cat $Firmware/13G37/url 2>/dev/null) # iOS 9.3.6 BasebandURL=$(cat $Firmware/13G37/url 2>/dev/null) # iOS 9.3.6
Baseband=0 Baseband=0