download_webclient.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. cd "$(dirname "$0")"
  3. function download_compat {
  4. if [[ "$AZ_CACHE" != "" ]]
  5. then
  6. download_id=$(echo "$2" | md5sum | sed 's/ .*//g')
  7. if [[ -e "$AZ_CACHE/$3/$download_id" ]]
  8. then
  9. echo "Cache hit: $AZ_CACHE/$3/$download_id"
  10. cp "$AZ_CACHE/$3/$download_id" "$1"
  11. return
  12. elif [[ "$3" != "" ]]
  13. then
  14. rm -r "$AZ_CACHE/$3" 2> /dev/null
  15. fi
  16. fi
  17. if [[ "$(which wget 2>/dev/null)" != "" ]]
  18. then
  19. wget -qO "$1" "$2"
  20. else [[ "$(which curl)" != "" ]]
  21. curl -sL "$2" > "$1"
  22. fi
  23. if [[ "$AZ_CACHE" != "" ]]
  24. then
  25. echo "Saving to: $AZ_CACHE/$3/$download_id"
  26. mkdir -p "$AZ_CACHE/$3/"
  27. cp "$1" "$AZ_CACHE/$3/$download_id"
  28. fi
  29. }
  30. function get_webclient_version {
  31. curl https://repo.jellyfin.org/releases/server/portable/versions/stable/web/ \
  32. | grep '[0-9]\+\.[0-9]\+\.[0-9]\+' \
  33. | sed 's/.*>\([0-9]\+\.[0-9]\+\.[0-9]\+\)\/.*/\1/g' \
  34. | sort -h | tail -n 1
  35. }
  36. if [[ "$1" == "--gen-fingerprint" ]]
  37. then
  38. (
  39. get_webclient_version
  40. ) | tee az-cache-fingerprint.list
  41. exit 0
  42. fi
  43. # Download web client
  44. update_web_client="no"
  45. mkdir -p build
  46. if [[ ! -e "build/dist" ]]
  47. then
  48. update_web_client="yes"
  49. elif [[ -e ".last_wc_version" ]]
  50. then
  51. if [[ "$(get_webclient_version)" != "$(cat .last_wc_version)" ]]
  52. then
  53. update_web_client="yes"
  54. fi
  55. fi
  56. if [[ "$update_web_client" == "yes" ]]
  57. then
  58. echo "Downloading web client..."
  59. wc_version=$(get_webclient_version)
  60. 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"
  61. if [[ "$DOWNLOAD_ONLY" != "1" ]]
  62. then
  63. rm -r build/dist 2> /dev/null
  64. rm -r dist 2> /dev/null
  65. tar -xvf dist.tar.gz > /dev/null && rm dist.tar.gz
  66. mv "jellyfin-web_${wc_version}" build/dist
  67. fi
  68. echo "$wc_version" > .last_wc_version
  69. fi