Handling of multiple sessions

This commit is contained in:
LukeZGD 2024-08-06 10:38:15 +08:00
parent a1df9f0c66
commit 623cfb8283
2 changed files with 19 additions and 13 deletions

2
.gitignore vendored
View File

@ -20,6 +20,6 @@ resources/powdersn0w/
resources/ramdisk/ resources/ramdisk/
saved/ saved/
sudoloop sudoloop
tmp/ tmp*/
version.xml version.xml
*.DS_Store *.DS_Store

View File

@ -36,20 +36,23 @@ pause() {
clean() { clean() {
kill $httpserver_pid $iproxy_pid $anisette_pid 2>/dev/null kill $httpserver_pid $iproxy_pid $anisette_pid 2>/dev/null
popd &>/dev/null popd &>/dev/null
rm -rf "$(dirname "$0")/tmp/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp/" 2>/dev/null rm -rf "$(dirname "$0")/tmp$$/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp$$/" 2>/dev/null
if [[ $platform == "macos" ]]; then if [[ $platform == "macos" && $(ls "$(dirname "$0")" | grep -v tmp$$ | grep -c tmp) == 0 ]]; then
killall -CONT AMPDevicesAgent AMPDeviceDiscoveryAgent MobileDeviceUpdater killall -CONT AMPDevicesAgent AMPDeviceDiscoveryAgent MobileDeviceUpdater
fi fi
} }
clean_sudo() { clean_sudo() {
clean clean
sudo rm -rf /tmp/futurerestore /tmp/*.json "$(dirname "$0")/tmp/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp/" sudo rm -rf /tmp/futurerestore /tmp/*.json "$(dirname "$0")/tmp$$/"* "$(dirname "$0")/iP"*/ "$(dirname "$0")/tmp$$/"
sudo kill $sudoloop_pid sudo kill $sudoloop_pid
} }
clean_usbmuxd() { clean_usbmuxd() {
clean_sudo clean_sudo
if [[ $(ls "$(dirname "$0")" | grep -v tmp$$ | grep -c tmp) != 0 ]]; then
return
fi
sudo killall usbmuxd 2>/dev/null sudo killall usbmuxd 2>/dev/null
if [[ $(command -v systemctl 2>/dev/null) ]]; then if [[ $(command -v systemctl 2>/dev/null) ]]; then
sleep 1 sleep 1
@ -228,13 +231,15 @@ set_tool_paths() {
"* Download the \"linux_$platform_arch\" or \"complete\" version to continue (or do a git clone)" "* Download the \"linux_$platform_arch\" or \"complete\" version to continue (or do a git clone)"
fi fi
if [[ -z $device_disable_usbmuxd ]]; then if [[ -z $device_disable_usbmuxd ]]; then
trap "clean_usbmuxd" EXIT
fi
if [[ -z $device_disable_usbmuxd && $othertmp == 0 ]]; then
if [[ $(command -v systemctl 2>/dev/null) ]]; then if [[ $(command -v systemctl 2>/dev/null) ]]; then
sudo systemctl stop usbmuxd sudo systemctl stop usbmuxd
fi fi
#sudo killall usbmuxd 2>/dev/null #sudo killall usbmuxd 2>/dev/null
#sleep 1 #sleep 1
sudo -b $dir/usbmuxd -pf 2>/dev/null sudo -b $dir/usbmuxd -pf 2>/dev/null
trap "clean_usbmuxd" EXIT
fi fi
fi fi
@ -399,7 +404,7 @@ install_depends() {
version_update_check() { version_update_check() {
log "Checking for updates..." log "Checking for updates..."
github_api=$(curl https://api.github.com/repos/LukeZGD/Legacy-iOS-Kit/releases/latest 2>/dev/null) github_api=$(curl https://api.github.com/repos/LukeZGD/Legacy-iOS-Kit/releases/latest 2>/dev/null)
pushd "$(dirname "$0")/tmp" >/dev/null pushd "$(dirname "$0")/tmp$$" >/dev/null
version_latest=$(echo "$github_api" | $jq -r '.assets[] | select(.name|test("complete")) | .name' | cut -c 25- | cut -c -9) version_latest=$(echo "$github_api" | $jq -r '.assets[] | select(.name|test("complete")) | .name' | cut -c 25- | cut -c -9)
git_hash_latest=$(echo "$github_api" | $jq -r '.assets[] | select(.name|test("git-hash")) | .name' | cut -c 21- | cut -c -7) git_hash_latest=$(echo "$github_api" | $jq -r '.assets[] | select(.name|test("git-hash")) | .name' | cut -c 21- | cut -c -7)
popd >/dev/null popd >/dev/null
@ -426,7 +431,7 @@ version_update() {
else else
req=".assets[] | select (.name|test(\"${platform}\")) | .browser_download_url" req=".assets[] | select (.name|test(\"${platform}\")) | .browser_download_url"
fi fi
pushd "$(dirname "$0")/tmp" >/dev/null pushd "$(dirname "$0")/tmp$$" >/dev/null
url="$(echo "$github_api" | $jq -r "$req")" url="$(echo "$github_api" | $jq -r "$req")"
log "Downloading: $url" log "Downloading: $url"
curl -L $url -o latest.zip curl -L $url -o latest.zip
@ -435,14 +440,14 @@ version_update() {
fi fi
popd >/dev/null popd >/dev/null
log "Updating..." log "Updating..."
cp resources/firstrun tmp 2>/dev/null cp resources/firstrun tmp$$ 2>/dev/null
rm -r bin/ LICENSE README.md restore.sh rm -r bin/ LICENSE README.md restore.sh
if [[ $device_sudoloop == 1 ]]; then if [[ $device_sudoloop == 1 ]]; then
sudo rm -rf resources/ sudo rm -rf resources/
fi fi
rm -r resources/ 2>/dev/null rm -r resources/ 2>/dev/null
unzip -q tmp/latest.zip -d . unzip -q tmp$$/latest.zip -d .
cp tmp/firstrun resources 2>/dev/null cp tmp$$/firstrun resources 2>/dev/null
log "Done! Please run the script again" log "Done! Please run the script again"
exit exit
} }
@ -2459,7 +2464,7 @@ ipsw_prepare_jailbreak() {
JBFiles[2]=$jelbrek/greenpois0n/${device_type}_${device_target_build}.tar JBFiles[2]=$jelbrek/greenpois0n/${device_type}_${device_target_build}.tar
fi fi
;; ;;
3.0* | 3.1 | 3.1.[12] ) JBFiles[0]="$jelbrek/fstab_old.tar";; 3.0* | 3.1 | 3.1.[12] ) :;;
* ) JBFiles[2]=$jelbrek/${JBFiles[2]};; * ) JBFiles[2]=$jelbrek/${JBFiles[2]};;
esac esac
case $device_target_vers in case $device_target_vers in
@ -8521,8 +8526,9 @@ trap "clean" EXIT
trap "exit 1" INT TERM trap "exit 1" INT TERM
clean clean
mkdir "$(dirname "$0")/tmp" othertmp=$(ls "$(dirname "$0")" | grep -c tmp)
pushd "$(dirname "$0")/tmp" >/dev/null mkdir "$(dirname "$0")/tmp$$"
pushd "$(dirname "$0")/tmp$$" >/dev/null
if [[ $no_color != 1 ]]; then if [[ $no_color != 1 ]]; then
TERM=xterm-256color # fix colors for msys2 terminal TERM=xterm-256color # fix colors for msys2 terminal