-
Notifications
You must be signed in to change notification settings - Fork 0
/
phitron-install.sh
42 lines (34 loc) · 1.39 KB
/
phitron-install.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
#!/bin/bash
# Retrieve the latest release information from GitHub's API
release=$(curl --silent "https://api.github.com/repos/Programming-Hero1/phitron-desktop-app/releases/latest")
# Extract the URL of the asset we want to download
URL=$(echo $release | grep -o '"browser_download_url": "[^"]*"' | sed 's/"browser_download_url": "\(.*\)"/\1/' | grep '\.exe$')
# Check if there are multiple .exe files in the release
if [ $(echo $release | grep -o '"browser_download_url": "[^"]*"' | sed 's/"browser_download_url": "\(.*\)"/\1/' | grep '\.exe$' | wc -l) -gt 1 ]; then
echo "Error: Found multiple .exe files in the release. Aborting."
exit 1
fi
# Check if there are no .exe files in the release
if [ $(echo $release | grep -o '"browser_download_url": "[^"]*"' | sed 's/"browser_download_url": "\(.*\)"/\1/' | grep '\.exe$' | wc -l) -eq 0 ]; then
echo "Error: No .exe files found in the release. Aborting."
exit 1
fi
# Download the asset with progress bar
FILENAME=$(basename $URL)
echo "Downloading $FILENAME..."
curl --progress-bar -L -o $FILENAME $URL
# Check if the download was successful
if [ $? -eq 0 ]; then
echo "File downloaded successfully."
else
echo "Failed to download file."
fi
# Install the downloaded file
echo "Installing $FILENAME..."
./$FILENAME
# Check if the installation was successful
if [ $? -eq 0 ]; then
echo "Installation successful."
else
echo "Installation failed."
fi