2021-05-29 13:26:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
SetToolPaths() {
|
2021-08-01 04:06:25 +02:00
|
|
|
MPath="./resources/libimobiledevice_"
|
2021-05-29 13:26:08 +02:00
|
|
|
if [[ $OSTYPE == "linux"* ]]; then
|
|
|
|
. /etc/os-release 2>/dev/null
|
|
|
|
platform="linux"
|
2021-06-07 07:49:58 +02:00
|
|
|
platformver="$PRETTY_NAME"
|
2021-07-12 16:36:51 +02:00
|
|
|
MPath+="$platform"
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2021-06-20 11:45:53 +02:00
|
|
|
bspatch="$(which bspatch)"
|
2021-06-01 09:21:37 +02:00
|
|
|
futurerestore1="sudo LD_PRELOAD=./resources/lib/libcurl.so.3 LD_LIBRARY_PATH=./resources/lib ./resources/tools/futurerestore1_linux"
|
|
|
|
futurerestore2="sudo LD_LIBRARY_PATH=./resources/lib ./resources/tools/futurerestore2_linux"
|
|
|
|
idevicerestore="sudo LD_LIBRARY_PATH=./resources/lib ./resources/tools/idevicerestore_linux"
|
2021-05-29 13:26:08 +02:00
|
|
|
python="$(which python2)"
|
|
|
|
ipwndfu="sudo $python ipwndfu"
|
|
|
|
rmsigchks="sudo $python rmsigchks.py"
|
2021-06-21 13:53:02 +02:00
|
|
|
SimpleHTTPServer="sudo -b $python -m SimpleHTTPServer 80"
|
2021-06-20 11:45:53 +02:00
|
|
|
|
2021-05-29 13:26:08 +02:00
|
|
|
elif [[ $OSTYPE == "darwin"* ]]; then
|
|
|
|
platform="macos"
|
2021-06-07 07:49:58 +02:00
|
|
|
platformver="${1:-$(sw_vers -productVersion)}"
|
2021-07-12 16:36:51 +02:00
|
|
|
MPath+="$platform"
|
|
|
|
if [[ -e /usr/local/bin/idevicedate && -e /usr/local/bin/irecovery ]]; then
|
|
|
|
Log "Detected libimobiledevice and libirecovery installed from Homebrew (Intel Mac)"
|
|
|
|
MPath="/usr/local/bin"
|
|
|
|
elif [[ -e /opt/homebrew/bin/idevicedate && -e /opt/homebrew/bin/irecovery ]]; then
|
|
|
|
Log "Detected libimobiledevice and libirecovery installed from Homebrew (Apple Silicon)"
|
|
|
|
MPath="/opt/homebrew/bin"
|
|
|
|
fi
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2021-06-20 11:45:53 +02:00
|
|
|
bspatch="/usr/bin/bspatch"
|
2021-05-29 13:26:08 +02:00
|
|
|
futurerestore1="./resources/tools/futurerestore1_macos"
|
|
|
|
futurerestore2="./resources/tools/futurerestore2_macos"
|
|
|
|
idevicerestore="./resources/tools/idevicerestore_macos"
|
|
|
|
ipwnder32="./resources/tools/ipwnder32_macos"
|
|
|
|
python="/usr/bin/python"
|
|
|
|
ipwndfu="$python ipwndfu"
|
|
|
|
rmsigchks="$python rmsigchks.py"
|
|
|
|
SimpleHTTPServer="$python -m SimpleHTTPServer 80"
|
|
|
|
fi
|
|
|
|
git="$(which git)"
|
2021-07-12 16:36:51 +02:00
|
|
|
ideviceenterrecovery="$MPath/ideviceenterrecovery"
|
|
|
|
ideviceinfo="$MPath/ideviceinfo"
|
|
|
|
iproxy="$MPath/iproxy"
|
2021-06-05 13:53:56 +02:00
|
|
|
ipsw="./tools/ipsw_$platform"
|
2021-07-12 16:36:51 +02:00
|
|
|
irecoverychk="$MPath/irecovery"
|
2021-05-29 13:26:08 +02:00
|
|
|
irecovery="$irecoverychk"
|
2021-06-07 07:49:58 +02:00
|
|
|
[[ $platform == "linux" ]] && irecovery="sudo LD_LIBRARY_PATH=./resources/lib $irecovery"
|
2021-06-01 09:21:37 +02:00
|
|
|
partialzip="./resources/tools/partialzip_$platform"
|
2021-05-29 13:26:08 +02:00
|
|
|
SSH="-F ./resources/ssh_config"
|
|
|
|
SCP="$(which scp) $SSH"
|
|
|
|
SSH="$(which ssh) $SSH"
|
2021-05-30 05:03:39 +02:00
|
|
|
tsschecker="./resources/tools/tsschecker_$platform"
|
2021-05-29 13:26:08 +02:00
|
|
|
|
2021-06-07 07:49:58 +02:00
|
|
|
Log "Running on platform: $platform ($platformver)"
|
2021-05-29 13:26:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SaveExternal() {
|
2021-06-08 05:04:40 +02:00
|
|
|
local ExternalURL="https://github.com/LukeZGD/$1.git"
|
|
|
|
local External=$1
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ $1 == "iOS-OTA-Downgrader-Keys" ]] && External="firmware"
|
|
|
|
cd resources
|
|
|
|
if [[ ! -d $External || ! -d $External/.git ]]; then
|
|
|
|
Log "Downloading $External..."
|
|
|
|
rm -rf $External
|
|
|
|
$git clone $ExternalURL $External
|
|
|
|
fi
|
|
|
|
if [[ ! -e $External/README.md || ! -d $External/.git ]]; then
|
|
|
|
rm -rf $External
|
|
|
|
Error "Downloading/updating $1 failed. Please run the script again"
|
|
|
|
fi
|
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveFile() {
|
|
|
|
curl -L $1 -o $2
|
|
|
|
if [[ $(shasum $2 | awk '{print $1}') != $3 ]]; then
|
|
|
|
Error "Verifying failed. Please run the script again" "./restore.sh Install"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
SavePkg() {
|
|
|
|
if [[ ! -d ../saved/lib ]]; then
|
|
|
|
Log "Downloading packages..."
|
|
|
|
SaveFile https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/depends2_linux.zip depends_linux.zip 38cf1db21c9aba88f0de95a1a7959ac2ac53c464
|
|
|
|
mkdir -p ../saved/lib
|
|
|
|
unzip depends_linux.zip -d ../saved/lib
|
|
|
|
fi
|
|
|
|
cp ../saved/lib/* .
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
InstallDepends() {
|
|
|
|
local libimobiledevice
|
|
|
|
|
|
|
|
mkdir resources/lib tmp 2>/dev/null
|
|
|
|
cd resources
|
|
|
|
rm -rf firmware ipwndfu lib/*
|
|
|
|
cd ../tmp
|
|
|
|
|
|
|
|
Log "Installing dependencies..."
|
2021-08-20 03:58:17 +02:00
|
|
|
if [[ $platform == "linux" ]]; then
|
|
|
|
Echo "* iOS-OTA-Downgrader will be installing dependencies from your distribution's package manager"
|
|
|
|
Echo "* Enter root password of your PC when prompted"
|
|
|
|
Input "Press Enter/Return to continue (or press Ctrl+C to cancel)"
|
|
|
|
read -s
|
|
|
|
fi
|
2021-08-26 13:41:52 +02:00
|
|
|
if [[ $ID == "arch" || $ID_LIKE == "arch" || $ID == "artix" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
sudo pacman -Syu --noconfirm --needed base-devel bsdiff curl libcurl-compat libpng12 libimobiledevice libzip openssh openssl-1.0 python2 unzip usbutils
|
|
|
|
ln -sf /usr/lib/libcurl.so.3 ../resources/lib/libcurl.so.3
|
|
|
|
ln -sf /usr/lib/libzip.so.5 ../resources/lib/libzip.so.4
|
|
|
|
|
2021-06-07 07:49:58 +02:00
|
|
|
elif [[ ! -z $UBUNTU_CODENAME && $VERSION_ID == "2"* ]] ||
|
2021-07-26 11:23:57 +02:00
|
|
|
[[ $VERSION == "11 (bullseye)" || $PRETTY_NAME == "Debian"*"sid" ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
[[ ! -z $UBUNTU_CODENAME ]] && sudo add-apt-repository -y universe
|
|
|
|
sudo apt update
|
2021-07-26 11:23:57 +02:00
|
|
|
sudo apt install -y bsdiff curl git libimobiledevice6 openssh-client python2 unzip usbmuxd usbutils
|
2021-05-29 13:26:08 +02:00
|
|
|
SavePkg
|
|
|
|
cp libcrypto.so.1.0.0 libcurl.so.3 libpng12.so.0 libssl.so.1.0.0 ../resources/lib
|
2021-07-26 11:23:57 +02:00
|
|
|
if [[ $VERSION_ID == "20"* ]]; then
|
2021-05-29 13:26:08 +02:00
|
|
|
cp libzip.so.4 ../resources/lib
|
2021-07-26 11:23:57 +02:00
|
|
|
else
|
|
|
|
sudo apt install -y libzip4
|
2021-05-29 13:26:08 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
elif [[ $ID == "fedora" ]] && (( $VERSION_ID >= 33 )); then
|
|
|
|
sudo dnf install -y bsdiff git libimobiledevice libpng12 libzip perl-Digest-SHA python2
|
|
|
|
SavePkg
|
|
|
|
cp libcrypto.so.1.0.0 libssl.so.1.0.0 ../resources/lib
|
|
|
|
ln -sf /usr/lib64/libzip.so.5 ../resources/lib/libzip.so.4
|
|
|
|
ln -sf /usr/lib64/libbz2.so.1.* ../resources/lib/libbz2.so.1.0
|
|
|
|
|
2021-06-07 07:49:58 +02:00
|
|
|
elif [[ $ID == "opensuse-tumbleweed" || $PRETTY_NAME == "openSUSE Leap 15.3" ]]; then
|
|
|
|
if [[ $ID == "opensuse-tumbleweed" ]]; then
|
|
|
|
libimobiledevice="libimobiledevice-1_0-6"
|
|
|
|
else
|
|
|
|
libimobiledevice="libimobiledevice6"
|
|
|
|
ln -sf /lib64/libreadline.so.7 ../resources/lib/libreadline.so.8
|
|
|
|
fi
|
|
|
|
sudo zypper -n in bsdiff curl git $libimobiledevice libpng12-0 libopenssl1_0_0 libzip5 python-base
|
2021-05-29 13:26:08 +02:00
|
|
|
ln -sf /usr/lib64/libzip.so.5 ../resources/lib/libzip.so.4
|
|
|
|
|
|
|
|
elif [[ $platform == "macos" ]]; then
|
|
|
|
xcode-select --install
|
|
|
|
libimobiledevice=("https://github.com/libimobiledevice-win32/imobiledevice-net/releases/download/v1.3.14/libimobiledevice.1.2.1-r1116-osx-x64.zip" "328e809dea350ae68fb644225bbf8469c0f0634b")
|
2021-07-12 16:36:51 +02:00
|
|
|
Echo "* iOS-OTA-Downgrader provides a copy of libimobiledevice and libirecovery by default"
|
|
|
|
Echo "* In case that problems occur, try installing them from Homebrew"
|
|
|
|
Echo "* The script will detect this automatically and will use the Homebrew versions of the tools"
|
|
|
|
Echo "* Install using this command: 'brew install libimobiledevice libirecovery'"
|
2021-05-29 13:26:08 +02:00
|
|
|
|
|
|
|
else
|
|
|
|
Error "Distro not detected/supported by the install script." "See the repo README for supported OS versions/distros"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $platform == "linux" ]]; then
|
|
|
|
libimobiledevice=("https://github.com/LukeZGD/iOS-OTA-Downgrader-Keys/releases/download/tools/libimobiledevice_linux.zip" "4344b3ca95d7433d5a49dcacc840d47770ba34c4")
|
|
|
|
fi
|
|
|
|
|
2021-07-31 10:58:19 +02:00
|
|
|
if [[ ! -d ../resources/libimobiledevice_$platform && $MPath == "./resources"* ]]; then
|
2021-07-12 16:36:51 +02:00
|
|
|
Log "Downloading libimobiledevice..."
|
2021-05-29 13:26:08 +02:00
|
|
|
SaveFile ${libimobiledevice[0]} libimobiledevice.zip ${libimobiledevice[1]}
|
|
|
|
mkdir ../resources/libimobiledevice_$platform
|
2021-07-12 16:36:51 +02:00
|
|
|
Log "Extracting libimobiledevice..."
|
|
|
|
unzip -q libimobiledevice.zip -d ../resources/libimobiledevice_$platform
|
2021-05-29 13:26:08 +02:00
|
|
|
chmod +x ../resources/libimobiledevice_$platform/*
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
Log "Install script done! Please run the script again to proceed"
|
2021-05-30 05:03:39 +02:00
|
|
|
exit 0
|
2021-05-29 13:26:08 +02:00
|
|
|
}
|