Last active
September 23, 2022 13:27
-
-
Save chris1984/7d2a03df1bff749d7b8d1bf7766379e9 to your computer and use it in GitHub Desktop.
upload_package_to_repo.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ $# -lt 2 ]; then | |
echo "too few arguments" | |
exit | |
fi | |
repoid=${1} | |
package=${2} | |
pkgname=${package##*/} | |
creds=admin:redhat | |
saturl=$(hostname -f) | |
size=$(wc -c $package | awk '{ print $1}') | |
checksum=$(sha256sum $package | awk '{ print $1}') | |
upload_url=$(curl --header "Accept:application/json" \ | |
--header "Content-Type:application/json" \ | |
--request POST --insecure --user $creds \ | |
--data "{\"size\": ${size}}" \ | |
https://${saturl}/katello/api/repositories/${repoid}/content_uploads | cut -d\" -f4 ) | |
curl --header "Accept:application/json" \ | |
--header "Content-Type:multipart/form-data" \ | |
--request PUT --insecure --user $creds \ | |
--data-urlencode "content@${package}" \ | |
--data-urlencode offset=0 \ | |
--data-urlencode size=${size} \ | |
https://${saturl}/katello/api/repositories/${repoid}/content_uploads/${upload_url} | |
curl --header "Accept:application/json" \ | |
--header "Content-Type:application/json" \ | |
--request PUT --insecure \ | |
--user $creds \ | |
--data "{\"uploads\":[{\"id\": \"${upload_url}\", \"name\": \"${pkgname}\"}]}" \ | |
https://${saturl}/katello/api/repositories/${repoid}/import_uploads |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment