Last active
October 11, 2023 14:33
-
-
Save jetfir3/826d5cdf7bf5b6d99417638e5302dbef to your computer and use it in GitHub Desktop.
SpotX-Bash Updater (Linux via APT/deb)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# The following script can run as a cron job to auto-update Spotify/SpotX-Bash | |
# Only "Debian-based" Linux distros using APT are supported | |
# Line #7 can be customized to set SpotX-Bash arguments | |
params="-h" | |
# Check for APT dependency and set default deb install location | |
command -v apt >/dev/null || { echo -e "Error: Debian-based Linux distro with APT support is required" >&2; exit 1; } | |
appDir="/usr/share/spotify" | |
# Check if Spotify is installed | |
if [ ! -f "${appDir}/spotify" ]; then | |
echo "Spotify not installed, exiting..." | |
exit 1 | |
fi | |
# Get currently installed client version | |
clientVer=$("${appDir}/spotify" --version | perl -nle'print $& if m{(?<=Spotify version ).*?(?=\.g[0-9a-f]{8})}') | |
# Get latest Linux Spotify version | |
repoVer=$(curl -sS http://repository.spotify.com/dists/testing/non-free/binary-amd64/Packages | perl -nle'print $& if m{(?<=Version: [0-9]:).*?(?=\.g[0-9a-f]{8})}') | |
# Get latest SpotX-Bash version | |
spotxBashVer=$(bash <(curl -sSL https://spotx-official.github.io/run.sh) --version | perl -nle'print $& if m{(?<=SpotX-Bash version ).*}') | |
# Compare versions | |
if [ "$(printf '%s\n' "${clientVer}" "${repoVer}" | sort -V | head -n1)" != "${repoVer}" ]; then | |
# If latest Linux version is higher, check SpotX-Bash version | |
if [ "$(printf '%s\n' "${repoVer}" "${spotxBashVer}" | sort -V | head -n1)" != "${spotxBashVer}" ]; then | |
# If SpotX-Bash version is higher or equal, update and patch Spotify with SpotX-Bash | |
bash <(curl -sSL https://spotx-official.github.io/run.sh) -P "${appDir}" --installdeb "${params}" | |
else | |
echo "Latest Spotify version not yet supported by SpotX-Bash, exiting..." | |
exit 1 | |
fi | |
else | |
echo "No new Spotify version detected, exiting..." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment