-
Notifications
You must be signed in to change notification settings - Fork 8
/
omegabrr_upgrade.sh
executable file
·40 lines (29 loc) · 1.14 KB
/
omegabrr_upgrade.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
#!/usr/bin/env bash
# Define service name as a variable
service_name="omegabrr@bakerboy448"
# Function to handle errors and exit
handle_error() {
echo "Error: $1" >&2
exit 1
}
# Get the old version of omegabrr
old_version=$(omegabrr version)
# Fetch the URL of the latest release for linux_x86_64
dlurl=$(curl -s https://api.github.com/repos/autobrr/omegabrr/releases/latest |
grep -E 'browser_download_url.*linux_x86_64' | cut -d\" -f4)
# Validate the download URL
if [ -z "$dlurl" ]; then
handle_error "Failed to fetch download URL."
fi
# Download the latest release
wget "$dlurl" -O omegabrr_latest.tar.gz || handle_error "Failed to download the latest version."
# Extract the downloaded archive
sudo tar -xzf omegabrr_latest.tar.gz -C /usr/bin/ || handle_error "Failed to extract files."
# Clean up downloaded files
rm omegabrr_latest.tar.gz
# Display old and new versions
new_version=$(omegabrr version)
echo "Omegabrr updated from $old_version to $new_version"
# Restart the specified service
sudo systemctl restart $service_name || handle_error "Failed to restart the service $service_name."
echo "Update and restart successful!"