Skip to content

Instantly share code, notes, and snippets.

@bechampion
Created April 21, 2022 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bechampion/d1430501eb6c6f782d744776c67446c4 to your computer and use it in GitHub Desktop.
Save bechampion/d1430501eb6c6f782d744776c67446c4 to your computer and use it in GitHub Desktop.
for i in $(curl -s https://registry.hub.docker.com/v1/repositories/sonatype/nexus3/tags | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}')
do
TIMEOUT=60
echo $i ; docker run --net=host -d --rm sonatype/nexus3:${i}
until [[ $(curl -s -o /dev/null localhost:8081 -w "%{response_code}") == 200 ]]
do
echo "waiting on nexus..., sleeping 5"
sleep 5
done
until [[ $(sudo cat /proc/$(docker inspect $(docker ps | grep -v CONT | awk '{ print $1 }') -f '{{ .State.Pid }}')/root/nexus-data/admin.password) ]]
do
TIMEOUT=$((TIMEOUT-5))
echo "password file not there yet..Timeout:${TIMEOUT}"
sleep 5
[[ ${TIMEOUT} == 0 ]] && break
done
if [[ ${TIMEOUT} == 0 ]]
then
PASS="admin123"
else
PASS=$(sudo cat /proc/$(docker inspect $(docker ps | grep -v CONT | awk '{ print $1 }') -f '{{ .State.Pid }}')/root/nexus-data/admin.password)
fi
curl -s -H"Content-Type: application/json" -u "admin:${PASS}" http://localhost:8081/service/rest/swagger.json > $i.json
#Create apt proxy repo
echo "repo creation:" >> $i.json
curl -o /dev/null -s -H"Content-Type: application/json" -u "admin:${PASS}" -X POST localhost:8081/service/rest/v1/repositories/apt/proxy -d @repo.json -w "%{response_code}" >> $i.json
#try MKCOL
echo "MKCOL:" >> $i.json
curl -s -o /dev/null -H"Content-Type: application/json" -u "admin:${PASS}" -X MKCOL localhost:8081/repository/ubuntu-bionic-proxy/snapshots/release123 -w "%{response_code}" >> $i.json
docker kill $(docker ps | grep -v CONT | awk '{ print $1 }')
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment