curl.sh 486 B

12345678910111213141516171819202122232425
  1. #!/bin/bash
  2. # Init CURL_OPTS if it's not set
  3. if [ -z ${CURL_OPTS+x} ]; then
  4. IFS=''
  5. CURL_OPTS=(--silent --connect-timeout 5 --max-time 30)
  6. fi
  7. # Construct URL
  8. if [ -z "${PMS_URL}" ]; then
  9. if [ -z "${PMS_HOST}" ]; then
  10. PMS_HOST="localhost"
  11. fi
  12. if [ -z "${PMS_PORT}" ]; then
  13. PMS_PORT=32400
  14. fi
  15. PMS_URL="https://${PMS_HOST}:${PMS_PORT}"
  16. fi
  17. # Append the token
  18. if [ -z "${PMS_TOKEN}" ]; then
  19. echo "No PMS_TOKEN provided" 1>&2
  20. else
  21. CURL_OPTS+=(-H "X-Plex-Token: ${PMS_TOKEN}")
  22. fi