-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Wysb 32Toaster.sh
97 lines (79 loc) · 2.62 KB
/
Wysb 32Toaster.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
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
#!/bin/bash
# Function to display program information
function show_info {
echo "Program Name: Wysb 32Toaster"
echo "Creator: Wesley Yan Soares Brehmer"
echo "All rights reserved."
}
# Function to check system architecture
function check_architecture {
local arch
arch=$(uname -m)
if [[ "$arch" == "x86_64" ]]; then
echo "64-bits"
elif [[ "$arch" == "i386" ]] || [[ "$arch" == "i686" ]]; then
echo "32-bits"
else
echo "Unknown architecture"
fi
}
# Function to download files
function download_file {
local url=$1
local dest=$2
echo "Downloading file from $url..."
curl -L -o "$dest" "$url"
}
# Function to validate user input
function validate_input {
local input=$1
local prompt=$2
local valid_options=$3
while true; do
read -rp "$prompt" input
if [[ "$valid_options" == *"$input"* ]]; then
echo "$input"
break
else
echo "Invalid input. Please try again."
fi
done
}
# Display program information
show_info
# Ask user for their system type
system_type=$(validate_input "" "What is your system type (Linux or macOS)? " "Linux macOS")
# Ask user for system architecture
arch=$(validate_input "" "What is your system architecture (32-bits or 64-bits)? " "32-bits 64-bits")
if [[ "$arch" == "64-bits" ]]; then
echo "You don't need to use this program. Please proceed to https://github.com/simplyYan/Wysb?tab=readme-ov-file#-how-to-install"
exit 0
fi
# Ask user if they agree with the license
read -rp "Do you agree with the license? (Read at https://github.com/simplyYan/Wysb/blob/main/LICENSE) (y/n) " agree
if [[ "$agree" != "y" && "$agree" != "Y" ]]; then
echo "You must agree to the license to continue. Program terminated."
exit 1
fi
# Determine download URL based on the system
if [[ "$system_type" == "macOS" ]]; then
file_url="https://github.com/simplyYan/Wysb/raw/main/dist%20(binary)/wysbc_macos32"
elif [[ "$system_type" == "Linux" ]]; then
file_url="https://github.com/simplyYan/Wysb/raw/main/dist%20(binary)/wysbc_linux32"
fi
# Download the file
temp_file="wysbc_temp_download"
download_file "$file_url" "$temp_file"
# Ask user for installation directory
while true; do
read -rp "Which directory would you like to install the program in? (Make sure the directory exists) " install_dir
if [[ -d "$install_dir" ]]; then
break
else
echo "The specified directory does not exist. Please try again."
fi
done
# Move the file to the installation directory
mv "$temp_file" "$install_dir"
echo "Thank you for downloading Wysb 32Toaster!"
exit 0