-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·68 lines (59 loc) · 1.52 KB
/
setup.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
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "This script is designed for macOS."
exit 1
fi
if [ "$EUID" -ne 0 ]; then
echo "This script must be run as root. Type your password to continue..."
sudo "$0" "$@"
exit
fi
echo "Updating system..."
softwareupdate --install --all
echo "Starting setup..."
SCRIPTS_DIR="./scripts"
FAILED_SCRIPTS=()
run_script() {
local script="$1"
local require_sudo="$2"
if [[ "$require_sudo" == "no" ]]; then
echo "Running $script as $SUDO_USER..."
if su - "$SUDO_USER" -c "bash $(pwd)/$script"; then
echo "$script completed successfully."
else
echo "Error: $script failed!"
FAILED_SCRIPTS+=("$script")
fi
else
echo "Running $script as root..."
if bash "$script"; then
echo "$script completed successfully."
else
echo "Error: $script failed!"
FAILED_SCRIPTS+=("$script")
fi
fi
}
SCRIPTS=(
"homebrew-setup.sh:yes"
"app-installer.sh:yes"
"zsh-setup.sh:yes"
"dev-tools.sh:no"
"starship-setup.sh:no"
"alacritty-setup.sh:no"
"dock.sh:no"
)
for script_entry in "${SCRIPTS[@]}"; do
IFS=":" read -r script require_sudo <<< "$script_entry"
run_script "$SCRIPTS_DIR/$script" "$require_sudo"
done
if [ ${#FAILED_SCRIPTS[@]} -ne 0 ]; then
echo "The following scripts failed:"
for script in "${FAILED_SCRIPTS[@]}"; do
echo "- $script"
done
echo "Please check the logs for more details."
else
echo "Setup complete! Restarting your machine in 10 seconds, press CTRL+C to cancel..."
sleep 10 && reboot
fi