Created
April 21, 2022 08:34
-
-
Save bechampion/a9dd297c17c2c5ff9cac6dfb81df83b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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-15)) | |
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 | |
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