Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- [[ -z "$1" ]] && echo "no resource directory supplied" && exit -1
- [[ -z "$2" ]] && echo "no destination repository supplied" && exit -1
- upload() {
- local local_repo="$1"
- local remote_repo="$2"
- local ct
- local user=${3:-${USER:-$(read -p "Username: " user && [ -n "${user}" ] && echo ${user})}}
- local pwd=$(read -s -p "Password: " pwd && [ -n "${pwd}" ] && echo ${pwd})
- echo ""
- declare -a pids
- for art in $(find "${local_repo}" -not -path '*/.*' -type f -not -name 'index.html' | sed -n 's;./(.*);1;p'); do
- # file extension
- case "$(echo ${art} | rev | cut -d'.' -f1 | rev)" in
- jar)
- ct="application/java-archive"
- ;;
- md5)
- ct="application/x-checksum"
- ;;
- pom)
- ct="application/x-maven-pom+xml"
- ;;
- sha1)
- ct="application/x-checksum"
- ;;
- txt)
- ct="text/plain"
- ;;
- xml)
- ct="application/xml"
- ;;
- esac
- (
- echo "${art} -> ${remote_repo}/${art}"
- curl -v -u "${user}:${pwd}" -X PUT -d "@$art" -H "Content-Type: $ct" "$remote_repo/$art" 2&>1 &&
- curl -I -u "${user}:${pwd}" "$remote_repo/$art" 2&>1
- ) &
- pids[${i}]=$!
- done
- for pid in ${pids[*]}; do
- wait ${pid}
- done
- }
- upload "$@"
Add Comment
Please, Sign In to add comment