Guest User

Untitled

a guest
Feb 4th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. [[ -z "$1" ]] && echo "no resource directory supplied" && exit -1
  4. [[ -z "$2" ]] && echo "no destination repository supplied" && exit -1
  5.  
  6.  
  7. upload() {
  8. local local_repo="$1"
  9. local remote_repo="$2"
  10. local ct
  11. local user=${3:-${USER:-$(read -p "Username: " user && [ -n "${user}" ] && echo ${user})}}
  12. local pwd=$(read -s -p "Password: " pwd && [ -n "${pwd}" ] && echo ${pwd})
  13. echo ""
  14. declare -a pids
  15. for art in $(find "${local_repo}" -not -path '*/.*' -type f -not -name 'index.html' | sed -n 's;./(.*);1;p'); do
  16.  
  17.  
  18. # file extension
  19. case "$(echo ${art} | rev | cut -d'.' -f1 | rev)" in
  20. jar)
  21. ct="application/java-archive"
  22. ;;
  23. md5)
  24. ct="application/x-checksum"
  25. ;;
  26. pom)
  27. ct="application/x-maven-pom+xml"
  28. ;;
  29. sha1)
  30. ct="application/x-checksum"
  31. ;;
  32. txt)
  33. ct="text/plain"
  34. ;;
  35. xml)
  36. ct="application/xml"
  37. ;;
  38. esac
  39. (
  40. echo "${art} -> ${remote_repo}/${art}"
  41. curl -v -u "${user}:${pwd}" -X PUT -d "@$art" -H "Content-Type: $ct" "$remote_repo/$art" 2&>1 &&
  42. curl -I -u "${user}:${pwd}" "$remote_repo/$art" 2&>1
  43. ) &
  44.  
  45. pids[${i}]=$!
  46.  
  47. done
  48. for pid in ${pids[*]}; do
  49. wait ${pid}
  50. done
  51. }
  52. upload "$@"
Add Comment
Please, Sign In to add comment