-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupScript.sh
More file actions
executable file
·144 lines (118 loc) · 4.13 KB
/
setupScript.sh
File metadata and controls
executable file
·144 lines (118 loc) · 4.13 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/zsh
check_and_install() {
local package_number="$1"
local package="$2"
local install_command="$3"
local version_command="$4"
if ! command -v "$package" &>/dev/null; then
echo
echo "\033[1m❌ Error: $package is not installed.\033[0m"
echo "To install $package, run the following command:"
echo "$install_command"
echo
exit 4
else
echo "[$package_number] ✅ $package is installed: $(eval $version_command)"
fi
}
download_repo() {
echo "⏳ Downloading the repository..."
if curl -L -o main.zip https://github.com/simitka/adbUnityProfiler/archive/refs/heads/main.zip; then
echo "⏳ Download successful. Unpacking the archive..."
if [[ -s main.zip ]]; then
unzip main.zip -d .
rm main.zip
mv adbUnityProfiler-main/* ./
rm -rf adbUnityProfiler-main
if [[ -f setupScript.sh ]]; then
echo "⏳ Removing setupScript.sh..."
rm setupScript.sh
fi
else
echo "❌ Error: The downloaded file is empty."
exit 5
fi
else
echo "❌ Error: Failed to download the repository."
exit 6
fi
echo "✅ Repository downloaded and unpacked successfully."
}
move_to_actual_path() {
if [[ ! -d "$actual_path" ]]; then
echo "⏳ Folder '$actual_path' does not exist. Creating it..."
mkdir -p "$actual_path" || {
echo "❌ Error: Failed to create folder '$actual_path'."
exit 7
}
else
echo "⏳ Folder '$actual_path' exists. Moving to it..."
fi
setopt nullglob
for item in * .[^.]*; do
[[ "$item" == "." || "$item" == ".." ]] && continue
if ! mv -- "$item" "$actual_path"/; then
echo "❌ Error: Failed to move '$item' to '$actual_path'."
exit 8
else
echo "✅ Moved: '$item' → '$actual_path/'"
fi
done
unsetopt nullglob
echo "✅ All files have been moved to '$actual_path'."
current_dir=$(pwd)
cd "$actual_path" ||
{
echo "❌ Error: Failed to change directory to '$actual_path'."
exit 9
}
rmdir "$current_dir" || {
echo "❌ Error: Failed to remove folder: '$current_dir'."
exit 10
}
}
rm /usr/local/bin/adbreadprofile
download_repo
source ./utils.sh
clear
echo
echo "\033[1m\033[4m$repository_name\033[0m\033[1m – A CLI tool to read Profile contents in the Unity application on Android\033[0m"
echo "any questions about how the script works – https://simitka.io"
echo
echo "⏳ Launching the setup assistant."
echo "⏳ Checking if all necessary packages are installed..."
echo "============================================================"
check_and_install "1" "brew" "/bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" "brew --version"
check_and_install "2" "jq" "brew install jq" "jq --version"
check_and_install "3" "adb" "brew install android-platform-tools" "adb --version"
echo "============================================================"
echo
echo "\033[1m📝 Enter the path to the folder where $repository_name will be installed:\033[0m"
echo "(or leave it blank and press Enter↵ to set to $default_path)"
read -r user_path
if [[ -z "$user_path" ]]; then
actual_path="$default_path"
else
actual_path="$user_path"
fi
move_to_actual_path
cat <<EOL >$config_file
actualPath:$actual_path
appBundleName:null
EOL
echo
echo
echo "\033[1m⏳ Creating the console command '$command_to_run' to run $repository_name\033[0m"
echo "(📝 enter the password from your MacOS user. The password is not displayed when you enter it)"
if [[ ! -d "/usr/local/bin" ]]; then
echo "⏳ The '/usr/local/bin' folder does not exist. Creating it..."
sudo mkdir -p /usr/local/bin
fi
temp_script="$HOME/${repository_name}_temp"
echo '#!/bin/zsh' >"$temp_script"
echo "cd $actual_path && ./start.sh" >>"$temp_script"
sudo mv "$temp_script" /usr/local/bin/$command_to_run
sudo chmod +x /usr/local/bin/$command_to_run
chmod +x start.sh
clear
$command_to_run