-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherase-install-invokation-tool.sh
executable file
·56 lines (49 loc) · 1.6 KB
/
erase-install-invokation-tool.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# example: sudo ./erase-install-invokation-tool.sh --version=14.4.1 --erase
ERASE_INSTALL_PATH="/Library/Management/erase-install/erase-install.sh"
# Check if erase-install.sh exists
if [ ! -f "$ERASE_INSTALL_PATH" ]; then
echo "Error: erase-install.sh not found at $ERASE_INSTALL_PATH"
echo "Please run erase-installer-fetcher.sh first and install the downloaded pkg manually."
exit 1
fi
# Check if running with sudo
if [ "$EUID" -ne 0 ]; then
echo "Error: This script must be run with sudo privileges"
echo "Please run: sudo $0 $*"
exit 1
fi
# Function to display usage
show_usage() {
echo "Usage: sudo $0 [OPTION]"
echo "Options:"
echo " --list Show available macOS versions"
echo " --download Just download latest macOS installer"
echo " --reinstall Download and upgrade to newer macOS"
echo " --erase Erase and reinstall macOS (WARNING: Will wipe system!)"
echo " --version=XX.XX Download specific macOS version"
echo " --help Show this help message"
echo ""
echo "Example: sudo $0 --reinstall"
echo "Example: sudo $0 --version=14.4.1 --erase"
}
# Show usage if no arguments provided
if [ $# -eq 0 ]; then
show_usage
exit 1
fi
# Process arguments
case "$1" in
--help)
show_usage
;;
--list|--download|--reinstall|--erase|--version=*)
echo "Executing: sudo $ERASE_INSTALL_PATH $*"
sudo "$ERASE_INSTALL_PATH" "$@"
;;
*)
echo "Error: Unknown option $1"
show_usage
exit 1
;;
esac