-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.sh
executable file
·87 lines (73 loc) · 2.62 KB
/
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bash
# Force bash shell
if [ -z "$BASH" ]; then
echo "Launching a bash shell"
exec bash "$0"
fi
set -eo pipefail
name="volspotconnect2"
use_local_ver=no
libpath=/data/plugins/music_service/${name}
configpath=/data/configuration/music_service/${name}
exit_error() {
echo "Plugin <${name}> installation script failed!!"
}
trap exit_error INT ERR
echo "Installing ${name} dependencies"
## Removing previous config
if [ -f "${configpath}/config.json" ]; then
echo "Cleaning old config flile"
sudo rm ${configpath}/config.json
fi
# shellcheck source=/dev/null
source /etc/os-release
## Get the Daemon binary
declare -A VLS_BIN=(
[armv6l]="vollibrespot-armv6l.tar.xz"
[armv7l]="vollibrespot-armv7l.tar.xz"
[aarch64]="vollibrespot-armv7l.tar.xz"
[i686]="vollibrespot-i686.tar.xz"
[x86_64]="vollibrespot-x86_64.tar.xz"
)
[[ ${VOLUMIO_ARCH} == armv8 ]] && VLS_BIN[aarch64]="vollibrespot-aarch64.tar.xz"
# Find arch
cpu=$(lscpu | lscpu | awk '/Architecture/{print $2}')
echo "Detected CPU: ${cpu} -- $(uname -m) -- ${VOLUMIO_ARCH}"
# Download and extract latest release
cd "${libpath}"
if [ ${VLS_BIN[${cpu}]+ok} ]; then
# Check for the latest release first
RELEASE_JSON=$(curl --silent "https://api.github.com/repos/ashthespy/vollibrespot/releases/latest")
# Get a fixed version from the repo
VLS_VER=v$(jq -r '.vollibrespot.version' package.json)
LATEST_VER=$(jq -r '.tag_name' <<<"${RELEASE_JSON}")
echo "Latest version: ${LATEST_VER} Requested version: ${VLS_VER}"
echo "Supported device (arch = ${cpu}), downloading required packages for vollibrespot $VLS_VER"
RELEASE_URL="https://api.github.com/repos/ashthespy/vollibrespot/releases/tags/${VLS_VER}"
DOWNLOAD_URL=$(curl --silent "${RELEASE_URL}" |
jq -r --arg VLS_BIN "${VLS_BIN[${cpu}]}" '.assets[] | select(.name | contains($VLS_BIN)).browser_download_url')
echo "Downloading file <${DOWNLOAD_URL}>"
if [[ $use_local_ver == no ]]; then
curl -L --output "${VLS_BIN[${cpu}]}" "${DOWNLOAD_URL}"
elif [[ -f ${VLS_BIN[${cpu}]} ]]; then
echo "Using local version"
fi
if [ $? -eq 0 ]; then
echo "Extracting..."
ls -l "${VLS_BIN[${cpu}]}"
tar -xf "${VLS_BIN[${cpu}]}" &&
./vollibrespot -v &&
rm "${VLS_BIN[${cpu}]}"
else
echo -e "Failed to download vollibrespot daemon. Check for internet connectivity/DNS issues. \nTerminating installation!"
exit 1
fi
else
echo -e "Sorry, current device (arch = ${cpu}) is not supported! \nTerminating installation!"
exit 1
fi
## Install the service
sudo tar -xvf ${name}.service.tar -C /
echo "${name} installed"
#required to end the plugin install
echo "plugininstallend"