download_live.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. CWD="$( cd "$( dirname "$0" )" && pwd )"
  3. wget_dnld () {
  4. DOWNLOAD_PATH=$CWD;
  5. if [ ! -z "$3" ]; then
  6. mkdir -p $CWD/$3
  7. DOWNLOAD_PATH=$CWD/$3
  8. fi;
  9. if [ ! -f "$DOWNLOAD_PATH/$2" ]; then
  10. echo "Downloading $1"
  11. #curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
  12. wget -O "$DOWNLOAD_PATH/$2" "$1"
  13. EXITCODE=$?
  14. if [ $EXITCODE -ne 0 ]; then
  15. echo ""
  16. echo "Failed to download $1. Exitcode $EXITCODE. Retrying in 10 seconds";
  17. sleep 10
  18. #curl -L --silent -o "$DOWNLOAD_PATH/$2" "$1"
  19. wget -O "$DOWNLOAD_PATH/$2" "$1"
  20. fi
  21. EXITCODE=$?
  22. if [ $EXITCODE -ne 0 ]; then
  23. echo ""
  24. echo "Failed to download $1. Exitcode $EXITCODE";
  25. exit 1
  26. fi
  27. echo "... Done"
  28. if ! tar -xvf "$DOWNLOAD_PATH/$2" -C "$DOWNLOAD_PATH" 2>/dev/null >/dev/null; then
  29. echo "Failed to extract $2";
  30. exit 1
  31. fi
  32. else
  33. echo "\"$DOWNLOAD_PATH/$2\" exists, if want to download the latest,please remove \"$2\" firstly!"
  34. exit 0
  35. fi
  36. }
  37. wget_dnld "http://www.live555.com/liveMedia/public/live555-latest.tar.gz" "live.tar.gz"