Browse and listen to thousands of radio stations across the globe right from your terminal ๐ ๐ป ๐ตโจ
radio
rust
tokio
web-radio
command-line-tool
tui
1#!/bin/bash
2
3readonly MAGENTA="$(tput setaf 5 2>/dev/null || echo '')"
4readonly GREEN="$(tput setaf 2 2>/dev/null || echo '')"
5readonly CYAN="$(tput setaf 6 2>/dev/null || echo '')"
6readonly NO_COLOR="$(tput sgr0 2>/dev/null || echo '')"
7
8# Define the release information
9RELEASE_URL="https://api.github.com/repos/tsirysndr/tunein-cli/releases/latest"
10
11# Determine the operating system
12OS=$(uname -s)
13if [ "$OS" = "Darwin" ]; then
14 # Determine the CPU architecture
15 ARCH=$(uname -m)
16 if [ "$ARCH" = "arm64" ]; then
17 ASSET_NAME="_aarch64-apple-darwin.tar.gz"
18 else
19 ASSET_NAME="_x86_64-apple-darwin.tar.gz"
20 fi
21elif [ "$OS" = "Linux" ]; then
22 # Determine the CPU architecture
23 ARCH=$(uname -m)
24 if [ "$ARCH" = "aarch64" ]; then
25 ASSET_NAME="_aarch64-unknown-linux-gnu.tar.gz"
26 elif [ "$ARCH" = "x86_64" ]; then
27 ASSET_NAME="_x86_64-unknown-linux-gnu.tar.gz"
28 else
29 echo "Unsupported architecture: $ARCH"
30 exit 1
31 fi
32else
33 echo "Unsupported operating system: $OS"
34 exit 1
35fi
36
37# Retrieve the download URL for the desired asset
38DOWNLOAD_URL=$(curl -sSL $RELEASE_URL | grep -o "browser_download_url.*$ASSET_NAME\"" | cut -d ' ' -f 2)
39
40ASSET_NAME=$(basename $DOWNLOAD_URL)
41
42# Define the installation directory
43INSTALL_DIR="/usr/local/bin"
44
45DOWNLOAD_URL=`echo $DOWNLOAD_URL | tr -d '\"'`
46
47# Download the asset
48curl -SL $DOWNLOAD_URL -o /tmp/$ASSET_NAME
49
50# Extract the asset
51tar -xzf /tmp/$ASSET_NAME -C /tmp
52
53# Set the correct permissions for the binary
54chmod +x /tmp/tunein
55
56# Move the extracted binary to the installation directory
57# use sudo if OS is Linux
58if [ "$OS" = "Linux" ]; then
59 if command -v sudo >/dev/null 2>&1; then
60 sudo mv /tmp/tunein $INSTALL_DIR
61 else
62 mv /tmp/tunein $INSTALL_DIR
63 fi
64else
65 mv /tmp/tunein $INSTALL_DIR
66fi
67
68# Clean up temporary files
69rm /tmp/$ASSET_NAME
70
71cat << EOF
72${CYAN}
73 ______ ____ _______ ____
74 /_ __/_ _____ ___ / _/__ / ___/ / / _/
75 / / / // / _ \\/ -_)/ // _ \\ / /__/ /___/ /
76 /_/ \\_,_/_//_/\\__/___/_//_/ \\___/____/___/
77
78${NO_COLOR}
79Browse and listen to thousands of radio stations across the globe right from your terminal ๐ ๐ป ๐ตโจ
80
81${GREEN}https://github.com/tsirysndr/tunein${NO_COLOR}
82
83Please file an issue if you encounter any problems!
84
85===============================================================================
86
87Installation completed! ๐
88
89EOF