Skip to content

Instantly share code, notes, and snippets.

@bechampion
Created February 2, 2022 09:19
Show Gist options
  • Save bechampion/75e6a37aad0f8775a4c8df987d315020 to your computer and use it in GitHub Desktop.
Save bechampion/75e6a37aad0f8775a4c8df987d315020 to your computer and use it in GitHub Desktop.
CREDS="user:password"
SOURCE="http://localhost:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${CREDS} $SOURCE/service/rest/v1/repositories | jq '.[]|select(.format=="apt" or .format=="yum")|select(.type=="proxy" or .type=="group")|.name+","+.format+","+.type' -r)
do
IFS="," read -r NAME FORMAT TYPE < <( echo $i)
JJ=$(curl -s -H"Content-Type: application/json" -u ${CREDS} ${SOURCE}/service/rest/v1/repositories/${FORMAT}/${TYPE}/${NAME} | jq -c '.name=.name+"_v2"')
echo ${JJ}
curl -s -H"Content-Type: application/json" -u ${CREDS} ${SOURCE}/service/rest/v1/repositories/${FORMAT}/${TYPE} -d @<(echo ${JJ})
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment