2021-04-08 23:49:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
function download_compat {
|
|
|
|
if [[ "$AZ_CACHE" != "" ]]
|
|
|
|
then
|
|
|
|
download_id=$(echo "$2" | md5sum | sed 's/ .*//g')
|
|
|
|
if [[ -e "$AZ_CACHE/$3/$download_id" ]]
|
|
|
|
then
|
|
|
|
echo "Cache hit: $AZ_CACHE/$3/$download_id"
|
|
|
|
cp "$AZ_CACHE/$3/$download_id" "$1"
|
|
|
|
return
|
|
|
|
elif [[ "$3" != "" ]]
|
|
|
|
then
|
|
|
|
rm -r "$AZ_CACHE/$3" 2> /dev/null
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ "$(which wget 2>/dev/null)" != "" ]]
|
|
|
|
then
|
|
|
|
wget -qO "$1" "$2"
|
|
|
|
else [[ "$(which curl)" != "" ]]
|
|
|
|
curl -sL "$2" > "$1"
|
|
|
|
fi
|
|
|
|
if [[ "$AZ_CACHE" != "" ]]
|
|
|
|
then
|
|
|
|
echo "Saving to: $AZ_CACHE/$3/$download_id"
|
|
|
|
mkdir -p "$AZ_CACHE/$3/"
|
|
|
|
cp "$1" "$AZ_CACHE/$3/$download_id"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-03-08 22:43:39 +00:00
|
|
|
function get_webclient_version {
|
|
|
|
curl https://repo.jellyfin.org/releases/server/portable/versions/stable/web/ \
|
2023-03-09 01:23:48 +00:00
|
|
|
| tr '<>/' '\t' | grep '[0-9]\+\.[0-9]\+\.[0-9]\+' | cut -f 4 | sort -V | tail -n 1
|
2021-04-08 23:49:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ "$1" == "--gen-fingerprint" ]]
|
|
|
|
then
|
|
|
|
(
|
2023-03-08 22:43:39 +00:00
|
|
|
get_webclient_version
|
2021-04-08 23:49:44 +00:00
|
|
|
) | tee az-cache-fingerprint.list
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Download web client
|
|
|
|
update_web_client="no"
|
|
|
|
mkdir -p build
|
|
|
|
if [[ ! -e "build/dist" ]]
|
|
|
|
then
|
|
|
|
update_web_client="yes"
|
|
|
|
elif [[ -e ".last_wc_version" ]]
|
|
|
|
then
|
2023-03-08 22:43:39 +00:00
|
|
|
if [[ "$(get_webclient_version)" != "$(cat .last_wc_version)" ]]
|
2021-04-08 23:49:44 +00:00
|
|
|
then
|
|
|
|
update_web_client="yes"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$update_web_client" == "yes" ]]
|
|
|
|
then
|
|
|
|
echo "Downloading web client..."
|
2023-03-08 22:43:39 +00:00
|
|
|
wc_version=$(get_webclient_version)
|
|
|
|
download_compat dist.tar.gz "https://repo.jellyfin.org/releases/server/portable/versions/stable/web/${wc_version}/jellyfin-web_${wc_version}_portable.tar.gz" "wc"
|
2021-04-25 00:16:49 +00:00
|
|
|
if [[ "$DOWNLOAD_ONLY" != "1" ]]
|
|
|
|
then
|
|
|
|
rm -r build/dist 2> /dev/null
|
|
|
|
rm -r dist 2> /dev/null
|
2023-03-08 22:43:39 +00:00
|
|
|
tar -xvf dist.tar.gz > /dev/null && rm dist.tar.gz
|
|
|
|
mv "jellyfin-web_${wc_version}" build/dist
|
2021-04-25 00:16:49 +00:00
|
|
|
fi
|
2021-04-08 23:49:44 +00:00
|
|
|
echo "$wc_version" > .last_wc_version
|
|
|
|
fi
|
|
|
|
|