mirror of
https://github.com/SpotX-Official/SpotX-Bash.git
synced 2026-12-07 06:12:46 +11:00
Harden Spotify installs and preserve backups on failure
This commit is contained in:
3 files changed
+154
-127
No files matched your search
@@ -25,7 +25,7 @@
|
||||
- Hide audiobooks, episodes & podcasts on home screen
|
||||
- Block automatic updates (macOS)
|
||||
- Install latest desktop client versions on macOS 13+ and APT-based Linux distros
|
||||
- Supports all Linux distros and OS X/macOS 10.11+
|
||||
- Supports the x86_64 Spotify client on Linux and compatible clients on OS X/macOS 10.11+
|
||||
- Older macOS releases require a compatible Spotify client installed manually; see the [version timeline](https://github.com/SpotX-Official/SpotX-Bash/wiki/Spotify-Desktop-Client-Version-Timeline).
|
||||
|
||||
### Usage:
|
||||
@@ -34,7 +34,15 @@
|
||||
> Recommended order: **install Spotify, run SpotX-Bash, then open Spotify/sign in.**
|
||||
> Repatch before opening an updated client. [Already opened Spotify?](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#how-do-i-use-it)
|
||||
|
||||
- Run the following command in terminal:
|
||||
Choose the command for your Spotify installation.
|
||||
|
||||
| Installation | How to run SpotX-Bash |
|
||||
| --- | --- |
|
||||
| macOS app, native Linux package, or Flatpak | Use the main script below. |
|
||||
| Snap | Use `bash spotx-snap.sh` from the cloned repo. See [Snap / Nix](#snap--nix). |
|
||||
| Nix on x86_64 Linux or Apple Silicon macOS | Follow the [SpotX-Nix instructions](https://github.com/SpotX-Official/SpotX-Nix). |
|
||||
|
||||
- Run the main script in your terminal:
|
||||
```
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh)
|
||||
```
|
||||
@@ -64,6 +72,7 @@ git clone https://github.com/SpotX-Official/SpotX-Bash.git
|
||||
cd SpotX-Bash
|
||||
bash spotx-snap.sh
|
||||
```
|
||||
The locally installed Snap stops receiving automatic Store updates. Run `bash spotx-snap.sh --download` to fetch and apply a fresh Store build, or `bash spotx-snap.sh --restore` to return to the official stable channel and automatic updates.
|
||||
Run `bash spotx-snap.sh --help` for additional Snap options or see the [FAQ](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#is-the-snap-version-of-spotify-supported).
|
||||
|
||||
Nix users on x86_64 Linux or Apple Silicon macOS should use [SpotX-Nix](https://github.com/SpotX-Official/SpotX-Nix), which applies SpotX-Bash while building the Spotify package without modifying the Nix store. It supports NixOS, nix-darwin, Home Manager, and configurations with or without flakes. Intel macOS users should continue using regular SpotX-Bash.
|
||||
@@ -86,10 +95,10 @@ Nix users on x86_64 Linux or Apple Silicon macOS should use [SpotX-Nix](https://
|
||||
| `--installmac` | install latest supported client [macOS] |
|
||||
| `-l` | [set lyrics background color to black](https://github.com/SpotX-Official/SpotX-Bash/issues/20#issuecomment-1762040019) |
|
||||
| `--nocolor` | remove colors from SpotX-Bash output |
|
||||
| `--noninteractive` | disable interactive prompts for automation |
|
||||
| `-o` | use [old home screen UI](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#what-is-the-old-and-new-ui) |
|
||||
| `-p` | [paid premium-tier subscriber](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#can-spotx-bash-be-used-with-a-paid-premium-account) |
|
||||
| `-P <path>` | set path to client |
|
||||
| `--noninteractive` | skip prompts and exit with an error if required sudo authorization is unavailable |
|
||||
| `-o` | use [old home screen UI](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#what-is-the-old-ui-option) on Spotify 1.1.93.896 through 1.2.13.661 |
|
||||
| `-p` | [paid premium-tier subscriber](https://github.com/SpotX-Official/SpotX-Bash/wiki/SpotX%E2%80%90Bash-FAQ#can-i-use-spotx-bash-with-a-paid-premium-account) |
|
||||
| `-P <path>` | directory containing `Spotify.app` on macOS or `Apps/xpui.spa` on Linux |
|
||||
| `--rollback` | install previous supported client version [macOS] |
|
||||
| `-S` | skip [codesigning](https://github.com/SpotX-Official/SpotX-Bash/discussions/3) [macOS] |
|
||||
| `--stable` | use with '--installdeb' for stable branch [Linux] |
|
||||
@@ -102,9 +111,13 @@ Nix users on x86_64 Linux or Apple Silicon macOS should use [SpotX-Nix](https://
|
||||
```
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh) -cdh
|
||||
```
|
||||
**Run SpotX-Bash, enable interactive mode, set custom path to client**
|
||||
**Run interactively with an existing app in your user Applications folder (macOS)**
|
||||
```bash
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh) -i -P "$HOME/Applications"
|
||||
```
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh) -i -P $HOME/Downloads/
|
||||
**Run interactively with a client installed in `/opt/spotify` (Linux)**
|
||||
```bash
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh) -i -P /opt/spotify
|
||||
```
|
||||
**Run SpotX-Bash, set paid premium-tier subscriber**
|
||||
```
|
||||
@@ -114,10 +127,14 @@ bash <(curl -sSL https://spotx-official.github.io/run.sh) -p
|
||||
```
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh) --installdeb
|
||||
```
|
||||
Add `--stable` to install the stable build. APT installs required dependencies. Optional packages recommended by Spotify, such as multimedia codecs, can be installed separately.
|
||||
|
||||
**Run SpotX-Bash, block auto-updates, install latest supported client version (macOS)**
|
||||
```
|
||||
bash <(curl -sSL https://spotx-official.github.io/run.sh) -B --installmac
|
||||
```
|
||||
If your installed client is newer than the supported build, `--installmac` replaces it with the supported version.
|
||||
|
||||
**Install latest supported client version without interactive prompts (macOS)**
|
||||
```
|
||||
curl -sSL https://spotx-official.github.io/run.sh | bash -s -- --noninteractive --installmac
|
||||
|
||||
+48
-36
@@ -17,6 +17,7 @@ Helper options:
|
||||
--channel <channel> : select stable, candidate, beta, or edge with '--download'
|
||||
--download : download Spotify snap instead of using a local source
|
||||
--help : print this help message
|
||||
--noninteractive : require sudo authorization in advance and skip prompts
|
||||
--output-dir <path> : set output directory for '--build-only'
|
||||
--restore : restore official store-managed Spotify snap
|
||||
--snap-file <path> : use a specific local Spotify snap
|
||||
@@ -50,43 +51,46 @@ has_spotx_marker() {
|
||||
return 1
|
||||
}
|
||||
|
||||
fetch_snap_assertions() {
|
||||
local revision declaration snapId storeRev
|
||||
revision=$(LC_ALL=C timeout 20 snap known --remote snap-revision snap-sha3-384="$1") || return 1
|
||||
snapId=$(awk '$1 == "snap-id:" { print $2; exit }' <<< "${revision}")
|
||||
[[ -n "${snapId}" ]] || return 1
|
||||
declaration=$(LC_ALL=C timeout 20 snap known --remote snap-declaration series=16 snap-id="${snapId}") &&
|
||||
printf '%s\n\n%s\n' "${declaration}" "${revision}" > "${workDir}/remote.assert" &&
|
||||
"${sudoCmd[@]}" snap ack "${workDir}/remote.assert" >/dev/null 2>&1 && return 0
|
||||
storeRev=$(awk '$1 == "snap-revision:" { print $2; exit }' <<< "${revision}")
|
||||
[[ "${storeRev}" =~ ^[1-9][0-9]*$ ]] || return 1
|
||||
(cd "${workDir}" && snap download spotify --revision="${storeRev}" --basename=official >/dev/null) &&
|
||||
rm -f -- "${workDir}/official.snap" &&
|
||||
"${sudoCmd[@]}" snap ack "${workDir}/official.assert"
|
||||
}
|
||||
|
||||
verify_snap_source() {
|
||||
local snap="${1}" digest size assertion assertedDigest snapId assertedSize declaration declaredName candidate remoteAssertion
|
||||
digest=$("${sudoCmd[@]}" snap info --verbose "${snap}" 2>/dev/null | awk '$1 == "sha3-384:" { print $2; exit }')
|
||||
size=$("${sudoCmd[@]}" stat -c '%s' "${snap}")
|
||||
local snap="${1}" digest size assertion assertedDigest snapId assertedSize declaration declaredName candidate
|
||||
digest=$(LC_ALL=C "${sudoCmd[@]}" snap info --verbose "${snap}" 2>/dev/null | awk '$1 == "sha3-384:" { print $2 }') || return 1
|
||||
size=$("${sudoCmd[@]}" stat -c '%s' "${snap}") || return 1
|
||||
[[ -n "${digest}" ]] || return 1
|
||||
assertion=$(LC_ALL=C snap known snap-revision snap-sha3-384="${digest}" 2>/dev/null || true)
|
||||
assertion=$(LC_ALL=C snap known snap-revision snap-sha3-384="${digest}" 2>/dev/null) || assertion=''
|
||||
[[ -n "${assertion}" ]] || {
|
||||
for candidate in "$(dirname -- "${sourceSnap}")"/*.assert; do
|
||||
[[ -f "${candidate}" ]] || continue
|
||||
"${sudoCmd[@]}" grep -Fqx "snap-sha3-384: ${digest}" "${candidate}" 2>/dev/null || continue
|
||||
"${sudoCmd[@]}" snap ack "${candidate}" >/dev/null 2>&1 || continue
|
||||
assertion=$(LC_ALL=C snap known snap-revision snap-sha3-384="${digest}" 2>/dev/null || true)
|
||||
assertion=$(LC_ALL=C snap known snap-revision snap-sha3-384="${digest}" 2>/dev/null) || assertion=''
|
||||
[[ -n "${assertion}" ]] && break
|
||||
done
|
||||
}
|
||||
[[ -n "${assertion}" ]] || {
|
||||
remoteAssertion=$(LC_ALL=C timeout 20 snap known --remote snap-revision snap-sha3-384="${digest}" 2>/dev/null || true)
|
||||
[[ -n "${remoteAssertion}" ]] && {
|
||||
printf '%s\n' "${remoteAssertion}" > "${workDir}/snap-revision.assert"
|
||||
"${sudoCmd[@]}" snap ack "${workDir}/snap-revision.assert" >/dev/null 2>&1 || true
|
||||
assertion="${remoteAssertion}"
|
||||
}
|
||||
fetch_snap_assertions "${digest}" &&
|
||||
assertion=$(LC_ALL=C snap known snap-revision snap-sha3-384="${digest}") || return 1
|
||||
}
|
||||
[[ -n "${assertion}" ]] || return 1
|
||||
assertedDigest=$(awk '$1 == "snap-sha3-384:" { print $2; exit }' <<< "${assertion}")
|
||||
snapId=$(awk '$1 == "snap-id:" { print $2; exit }' <<< "${assertion}")
|
||||
assertedSize=$(awk '$1 == "snap-size:" { print $2; exit }' <<< "${assertion}")
|
||||
[[ "${assertedDigest}" == "${digest}" && -n "${snapId}" && "${assertedSize}" == "${size}" ]] || return 1
|
||||
declaration=$(LC_ALL=C snap known snap-declaration snap-id="${snapId}" 2>/dev/null || true)
|
||||
[[ -n "${declaration}" ]] || {
|
||||
remoteAssertion=$(LC_ALL=C timeout 20 snap known --remote snap-declaration snap-id="${snapId}" 2>/dev/null || true)
|
||||
[[ -n "${remoteAssertion}" ]] && {
|
||||
printf '%s\n' "${remoteAssertion}" > "${workDir}/snap-declaration.assert"
|
||||
"${sudoCmd[@]}" snap ack "${workDir}/snap-declaration.assert" >/dev/null 2>&1 || true
|
||||
declaration="${remoteAssertion}"
|
||||
}
|
||||
}
|
||||
declaration=$(LC_ALL=C snap known snap-declaration series=16 snap-id="${snapId}") || return 1
|
||||
declaredName=$(awk '$1 == "snap-name:" { print $2; exit }' <<< "${declaration}")
|
||||
[[ "${declaredName}" == "spotify" ]] || return 1
|
||||
sourceVerified='true'
|
||||
@@ -102,6 +106,7 @@ allowUnverified=''
|
||||
downloadSnap=''
|
||||
buildOnly=''
|
||||
restoreSnap=''
|
||||
nonInteractive=''
|
||||
channelSet=''
|
||||
outputSet=''
|
||||
outputDir="${PWD}"
|
||||
@@ -122,6 +127,7 @@ while (($#)); do
|
||||
;;
|
||||
--download) downloadSnap='true' ;;
|
||||
--help) show_help; exit 0 ;;
|
||||
--noninteractive) nonInteractive='true' ;;
|
||||
--output-dir)
|
||||
(($# > 1)) || error "'--output-dir' requires an argument."
|
||||
outputDir="${2}"
|
||||
@@ -165,32 +171,29 @@ done
|
||||
}
|
||||
[[ "${snapChannel}" =~ ^(stable|candidate|beta|edge)$ ]] || error "Invalid snap channel '${snapChannel}'."
|
||||
|
||||
scriptDir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
spotxScript="${scriptDir}/spotx.sh"
|
||||
[[ -f "${spotxScript}" ]] || error "spotx.sh not found beside spotx-snap.sh."
|
||||
command -v snap >/dev/null || error "snap command not found."
|
||||
snap version >/dev/null 2>&1 || error "snapd is not available."
|
||||
[[ "${restoreSnap}" ]] || {
|
||||
scriptDir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
spotxScript="${scriptDir}/spotx.sh"
|
||||
[[ -f "${spotxScript}" ]] || error "spotx.sh not found beside spotx-snap.sh."
|
||||
|
||||
for requirement in snap unsquashfs unzip zip perl awk grep sha256sum mktemp getent install stat timeout; do
|
||||
command -v "${requirement}" >/dev/null || error "${requirement} command not found."
|
||||
done
|
||||
|
||||
runUser="${SUDO_USER:-$(id -un)}"
|
||||
runUid=$(id -u "${runUser}")
|
||||
runGid=$(id -g "${runUser}")
|
||||
runHome=$(getent passwd "${runUser}" 2>/dev/null | awk -F: 'NR == 1 { print $6 }')
|
||||
[[ -n "${runHome}" ]] || runHome="${HOME}"
|
||||
cacheBase="${runHome}/.cache/spotx-bash"
|
||||
cacheDir="${cacheBase}/snap"
|
||||
for requirement in unsquashfs unzip zip perl awk grep sha256sum mktemp getent install stat timeout; do
|
||||
command -v "${requirement}" >/dev/null || error "${requirement} command not found."
|
||||
done
|
||||
}
|
||||
sudoCmd=()
|
||||
((EUID == 0)) || {
|
||||
command -v sudo >/dev/null || error "sudo command not found."
|
||||
sudo -n true >/dev/null 2>&1 || {
|
||||
[[ -z "${nonInteractive}" ]] || error "Authorize sudo before running with '--noninteractive'."
|
||||
echo -e "This script requires sudo permission to preserve and install snap files.\nPlease enter your sudo password..."
|
||||
sudo -v || error "Failed to obtain sudo permission."
|
||||
}
|
||||
sudoCmd=(sudo)
|
||||
[[ -z "${nonInteractive}" ]] || sudoCmd+=(-n)
|
||||
}
|
||||
|
||||
snap version >/dev/null 2>&1 || error "snapd is not available."
|
||||
[[ "${restoreSnap}" ]] && {
|
||||
LC_ALL=C snap list spotify >/dev/null 2>&1 || error "Spotify snap is not installed."
|
||||
command pkill -9 '[sS]potify' 2>/dev/null || true
|
||||
@@ -201,6 +204,15 @@ snap version >/dev/null 2>&1 || error "snapd is not available."
|
||||
exit 0
|
||||
}
|
||||
|
||||
runUser="${SUDO_USER:-$(id -un)}"
|
||||
runUid=$(id -u "${runUser}")
|
||||
runGid=$(id -g "${runUser}")
|
||||
runHome=$(getent passwd "${runUser}" 2>/dev/null | awk -F: 'NR == 1 { print $6 }')
|
||||
[[ -n "${runHome}" ]] || runHome="${HOME}"
|
||||
cacheBase="${runHome}/.cache/spotx-bash"
|
||||
cacheDir="${cacheBase}/snap"
|
||||
[[ -z "${nonInteractive}" ]] || spotxArgs+=(--noninteractive)
|
||||
|
||||
tempBase="${TMPDIR:-/tmp}"
|
||||
tempBase="${tempBase%/}"
|
||||
workDir=$(mktemp -d "${tempBase}/spotx-snap.XXXXXXXX")
|
||||
@@ -265,7 +277,7 @@ sourceVerified=''
|
||||
verify_snap_source "${sourceCopy}" && {
|
||||
echo -e "${green}Verified official Spotify snap${clr}\n"
|
||||
} || {
|
||||
[[ "${allowUnverified}" ]] || error "Selected snap could not be authenticated as an official Spotify snap.\nConnect to the internet, place its matching assertion beside it or use '--allow-unverified'."
|
||||
[[ "${allowUnverified}" ]] || error "Selected snap could not be authenticated as an official Spotify snap.\nUse '--download', place its matching assertion bundle beside it or use '--allow-unverified'."
|
||||
echo -e "${yellow}Warning:${clr} Selected snap could not be authenticated and will not be cached.\n"
|
||||
}
|
||||
"${sudoCmd[@]}" unsquashfs -d "${snapRoot}" "${sourceCopy}" >/dev/null
|
||||
|
||||
@@ -23,7 +23,7 @@ esac
|
||||
runtime_state_init() {
|
||||
unset macRecoveryDir macRecoveryTarget macRecoveryReady macRecoveryIdentity macRecoveryOriginal \
|
||||
macRecoveryCommitted macRecoveryFingerprint macRecoveryCandidateIdentity macWriteProbe \
|
||||
macInstallTemp macInstallTarget macInstallSource macDownloadPath workDir copyTempDir spaTempDir xpuiTempCreated \
|
||||
macInstallTemp macInstallTarget macInstallSource workDir copyTempDir spaTempDir xpuiTempCreated \
|
||||
targetAppPath targetAppBinary targetAppBak targetXpuiPath targetXpuiSpa targetXpuiBak \
|
||||
protectedInstall stagedInstall cleanAB detectedClientVer backupBuild backupCreated clientLockPaths clientLockTargets
|
||||
runtimePid=$$
|
||||
@@ -48,7 +48,7 @@ show_help() {
|
||||
--installmac : install latest supported client version [macOS]
|
||||
-l, --lyricsbg : set lyrics background color to black
|
||||
--nocolor : remove colors from SpotX-Bash output
|
||||
--noninteractive : disable interactive prompts
|
||||
--noninteractive : skip prompts (authorize required sudo access in advance)
|
||||
-o, --oldui : use old home screen UI
|
||||
-p, --premium : paid premium-tier subscriber
|
||||
-P <path> : set path to client
|
||||
@@ -216,7 +216,9 @@ macos_set_version() {
|
||||
macos_legacy_notice() {
|
||||
local reason="${1}"
|
||||
[[ "${reason}" == "toohigh" ]] && { echo -e "\n${red}Error:${clr} v${clientVer} not supported on macOS ${macOSVer} (max: ${legacyMaxVer}).\nInstall a compatible Spotify version manually, then re-run SpotX-Bash.\n" >&2; exit 1; }
|
||||
echo -e "\n${yellow}Warning:${clr} Automatic Spotify installation is unavailable on macOS ${macOSVer}.\nInstall a compatible Spotify version manually (max: ${legacyMaxVer}), then re-run SpotX-Bash.\n"
|
||||
local notice="Automatic Spotify installation is unavailable on macOS ${macOSVer}.\nInstall a compatible Spotify version manually (max: ${legacyMaxVer}), then re-run SpotX-Bash."
|
||||
[[ "${installMac}" ]] && { echo -e "\n${red}Error:${clr} ${notice}\n" >&2; exit 1; }
|
||||
echo -e "\n${yellow}Warning:${clr} ${notice}\n"
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -333,15 +335,30 @@ linux_deb_prepare() {
|
||||
installOutput="${installPath}"
|
||||
linux_client_variant
|
||||
installClient='true'
|
||||
grab1=$(echo "=0TP3xEd5ITW1tmbaBnUzI2dO5GT1o0MiBDbyMmdChlW5lTeMZTTINGMShUY" | rev | base64 --decode | base64 --decode)
|
||||
[[ "${stableVar}" ]] && \
|
||||
grab2=$(echo "==QP9cWS6ZlMahGdykFaCFDTwkFRaRnRXxUNKhVW1xWbZZXVXpVeadFT1lTbiZXVHJWaGdEZ6lTejBjTYF2axgVTpZUbj5GdIpUaBl3Y0F0UjRXQDJWeWNTW" | rev | base64 --decode | base64 --decode) || \
|
||||
grab2=$(echo "==QPJl3YsR2VZJnTXlVU5MkTyE1VihWMTVWeG1mYwpkMMxmVtNWbxkmY2VjMM5WNXFGMOhlWwkTejBjTYF2axgVTpZUbj5GdIpUaBl3Y0F0UjRXQDJWeWNTW" | rev | base64 --decode | base64 --decode)
|
||||
grab3=$(eval "${grab2}" 2>/dev/null)
|
||||
grab4=$(echo "${grab3}" | grep -m 1 "^Filename: " | perl -pe 's/^Filename: //')
|
||||
grab5="${grab1}${grab4}"
|
||||
fileVar=$(basename "${grab4}")
|
||||
downloadVer=$(echo "${fileVar}" | perl -pe 's/^[a-z-]+_([0-9.]+)\.g.*/\1/')
|
||||
local suite='testing' keyFingerprint='E1096BCBFF6D418796DE78515384CE82BA52C83A'
|
||||
[[ "${stableVar}" ]] && suite='stable'
|
||||
linux_working_dir
|
||||
local aptDir="${workDir}/apt"
|
||||
mkdir -p "${aptDir}/keys" "${aptDir}/lists/partial" || exit 1
|
||||
debAptOptions=(
|
||||
-o "Dir::Etc::sourcelist=${aptDir}/spotify.list" -o 'Dir::Etc::sourceparts=-'
|
||||
-o "Dir::Etc::trustedparts=${aptDir}/keys" -o 'Dir::Etc::trusted='
|
||||
-o "Dir::State::lists=${aptDir}/lists" -o 'Dir::State::status=/dev/null'
|
||||
-o 'Dir::Cache::pkgcache=' -o 'Dir::Cache::srcpkgcache='
|
||||
-o 'APT::Architecture=amd64' -o 'APT::Default-Release=' -o 'APT::Get::AllowUnauthenticated=false'
|
||||
)
|
||||
printf 'deb [arch=amd64 signed-by=%s] https://repository.spotify.com %s non-free\n' "${keyFingerprint}" "${suite}" > "${aptDir}/spotify.list" &&
|
||||
curl -q -fsSL --retry 3 "https://download.spotify.com/debian/pubkey_${keyFingerprint: -16}.gpg" -o "${aptDir}/keys/spotify.gpg" &&
|
||||
apt-get "${debAptOptions[@]}" update >/dev/null || {
|
||||
echo -e "\n${red}Error:${clr} Could not load Spotify's signed ${suite} repository.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
debVersion=$(LC_ALL=C apt-cache "${debAptOptions[@]}" policy spotify-client:amd64 | awk '$1 == "Candidate:" { print $2; exit }')
|
||||
[[ "${debVersion#*:}" =~ ^(1\.[0-9]+\.[0-9]+\.[0-9]+)([.+~-]|$) ]] || {
|
||||
echo -e "\n${red}Error:${clr} Spotify client version not found in the ${suite} repository.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
downloadVer="${BASH_REMATCH[1]}"
|
||||
[[ ! -f "${installPath}/Apps/xpui.spa" ]] && notInstalled='true'
|
||||
}
|
||||
|
||||
@@ -352,6 +369,8 @@ linux_no_client() {
|
||||
}
|
||||
command -v apt >/dev/null && {
|
||||
interactiveMode='true'
|
||||
notInstalled='true'
|
||||
prepare_interactive_input || exit 1
|
||||
linux_deb_prepare
|
||||
echo -e "\n${yellow}Warning:${clr} Client not found. Starting interactive mode...\n" >&2
|
||||
return
|
||||
@@ -893,28 +912,14 @@ check_write_permission() {
|
||||
[[ ! -w "${writePath}" || ( "${platformType}" == "Linux" && -f "${path_to_check}" && ! -O "${path_to_check}" ) ]] && {
|
||||
stagedInstall='true'
|
||||
protectedInstall='true'
|
||||
((EUID == 0)) && continue
|
||||
command -v sudo >/dev/null || {
|
||||
echo -e "\n${red}Error:${clr} sudo command not found. Install sudo or run this script as root.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
sudo -n true 2>/dev/null || {
|
||||
echo -e "${yellow}Warning:${clr} SpotX-Bash does not have write permission in client directory.\nRequesting sudo permission..." >&2
|
||||
sudo -v || {
|
||||
echo -e "\n${red}Error:${clr} SpotX-Bash was not given sudo permission. Exiting...\n" >&2
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
sudo_check 'SpotX-Bash needs sudo permission to modify this Spotify installation.'
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
sudo_run() {
|
||||
if ((EUID == 0)) || [[ -z "${protectedInstall+x}" ]]; then
|
||||
command "$@"
|
||||
else
|
||||
sudo "$@"
|
||||
fi
|
||||
[[ "${protectedInstall+x}" ]] && ((EUID != 0)) || { command "$@"; return; }
|
||||
sudo ${nonInteractive:+-n} "$@"
|
||||
}
|
||||
|
||||
protected_stage_copy() {
|
||||
@@ -1361,11 +1366,16 @@ run_interactive_check() {
|
||||
}
|
||||
|
||||
sudo_check() {
|
||||
((EUID == 0)) && return 0
|
||||
command -v sudo &> /dev/null || {
|
||||
echo -e "\n${red}Error:${clr} sudo command not found. Install sudo or run this script as root.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
sudo -n true &> /dev/null || {
|
||||
[[ "${nonInteractive}" ]] && {
|
||||
echo -e "\n${red}Error:${clr} Sudo permission is required. Authorize sudo before running with '--noninteractive'.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
printf '%s\n%s\n' "${1:-This script requires sudo permission to install the client.}" 'Please enter your sudo password...'
|
||||
sudo -v || {
|
||||
echo -e "\n${red}Error:${clr} Failed to obtain sudo permission. Exiting...\n" >&2
|
||||
@@ -1380,7 +1390,6 @@ cleanup_temp_dirs() {
|
||||
macos_probe_cleanup
|
||||
macos_recovery_restore
|
||||
[[ -n "${macInstallTemp:-}" && -d "${macInstallTemp}" && "${macInstallTemp%/*}" == "${installPath:-}" && "${macInstallTemp##*/}" == .spotx-install.* ]] && rm -rf -- "${macInstallTemp}"
|
||||
[[ -n "${macDownloadPath:-}" && -f "${macDownloadPath}" && "${macDownloadPath%/*}" == "${HOME}/Downloads" && "${macDownloadPath##*/}" == "${fileVar:-}" ]] && rm -f -- "${macDownloadPath}"
|
||||
[[ -n "${workDir:-}" && -d "${workDir}" && "${workDir##*/}" == spotx-bash.* ]] && rm -rf -- "${workDir}"
|
||||
[[ -n "${copyTempDir:-}" && -d "${copyTempDir}" && "${copyTempDir##*/}" == *.spotx.* ]] && rm -rf -- "${copyTempDir}"
|
||||
[[ -n "${spaTempDir:-}" && -d "${spaTempDir}" && "${spaTempDir##*/}" == .spotx-spa.* ]] && rm -rf -- "${spaTempDir}"
|
||||
@@ -1405,78 +1414,68 @@ linux_working_dir() {
|
||||
linux_deb_install() {
|
||||
client_lock_acquire || exit 1
|
||||
sudo_check
|
||||
linux_working_dir
|
||||
lc01=$(printf "%s" \
|
||||
"=kjQ59EeBNEZwhGWad2cq1Ub0QUSpRzRYtmVHJGcG1mWnF1VZZHetJ2M5ckWnFlb" \
|
||||
"ixGbHJGRCNlZ5hnMZdjUp9Ue502Y5ZVVmtmVtN2NSlmYjp0QJxWMDlkdoJTWsJUe" \
|
||||
"ld2dIZ2ZJNlTpZUbj5mUpl0Z3dkYxUjMMJjVHpldBlnY0FUejRXQTNFdBlmW0F0U" \
|
||||
"jRXQDJWeWNTW" \
|
||||
| rev | base64 --decode | base64 --decode)
|
||||
lc02=$(printf "%s" \
|
||||
"9ADSJdTRElEMsdUZsJUePlXWpB1ZJlmYjJ1VaNHbXlVbCNkWolzRiVHZzI2aCNEZ" \
|
||||
"1Z1VhNnTFlUOKhkYqRHSKZTSzIWeKhlU5I1ValHdIpUd4xWSnV1VMdGOHFmaWdUS" \
|
||||
"3I0QmhjQplUMJdVW5R2RKlWQplUOKhVWXZ1RiBnWyU2a4MlZ5x2RSJnSzI2M0hkS" \
|
||||
"pFUeiRXQT50Zr52YwYVbjRHMDlEdBlXU0FUaaRXQpNGaKdFT65EWalHZyIWeChFT" \
|
||||
"0F0UjRXQDJWeWNTW" \
|
||||
| rev | base64 --decode | base64 --decode)
|
||||
eval "${lc01}"; eval "${lc02}"
|
||||
dpkg-deb --info "${workDir}/${fileVar}" &>/dev/null || {
|
||||
rm "${workDir}/${fileVar}" 2>/dev/null
|
||||
echo -e "\n${red}Error:${clr} Downloaded client package is corrupt or incomplete. Exiting...\n" >&2
|
||||
local protectedInstall='true' aptEnv=() aptFlags=()
|
||||
[[ "${nonInteractive}" ]] && {
|
||||
aptEnv=(DEBIAN_FRONTEND=noninteractive)
|
||||
aptFlags=(-o 'Dpkg::Options::=--force-confdef' -o 'Dpkg::Options::=--force-confold')
|
||||
}
|
||||
(cd "${workDir}" && apt-get "${debAptOptions[@]}" download "spotify-client:amd64=${debVersion}") || {
|
||||
echo -e "\n${red}Error:${clr} Could not download the verified Spotify package.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
local packages=("${workDir}"/spotify-client_*_amd64.deb)
|
||||
[[ "${#packages[@]}" == 1 && -f "${packages[0]}" ]] || {
|
||||
echo -e "\n${red}Error:${clr} Expected one downloaded Spotify package.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
printf "\xE2\x9C\x94\x20\x44\x6F\x77\x6E\x6C\x6F\x61\x64\x65\x64\x20\x61\x6E\x64\x20\x69\x6E\x73\x74\x61\x6C\x6C\x69\x6E\x67\x20\x53\x70\x6F\x74\x69\x66\x79\n"
|
||||
[[ -f "${appBak}" ]] && sudo rm "${appBak}" 2>/dev/null
|
||||
[[ -f "${xpuiBak}" || -f "${xpuiBak}.info" ]] && sudo rm -f -- "${xpuiBak}" "${xpuiBak}.info" 2>/dev/null
|
||||
[[ -d "${xpuiDir}" ]] && sudo rm -rf "${xpuiDir}" 2>/dev/null
|
||||
sudo dpkg -i "${workDir}/${fileVar}" &>/dev/null || {
|
||||
sudo apt-get -f install -y &>/dev/null || {
|
||||
rm "${workDir}/${fileVar}" 2>/dev/null
|
||||
echo -e "\n${red}Error:${clr} Failed to install missing dependencies. Exiting...\n" >&2
|
||||
exit 1
|
||||
}
|
||||
} && sudo dpkg -i "${workDir}/${fileVar}" &>/dev/null || {
|
||||
rm "${workDir}/${fileVar}" 2>/dev/null
|
||||
sudo_run env "${aptEnv[@]}" apt-get "${aptFlags[@]}" -y --reinstall --allow-downgrades --no-remove --no-install-recommends install "${packages[0]}" || {
|
||||
echo -e "\n${red}Error:${clr} Client install failed. Exiting...\n" >&2
|
||||
exit 1
|
||||
}
|
||||
printf "\xE2\x9C\x94\x20\x49\x6E\x73\x74\x61\x6C\x6C\x65\x64\x20\x69\x6E\x20'"${installOutput}"'\n"
|
||||
rm "${workDir}/${fileVar}" 2>/dev/null
|
||||
clientVer=$(echo "${fileVar}" | perl -pe 's/^[a-z-]+_([0-9.]+)\.g.*/\1/')
|
||||
detectedClientVer=$(dpkg-query -W -f='${Version}' spotify-client 2>/dev/null | perl -ne '/(1(?:\.[0-9]+){3})/ && print $1')
|
||||
[[ "$(dpkg-query -W -f='${db:Status-Status} ${Version}' spotify-client:amd64)" == "installed ${debVersion}" ]] || {
|
||||
echo -e "\n${red}Error:${clr} Could not confirm the requested Spotify package was installed.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
[[ -e "${appBak}" || -e "${xpuiBak}" || -e "${xpuiBak}.info" || -d "${xpuiDir}" ]] && {
|
||||
(set -o pipefail
|
||||
[[ -f "${appBinary}" && -s "${appBinary}" && -x "${appBinary}" && -f "${xpuiSpa}" ]] && cd / &&
|
||||
dpkg-query --control-show spotify-client:amd64 md5sums |
|
||||
awk -v bin="${appBinary#/}" -v spa="${xpuiSpa#/}" '
|
||||
length($1) != 32 || $1 !~ /^[0-9a-f]+$/ { next }
|
||||
$2 == bin { binary++; print }
|
||||
$2 == spa { archive++; print }
|
||||
END { exit !(binary == 1 && archive == 1) }' |
|
||||
md5sum -c - >/dev/null
|
||||
) || { printf '%s\n' 'Error: Could not verify the installed Spotify files. Backups were preserved.' >&2; exit 1; }
|
||||
}
|
||||
sudo_run rm -f -- "${appBak}" "${xpuiBak}" "${xpuiBak}.info" &&
|
||||
sudo_run rm -rf -- "${xpuiDir}" || { echo -e "${red}Error:${clr} Could not clean the previous installation." >&2; exit 1; }
|
||||
printf "\xE2\x9C\x94 Installed in '%s'\n" "${installOutput}"
|
||||
clientVer="${downloadVer}"
|
||||
detectedClientVer="${downloadVer}"
|
||||
unset notInstalled versionFailed
|
||||
}
|
||||
|
||||
macos_client_install() {
|
||||
client_lock_acquire || exit 1
|
||||
local downloadPath="${HOME}/Downloads/${fileVar}" stagedApp
|
||||
local downloadPath stagedApp
|
||||
[[ ! -w "${installPath}" ]] && {
|
||||
echo -e "${red}Error:${clr} SpotX-Bash does not have write permission in ${installOutput}.\nConfirm permissions or set custom install path to writable directory.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
mc01=$(printf "%s" \
|
||||
"=kjQ59EeBNEZwhGWad2cq1Ub0QUSpRzRYtmVHJGcG1mWnF1VZZHetJ2M5ckWnFlb" \
|
||||
"ixGbHJGRCNlZ5hnMZdjUp9Ue502Y5ZVVmtmVtN2NSlmYjp0QJxWMDlkdoJTWsJUe" \
|
||||
"ld2dIZ2ZJlXTpZUbj5mUpl0Z3dkYxUjMMJjVHpldBlnY0FUejRXQTNFdBlmW0F0U" \
|
||||
"jRXQDJWeWNTW" \
|
||||
| rev | base64 --decode | base64 --decode)
|
||||
mc02=$(printf "%s" \
|
||||
"=0TPRZ2ZzRVTnFFWhRjVHl0NJpmSrEUaJVHeGpFb4dVYop1RJtmRyI2c1IDZ2J1R" \
|
||||
"JBTNXpFc4JTUnBjbjNnTyU2avp2Y2pkbjZUMIpFbKNTZrRzRYlWQTpFdBlnYv50V" \
|
||||
"ad2cIlEO4hUSp1kaZhmSzo1aJNUSpBjbjhmWWp1cs1mW3IVeMpnUXlld41mYzkzR" \
|
||||
"SZXVVRFUoVkSpFUeiRXQT50Zr52YwYVbjRHMDlEdBlXU0FUaaRXQpNGaKdFT65EW" \
|
||||
"alHZyIWeChFT0F0UjRXQDJWeWNTW" \
|
||||
| rev | base64 --decode | base64 --decode)
|
||||
eval "${mc01}"; eval "${mc02}"
|
||||
linux_working_dir
|
||||
downloadPath="${workDir}/spotify.tbz"
|
||||
curl -q --progress-bar -f -C - --retry 5 -o "${downloadPath}" "${grab3}" || {
|
||||
echo -e "\n${red}Error:${clr} Client download failed\n" >&2
|
||||
exit 1
|
||||
}
|
||||
tar -tf "${downloadPath}" >/dev/null 2>&1 || {
|
||||
rm "${downloadPath}" 2>/dev/null
|
||||
echo -e "\n${red}Error:${clr} Downloaded client archive is corrupt or incomplete. Exiting...\n" >&2
|
||||
exit 1
|
||||
}
|
||||
macDownloadPath="${downloadPath}"
|
||||
printf "\xE2\x9C\x94\x20\x44\x6F\x77\x6E\x6C\x6F\x61\x64\x65\x64\x20\x61\x6E\x64\x20\x69\x6E\x73\x74\x61\x6C\x6C\x69\x6E\x67\x20\x53\x70\x6F\x74\x69\x66\x79\n"
|
||||
macInstallTemp=$(mktemp -d "${installPath}/.spotx-install.XXXXXXXX") || {
|
||||
rm "${downloadPath}" 2>/dev/null
|
||||
echo -e "\n${red}Error:${clr} Client install failed. Exiting...\n" >&2
|
||||
exit 1
|
||||
}
|
||||
@@ -1486,14 +1485,13 @@ macos_client_install() {
|
||||
[[ -x "${stagedApp}/Contents/MacOS/Spotify" ]] &&
|
||||
[[ -f "${stagedApp}/Contents/Info.plist" ]] &&
|
||||
[[ -f "${stagedApp}/Contents/Resources/Apps/xpui.spa" ]] || {
|
||||
rm "${downloadPath}" 2>/dev/null
|
||||
echo -e "\n${red}Error:${clr} Client install failed. Exiting...\n" >&2
|
||||
exit 1
|
||||
}
|
||||
macInstallTarget="${appPath}"
|
||||
macInstallSource="${stagedApp}"
|
||||
macos_bind_bundle "${stagedApp}"
|
||||
rm "${downloadPath}" && unset macDownloadPath
|
||||
rm -f -- "${downloadPath}"
|
||||
clientVer=$(echo "${fileVar}" | perl -ne '/te-(.*)\..*\./ && print "$1"')
|
||||
detectedClientVer=$(defaults read "${stagedApp}/Contents/Info.plist" CFBundleShortVersionString 2>/dev/null | perl -ne '/^(1(?:\.[0-9]+){3})/ && print $1')
|
||||
unset notInstalled versionFailed
|
||||
|
||||
Reference in new issue
Block a user