├── LICENSE
├── README.md
├── macscript.sh
└── version.txt
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Mac
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 |
General script for installing palera1n/checkra1n and bootstrapping with Procursus on macOS systems.
4 |
5 | This product is hereby licensed under the MIT license. It can be viewed [here](https://github.com/itsmaclol/macscript/blob/main/LICENSE).
6 |
7 | Backups are recommended, continue at your own risk.
8 |
9 | ## Installation
10 |
11 | jq is REQUIRED for macscript to work correctly, so install it via `brew install jq` or `apt install jq`
12 |
13 | Just run the following in your terminal:
14 |
15 | `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/itsmaclol/macscript/main/macscript.sh)"`
16 |
17 |
18 | macscript-gui is not the best version of macscript and highly unstable, use macscript-cli for better performance.
19 |
20 | macn1x (bootable Linux distro for macscript) is coming soon.
21 |
22 | Check out the [Discord](https://dsc.gg/macscript)
23 | and the [GUI](https://github.com/itsmaclol/macscript-gui)
24 |
25 | # Usage
26 |
27 | Use the flag `--remove-procursus` to uninstall the procursus bootstrap on your mac
28 |
29 | ## Features
30 | Easy installation of palera1n/odysseyra1n/checkra1n (macOS and Linux).
31 |
32 | Installation of the Procursus bootstrap on macOS (Big Sur and above).
33 |
34 | [SSHRD_Script](https://github.com/verygenericname/sshrd_script) (macOS and Linux).
35 |
36 | [seprmvr64](https://github.com/mineek/seprmvr64) support coming soon, (maybe)
37 |
38 | # Using the script locally
39 |
40 | ```
41 | git clone https://github.com/itsmaclol/macscript.git
42 | cd macscript
43 | chmod +x ./macscript.sh
44 | ./macscript.sh
45 | ```
46 |
47 | ## Credits
48 | genesis. for the fix for Procursus on macOS and for the iOS palera1n installation part.
49 |
50 | Nara for helping me with some bash code and the GUI.
51 |
52 | May, for helping make the README.md *pretty*.
53 |
54 | Alexia, for helping me with some bash.
55 |
56 | Me, for.. you know, basically everything.
57 |
58 | Made with <3 by Mac
59 |
--------------------------------------------------------------------------------
/macscript.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | os=$(uname)
3 | arch=$(uname -m)
4 | local_dir="/usr/local/bin"
5 | RED='\033[0;31m'
6 | YELLOW='\033[0;33m'
7 | DARK_GRAY='\033[90m'
8 | LIGHT_CYAN='\033[0;96m'
9 | NO_COLOR='\033[0m'
10 | github_version_url="https://raw.githubusercontent.com/itsmaclol/macscript/main/version.txt"
11 | local_version_file="./version.txt"
12 |
13 |
14 | error() {
15 | echo -e " - [${DARK_GRAY}$(date +'%m/%d/%y %H:%M:%S')${NO_COLOR}] ${RED}${NO_COLOR}: ${RED}$1${NO_COLOR}"
16 | }
17 |
18 | info() {
19 | echo -e " - [${DARK_GRAY}$(date +'%m/%d/%y %H:%M:%S')${NO_COLOR}] ${LIGHT_CYAN}${NO_COLOR}: ${LIGHT_CYAN}$1${NO_COLOR}"
20 | }
21 |
22 | warning() {
23 | echo -e " - [${DARK_GRAY}$(date +'%m/%d/%y %H:%M:%S')${NO_COLOR}] ${YELLOW}${NO_COLOR}: ${YELLOW}$1${NO_COLOR}"
24 | }
25 |
26 | if [ "$(id -u)" -ne 0 ]; then error "This script will not run without root or sudo." >&2; exit 1; fi
27 | get_package_manager() {
28 | if command -v apt-get >/dev/null 2>&1; then
29 | PACKAGE_MANAGER="apt-get"
30 | elif command -v yum >/dev/null 2>&1; then
31 | PACKAGE_MANAGER="yum"
32 | elif command -v dnf >/dev/null 2>&1; then
33 | PACKAGE_MANAGER="dnf"
34 | elif command -v pacman >/dev/null 2>&1; then
35 | PACKAGE_MANAGER="pacman"
36 | elif command -v apk >/dev/null 2>&1; then
37 | PACKAGE_MANAGER="apk"
38 | elif command -v zypper >/dev/null 2>&1; then
39 | PACKAGE_MANAGER="zypper"
40 | else
41 | PACKAGE_MANAGER="Unknown"
42 | fi
43 | }
44 |
45 | case $os in
46 | Darwin )
47 | macos_version=$(sw_vers -productVersion)
48 | macos_version_major=${macos_version%%.*}
49 | if [ "$(uname -r | cut -d. -f1)" -gt "15" ]; then
50 | os_name="macOS"
51 | elif [ "$(uname -m | head -c2)" = "iP" ]; then
52 | error "This script is not meant to be used on an iDevice. Please use a PC to use this script."
53 | exit 1
54 | else
55 | os_name="Mac OS X"
56 | fi
57 | ;;
58 | Linux)
59 | if grep -qi Microsoft /proc/version > /dev/null 2>&1; then
60 | error "You are running WSL, This script does not support WSL."
61 | exit 1
62 | fi
63 | os_name="Linux"
64 | get_package_manager
65 | ;;
66 | esac
67 |
68 | dependencies() {
69 | dependencies=("jq" "curl" "unzip" "git")
70 | missing_dependencies=()
71 |
72 | for dep in "${dependencies[@]}"; do
73 | if ! command -v "$dep" > /dev/null; then
74 | missing_dependencies+=("$dep")
75 | fi
76 | done
77 |
78 | if [[ ${#missing_dependencies[@]} -gt 0 ]]; then
79 | info "Dependencies are missing, would you like to install them?"
80 | read -r -p "y/n: " install_deps
81 | case $install_deps in
82 | y|Y|Yes|YES|yes )
83 | if [[ "$os" == "Darwin" && -x "$(command -v brew)" ]]; then
84 | # Install the missing dependencies using brew
85 | sudo -u "$SUDO_USER" brew install "${missing_dependencies[@]}"
86 | info "Dependencies installed, please rerun this script."
87 | exit 1
88 | elif [[ "$os" == "Linux" ]]; then
89 | case $PACKAGE_MANAGER in
90 | "pacman" )
91 | # Install dependencies using pacman
92 | sudo pacman -Syu "${missing_dependencies[@]}" --noconfirm
93 | ;;
94 | "apt-get" )
95 | # apt
96 | sudo apt-get update
97 | sudo apt-get install "${missing_dependencies[@]}" -y
98 | ;;
99 | "yum"|"dnf" )
100 | # yum/dnf, same thing tbh
101 | sudo dnf update
102 | sudo dnf install "${missing_dependencies[@]}" -y
103 | ;;
104 | "apk" )
105 | # apk for alpine
106 | sudo apk update
107 | sudo apk add "${missing_dependencies[@]}"
108 | ;;
109 | "zypper" )
110 | # and zypper for openSUSE
111 | sudo zypper refresh
112 | sudo zypper --non-interactive install "${missing_dependencies[@]}"
113 | ;;
114 | esac
115 | info "Dependencies installed, please rerun this script."
116 | exit 1
117 | else
118 | error "Unsupported operating system. You need to install ${missing_dependencies[*]} manually."
119 | exit 1
120 | fi
121 | ;;
122 | * )
123 | error "${missing_dependencies[*]} is/are needed for the script to work as intended."
124 | exit 1
125 | ;;
126 | esac
127 | fi
128 | case $os in
129 | Darwin )
130 | output=$(sudo -u "$SUDO_USER" brew list -1 | grep "libusbmuxd")
131 | if [ -z "$output" ]; then
132 | sudo -u "$SUDO_USER" brew install libusbmuxd
133 | fi
134 | ;;
135 | Linux )
136 | output=$(dpkg -l | grep libusbmuxd-tools)
137 | if [ -z "$output" ]; then
138 | case $PACKAGE_MANAGER in
139 | "pacman" )
140 | # Install dependencies using pacman
141 | sudo pacman -Syu libusbmuxd-tools --noconfirm
142 | ;;
143 | "apt-get" )
144 | # apt
145 | sudo apt-get update
146 | sudo apt-get install libusbmuxd-tools -y
147 | ;;
148 | "yum"|"dnf" )
149 | # yum/dnf, same thing tbh
150 | sudo dnf update
151 | sudo dnf install libusbmuxd-tools -y
152 | ;;
153 | "apk" )
154 | # apk for alpine
155 | sudo apk update
156 | sudo apk add libusbmuxd-tools
157 | ;;
158 | "zypper" )
159 | # and zypper for openSUSE
160 | sudo zypper refresh
161 | sudo zypper --non-interactive install libusbmuxd-tools
162 | ;;
163 | esac
164 | fi
165 | ;;
166 | esac
167 | }
168 |
169 | internet_check() {
170 | ping -c 1 -W 1 google.com > /dev/null 2>&1
171 |
172 | if [ $? -eq 0 ]; then
173 | echo "" > /dev/null
174 | else
175 | error "You do not seem to have an internet connection, please connect to the internet and try again, or if you are completely sure that you have internet, use the --ignore-internet-check flag."
176 | exit 1
177 | fi
178 | }
179 |
180 |
181 |
182 | local_version=$(cat $local_version_file)
183 | github_version=$(curl -s $github_version_url)
184 |
185 | if [[ $github_version > $local_version ]]; then
186 | version() {
187 | echo "Local version: $local_version"
188 | echo "GitHub version: $github_version"
189 | read -r -p "A new version is available. Do you want to update? (y/n): " version_choice
190 | }
191 | version
192 |
193 | case $version_choice in
194 | y|Y|YES|Yes|yes )
195 | info "Updating..."
196 | git pull
197 | ;;
198 | n|N|NO|No|no )
199 | echo "" > /dev/null
200 | ;;
201 | * )
202 | error "Invalid Choice."
203 | clear
204 | version
205 | ;;
206 | esac
207 |
208 | else
209 | echo "" > /dev/null
210 | fi
211 |
212 | help_menu() {
213 | cat << EOF
214 | Usage: $0 [Options]
215 | macscript
216 |
217 | Options:
218 | --help Prints this help
219 | --ignore-internet-check Ignores the internet check at the beginning of the script. Use this if you are 100% sure that you have internet.
220 | --ignore-dependencies Ignores the dependency check at the beginning of the script. Use this if you are 100% sure that you have the dependencies installed.
221 | --ignore-all-checks Ignores both the internet and dependency check at the beginning of the script. Use this if you are 100% sure that you have the dependencies installed and have internet.
222 | --ignore-recovery-download Ignores the macOS recovery download menu, in case you are just trying to make an efi without the macOS installer.
223 |
224 | EOF
225 | exit 1
226 | }
227 |
228 | case $1 in
229 | --remove-procursus )
230 | info "Uninstalling procursus bootstrap..."
231 | sudo rm -rf /opt/procursus
232 | info "Done!"
233 | exit 1
234 | ;;
235 | "" )
236 | dependencies
237 | internet_check
238 | ;;
239 | "--ignore-internet-check" )
240 | dependencies
241 | ;;
242 | "--ignore-dependencies-check" )
243 | internet_check
244 | ;;
245 | "--ignore-all-checks" )
246 | echo "" > /dev/null
247 | ;;
248 | "--help" | "-h" | "--h" )
249 | help_menu
250 | ;;
251 | * )
252 | error "Unknown arg $1"
253 | ;;
254 | esac
255 |
256 | arch_url_check() {
257 | case $os in
258 | Linux )
259 | case $arch in
260 | x86_64 )
261 | procursus_bootstrap_url="https://apt.procurs.us/bootstraps/big_sur/bootstrap-darwin-amd64.tar.zst"
262 | checkra1n_url="https://assets.checkra.in/downloads/linux/cli/x86_64/dac9968939ea6e6bfbdedeb41d7e2579c4711dc2c5083f91dced66ca397dc51d/checkra1n"
263 | ;;
264 | arm )
265 | checkra1n_url="https://assets.checkra.in/downloads/linux/cli/arm/ff05dfb32834c03b88346509aec5ca9916db98de3019adf4201a2a6efe31e9f5/checkra1n"
266 | ;;
267 | arm64 )
268 | procursus_bootstrap_url="https://apt.procurs.us/bootstraps/big_sur/bootstrap-darwin-arm64.tar.zst"
269 | checkra1n_url="https://assets.checkra.in/downloads/linux/cli/arm64/43019a573ab1c866fe88edb1f2dd5bb38b0caf135533ee0d6e3ed720256b89d0/checkra1n"
270 | ;;
271 | i486 )
272 | checkra1n_url="https://assets.checkra.in/downloads/linux/cli/i486/77779d897bf06021824de50f08497a76878c6d9e35db7a9c82545506ceae217e/checkra1n"
273 | esac
274 | palera1n_recovery_url=$(curl -s 'https://api.github.com/repos/palera1n/palera1n/releases' | jq --arg uname "$(uname -m)" -r '.[0].assets[] | select(.name == "palera1n-linux-\($uname)") | .browser_download_url')
275 | ;;
276 | Darwin )
277 | palera1n_recovery_url=$(curl -s 'https://api.github.com/repos/palera1n/palera1n/releases' | jq -r '.[0].assets[] | select(.name == "palera1n-macos-universal") | .browser_download_url')
278 | ;;
279 | esac
280 | }
281 |
282 |
283 | checkra1n() {
284 | arch_url_check
285 | case $os in
286 | Linux )
287 | info "Detected $os_name on $arch"
288 | info "Downloading checkra1n for $os_name on $arch"
289 | curl -sL "$checkra1n_url" -o "$local_dir/checkra1n"
290 | info "Checkra1n is successfully downloaded, Running..."
291 | sudo chmod +x "$local_dir"/checkra1n
292 | warning "In this next screen, you have to enable Untested iOS versions if you're on iOS 14.5 and newer. If not, you can safely ignore this."
293 | sleep 3
294 | "$local_dir"/checkra1n
295 | rm -rf "$local_dir"/checkra1n
296 | ;;
297 |
298 | Darwin )
299 | info "Detected $os_name on $arch"
300 | info "Downloading checkra1n for $os_name on $arch"
301 | sudo curl -s -L https://assets.checkra.in/downloads/macos/754bb6ec4747b2e700f01307315da8c9c32c8b5816d0fe1e91d1bdfc298fe07b/checkra1n%20beta%200.12.4.dmg -o /usr/local/bin/checkra1n.dmg
302 | info "Checkra1n is successfully downloaded, Running..."
303 | sudo hdiutil attach /usr/local/bin/checkra1n.dmg
304 | warning "In this next screen, you have to enable Untested iOS versions if you're on iOS 14.5 and newer. If not, you can safely ignore this."
305 | sleep 3
306 | case $macos_version_major in
307 | 11|12 )
308 | sudo /Volumes/checkra1n\ beta\ 0.12.4\ 1/checkra1n.app/Contents/MacOS/checkra1n -V -t
309 | ;;
310 | * )
311 | sudo /Volumes/checkra1n\ beta\ 0.12.4/checkra1n.app/Contents/MacOS/checkra1n -V -t
312 | ;;
313 | esac
314 | case $macos_version_major in
315 | 11|12 )
316 | sudo hdiutil detach /Volumes/checkra1n\ beta\ 0.12.4\ 1/
317 | ;;
318 | * )
319 | sudo hdiutil detach /Volumes/checkra1n\ beta\ 0.12.4\
320 | ;;
321 | esac
322 | rm -rf /usr/local/bin/checkra1n.dmg
323 | esac
324 | }
325 |
326 | odysseyra1n() {
327 | warning "For odysseyra1n to work, you have to be jailbroken via checkra1n, and to not have opened the checkra1n app after jailbreak, if you have done so, restore rootFS and try again."
328 | warning "Exit this script now via Ctrl + C if you need to jailbreak with checkra1n, if you have done so and followed the instructions above, you can ignore this message"
329 | sleep 10
330 | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/coolstar/Odyssey-bootstrap/master/procursus-deploy-linux-macos.sh)"
331 | }
332 |
333 | sshrd() {
334 | arch_url_check
335 | info "Detected $os_name on $arch"
336 | git clone https://github.com/verygenericname/SSHRD_Script --recursive && cd SSHRD_Script
337 | sudo chmod +x ./sshrd.sh
338 | info "The device will now be placed in recovery mode, and the palera1n DFU Helper will be launched to put the device in DFU mode."
339 | curl -L "$palera1n_recovery_url" -o ~/Documents/palera1n-dfu
340 | chmod +x ~/Documents/palera1n-dfu
341 | ~/Documents/palera1n-dfu -D
342 | case $os in
343 | Linux )
344 | warning "You will not be able to make a ramdisk for 16.1+, please use something lower instead, like 16.0"
345 | ;;
346 | esac
347 | read -r -p "What iOS version is the device currently running?" ios_version_sshrd
348 | ./sshrd.sh "$ios_version_sshrd"
349 | ./sshrd.sh boot
350 | sleep 10
351 | ./sshrd.sh ssh
352 | cd ..
353 | rm -rf SSHRD_Script ~/Documents/palera1n-dfu
354 | }
355 |
356 | apt-procursus() {
357 | arch_url_check
358 | info "Bootstrapping procursus and installing apt..."
359 | case $os in
360 | Darwin )
361 | info "Detected $os_name on $arch"
362 | cd "$HOME"
363 | # Download the bootstrap
364 | curl -Ls "$procursus_bootstrap_url" -o bootstrap.tar.zst
365 | curl -LsO https://cameronkatri.com/zstd
366 | chmod +x zstd
367 | ./zstd -d bootstrap.tar.zst > /dev/null 2>&1
368 | sudo tar -xpkf bootstrap.tar -C / > /dev/null 2>&1
369 | sudo mv zstd /opt/procursus/bin/zstd
370 | printf 'export PATH="/opt/procursus/bin:/opt/procursus/sbin:/opt/procursus/games:$PATH"\nexport CPATH="$CPATH:/opt/procursus/include"\nexport LIBRARY_PATH="$LIBRARY_PATH:/opt/procursus/lib"\n' | sudo tee -a /etc/zshenv /etc/profile
371 | export PATH="/opt/procursus/bin:/opt/procursus/sbin:/opt/procursus/games:$PATH"
372 | export CPATH="$CPATH:/opt/procursus/include"
373 | export LIBRARY_PATH="$LIBRARY_PATH:/opt/procursus/lib"
374 | echo >> ~/.zprofile #this fix for apt on macos was taken from azaz, thank you!
375 | echo PATH="/opt/procursus/bin:/opt/procursus/sbin:/opt/procursus/games:$PATH" >> ~/.zprofile
376 | echo CPATH="$CPATH:/opt/procursus/include" >> ~/.zprofile
377 | echo PATH="/opt/procursus/bin:/opt/procursus/sbin:/opt/procursus/games:$PATH" >> ~/.zprofile
378 | echo CPATH="$CPATH:/opt/procursus/include" >> ~/.zprofile
379 | echo LIBRARY_PATH="$LIBRARY_PATH:/opt/procursus/lib" >> ~/.zprofile
380 | echo export PATH >> ~/.zprofile
381 | echo export CPATH >> ~/.zprofile
382 | echo export LIBRARY_PATH >> ~/.zprofile
383 | source ~/.zprofile
384 | #update and install sileo
385 | sudo apt update
386 | sudo apt full-upgrade -y --allow-downgrades
387 | sudo apt install sileo -y
388 | rm bootstrap.tar.zst bootstrap.tar
389 | info "Installation Complete! Be sure to restart your terminal!"
390 | ;;
391 | * )
392 | error "Not supported."
393 | exit 1
394 | ;;
395 | esac
396 | }
397 |
398 | palera1n() {
399 | case $os in
400 | Linux )
401 | latest_build=$(curl -s "https://api.github.com/repos/palera1n/palera1n/tags" | jq -r '.[].name' | grep -E "v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+(\.[0-9]+)*$" | sort -V | tail -n 1)
402 | REPO_URL="https://api.github.com/repos/palera1n/palera1n/releases"
403 | BIN_URL=$(curl -s 'https://api.github.com/repos/palera1n/palera1n/releases' | jq --arg uname "$(uname -m)" -r '.[0].assets[] | select(.name == "palera1n-linux-\($uname)") | .browser_download_url')
404 | LOCK_FILE="$HOME/macscript_palera1n.lock"
405 | palera1n_get() {
406 | info "Detected $os_name on $arch"
407 | info "Downloading palera1n version ${latest_build} for $os_name on $arch"
408 | sudo curl -L "$BIN_URL" -o /usr/bin/palera1n
409 | sudo chmod +x /usr/bin/palera1n
410 | }
411 | # Grab the release from Github
412 | fetch_latest_version() {
413 | latest_version=$(curl -s $REPO_URL | grep -o '"tag_name": ".*"' | cut -d'"' -f4)
414 | info "$latest_version"
415 | }
416 |
417 | #Put the release name in the lock file
418 | update_lock_file() {
419 | latest_version=$1
420 | echo "$latest_version" > "$LOCK_FILE"
421 | info "Lock file updated with version $latest_version"
422 | }
423 |
424 | #Read the release name from the lock file
425 | current_version=$(cat "$LOCK_FILE" 2>/dev/null)
426 |
427 | #Get the release file
428 | latest_version=$(fetch_latest_version)
429 |
430 |
431 | if [[ -z "$current_version" ]]; then
432 | update_lock_file "$latest_version"
433 | palera1n_get
434 | elif [[ "$current_version" != "$latest_version" ]]; then
435 | info "New palera1n version avaliable, Downloading..."
436 | update_lock_file "$latest_version"
437 | palera1n_get
438 | else
439 | info "palera1n is up to date."
440 | fi
441 | palera1n_main_menu
442 | ;;
443 | Darwin )
444 | latest_build=$(curl -s "https://api.github.com/repos/palera1n/palera1n/tags" | jq -r '.[].name' | grep -E "v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+(\.[0-9]+)*$" | sort -V | tail -n 1)
445 | REPO_URL="https://api.github.com/repos/palera1n/palera1n/releases"
446 | LOCK_FILE="$HOME/macscript_palera1n.lock"
447 | BIN_URL=$(curl -s 'https://api.github.com/repos/palera1n/palera1n/releases' | jq -r '.[0].assets[] | select(.name == "palera1n-macos-universal") | .browser_download_url')
448 | palera1n_get() {
449 | info "Downloading palera1n version ${latest_build} for $os_name on $arch"
450 | sudo curl -L -s "$BIN_URL" -o /usr/local/bin/palera1n
451 | sudo chmod +x /usr/local/bin/palera1n
452 | }
453 |
454 | # Grab the release from github
455 | fetch_latest_version() {
456 | latest_version=$(curl -s $REPO_URL | grep -o '"tag_name": ".*"' | cut -d'"' -f4)
457 | echo "$latest_version"
458 | }
459 |
460 | # Update lock file with version
461 | update_lock_file() {
462 | latest_version=$1
463 | echo "$latest_version" > "$LOCK_FILE"
464 | info "Lock file updated with version $latest_version"
465 | }
466 |
467 | # Read the current version from the lock file
468 | current_version=$(cat "$LOCK_FILE" 2>/dev/null)
469 |
470 | latest_version=$(fetch_latest_version)
471 |
472 | # Compare versions and update if needed.
473 | if [[ -z "$current_version" ]]; then
474 | update_lock_file "$latest_version"
475 | palera1n_get
476 | elif [[ "$current_version" != "$latest_version" ]]; then
477 | info "New palera1n update available!, downloading..."
478 | update_lock_file "$latest_version"
479 | palera1n_get
480 | else
481 | info "palera1n is up to date."
482 | fi
483 | palera1n_main_menu
484 | ;;
485 | esac
486 | }
487 |
488 | palera1n_check() {
489 | case $os in
490 | Darwin )
491 | "$local_dir"/palera1n "$@"
492 | ;;
493 | Linux )
494 | /usr/bin/palera1n "$@"
495 | ;;
496 | esac
497 | }
498 |
499 | submenu_rootful() {
500 | echo "┌───┬────────────────────────────────┐"
501 | printf "│ %-2s│ %-30s │\n" "1" "Setup FakeFS"
502 | printf "│ %-2s│ %-30s │\n" "2" "Setup BindFS"
503 | printf "| %-2s| %-30s |\n" "3" "Clean FakeFS"
504 | printf "│ %-2s│ %-30s │\n" "4" "Boot"
505 | printf "│ %-2s│ %-30s │\n" "5" "Enter Recovery Mode"
506 | printf "│ %-2s│ %-30s │\n" "6" "Exit Recovery Mode"
507 | printf "│ %-2s│ %-30s │\n" "7" "Safe Mode"
508 | printf "│ %-2s│ %-30s │\n" "8" "Restore RootFS"
509 | printf "│ %-2s│ %-30s │\n" "9" "DFU Helper"
510 | printf "│ %-2s│ %-30s │\n" "10" "Back"
511 | printf "│ %-2s│ %-30s │\n" "11" "Exit"
512 | echo "└───┴────────────────────────────────┘"
513 | read -r -p "Enter the number of the option you want to select: " selection
514 | case $selection in
515 | 1 )
516 | palera1n_check -c -f -V
517 | ;;
518 | 2 )
519 | palera1n_check -f -V -B
520 | ;;
521 | 3 )
522 | palera1n_check -f -V -C
523 | ;;
524 | 4 )
525 | palera1n_check -f -V
526 | ;;
527 | 5 )
528 | palera1n_check -E
529 | ;;
530 | 6 )
531 | palera1n_check -n
532 | ;;
533 | 7 )
534 | palera1n_check -s -V -f
535 | ;;
536 | 8 )
537 | palera1n_check --force-revert -f -V
538 | ;;
539 | 9 )
540 | palera1n_check -D -f -V
541 | ;;
542 | 10 )
543 | palera1n_main_menu
544 | ;;
545 | 11 )
546 | exit 1
547 | ;;
548 | * )
549 | error "Invalid Selection $selection"
550 | submenu_rootful
551 | ;;
552 | esac
553 | }
554 |
555 | submenu_rootless() {
556 | echo "┌───┬────────────────────────────────┐"
557 | printf "│ %-2s│ %-30s │\n" "1" "Boot"
558 | printf "│ %-2s│ %-30s │\n" "2" "Enter Recovery Mode"
559 | printf "│ %-2s│ %-30s │\n" "3" "Exit Recovery Mode"
560 | printf "│ %-2s│ %-30s │\n" "4" "DFU Helper"
561 | printf "│ %-2s│ %-30s │\n" "5" "Restore RootFS"
562 | printf "│ %-2s│ %-30s │\n" "6" "Back"
563 | printf "│ %-2s│ %-30s │\n" "7" "Exit"
564 | echo "└───┴────────────────────────────────┘"
565 | read -r -p "Enter the number of the option you want to select: " selection
566 | case $selection in
567 | 1)
568 | palera1n_check -l -V
569 | ;;
570 | 2)
571 | palera1n_check -E
572 | ;;
573 | 3)
574 | palera1n_check -n
575 | ;;
576 | 4)
577 | palera1n_check -D -l -V
578 | ;;
579 | 5)
580 | palera1n_check --force-revert -V
581 | ;;
582 | 6)
583 | palera1n_main_menu
584 | ;;
585 | 7)
586 | exit 1
587 | ;;
588 | *)
589 | error "Invalid selection $selection"
590 | ;;
591 | esac
592 | }
593 |
594 | palera1n_main_menu() {
595 | echo "Welcome to the palera1n submenu!"
596 | echo "┌───┬────────────────────────────────┐"
597 | printf "│ %-2s│ %-30s │\n" "1" "Rootful"
598 | printf "│ %-2s│ %-30s │\n" "2" "Rootless (Recommended)"
599 | printf "│ %-2s│ %-30s │\n" "3" "Back"
600 | printf "│ %-2s│ %-30s │\n" "4" "Exit"
601 | echo "└───┴────────────────────────────────┘"
602 | read -r -p "Enter the number of what you want to do: " selection
603 | case $selection in
604 | 1)
605 | submenu_rootful
606 | ;;
607 | 2)
608 | submenu_rootless
609 | ;;
610 | 3)
611 | main_menu
612 | ;;
613 | 4)
614 | exit
615 | ;;
616 | *)
617 | error "Invalid selection $selection"
618 | palera1n_main_menu
619 | ;;
620 | esac
621 | }
622 |
623 |
624 | main_menu() {
625 | echo "Welcome to macscript!"
626 | echo "┌───┬────────────────────────────────┐"
627 | printf "│ %-2s│ %-30s │\n" "1" "Install checkra1n"
628 | printf "│ %-2s│ %-30s │\n" "2" "Run the odysseyra1n Script"
629 | printf "│ %-2s│ %-30s │\n" "3" "Install palera1n"
630 | case $os in
631 | Darwin )
632 | case $macos_version_major in
633 | 11|12|13|14 )
634 | printf "│ %-2s│ %-30s │\n" "4" "Install Procursus (macOS only)"
635 | printf "│ %-2s│ %-30s │\n" "5" "SSHRD Script"
636 | printf "│ %-2s│ %-30s │\n" "6" "Exit"
637 | ;;
638 | * )
639 | printf "│ %-2s│ %-30s │\n" "4" "SSHRD Script"
640 | printf "│ %-2s│ %-30s │\n" "5" "Exit"
641 | ;;
642 | esac
643 | ;;
644 | Linux )
645 | printf "│ %-2s│ %-30s │\n" "4" "SSHRD Script"
646 | printf "│ %-2s│ %-30s │\n" "5" "Exit"
647 | ;;
648 | esac
649 | echo "└───┴────────────────────────────────┘"
650 |
651 | read -r -p "Enter the number of what you want to do: " selection
652 |
653 | case $selection in
654 | 1)
655 | checkra1n
656 | ;;
657 | 2)
658 | odysseyra1n
659 | ;;
660 | 3)
661 | palera1n
662 | ;;
663 | 4)
664 | case $os in
665 | Darwin )
666 | case $macos_version_major in
667 | 11|12|13|14 )
668 | apt-procursus
669 | ;;
670 | * )
671 | error "Not supported."
672 | exit 1
673 | esac
674 | ;;
675 | Linux )
676 | error "Not Supported."
677 | exit 1
678 | ;;
679 | esac
680 | ;;
681 | 5)
682 | sshrd
683 | ;;
684 | 6)
685 | echo "Exiting..."
686 | exit
687 | ;;
688 | *)
689 | echo "Invalid selection"
690 | ;;
691 | esac
692 | }
693 | main_menu
694 |
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | 1.0
2 |
--------------------------------------------------------------------------------