Skip to content

Instantly share code, notes, and snippets.

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
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..."
sleep 1
done
curl -s -H"Content-Type: application/json" -u "admin:$(sudo cat /proc/$(docker inspect $(docker ps | grep -v CONT | awk '{ print $1 }') -f '{{ .State.Pid }}')/root/nexus-data/admin.password)" http://localhost:8081/service/rest/swagger.json | jq -r '.paths|keys'
#!/usr/bin/python
import os
import sys
import argparse
from google.cloud.resourcemanager import ProjectsClient
try:
import json
except ImportError:
import simplejson as json
package main
import (
"cloud.google.com/go/logging"
"cloud.google.com/go/logging/logadmin"
"context"
"encoding/json"
"os"
"fmt"
"google.golang.org/api/iterator"
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://localhost:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $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 ${SRCCREDS} ${SOURCE}/service/rest/v1/repositories/${FORMAT}/${TYPE}/${NAME})
echo ${JJ}
curl -s -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/repositories/${FORMAT}/${TYPE} -d @<(echo ${JJ})
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://10.14.232.51:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $SOURCE/service/rest/v1/blobstores | jq '.[].name | select(contains("bmg"))' -r)
do
BB=$(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} ${SOURCE}/service/rest/v1/blobstores/google/${i} | jq -c '.credentialFilePath="/opt/sonatype/nexus/creds/gcp.json"| del(.softQuota)')
curl -vvv -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/blobstores/google/ -d @<(echo ${BB})
done
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://10.14.232.51:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $SOURCE/service/rest/v1/blobstores | jq '.[].name | select(contains("bmg"))' -r)
do
BB=$(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} ${SOURCE}/service/rest/v1/blobstores/google/${i} | jq -c '.credentialFilePath="/opt/sonatype/nexus/creds/gcp.json"| del(.softQuota)')
curl -vvv -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/blobstores/google/ -d @<(echo ${BB})
done
SRCCREDS="user:password"
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://10.14.232.51:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $SOURCE/service/rest/v1/blobstores | jq '.[].name | select(contains("bmg"))' -r)
do
BB=$(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} ${SOURCE}/service/rest/v1/blobstores/google/${i} | jq -c '.credentialFilePath="/opt/sonatype/nexus/creds/gcp.json"| del(.softQuota)')
curl -vvv -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/blobstores/google/ -d @<(echo ${BB})
done
SRCCREDS="user:password"
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://10.14.232.51:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $SOURCE/service/rest/v1/blobstores | jq '.[].name | select(contains("bmg"))' -r)
do
BB=$(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} ${SOURCE}/service/rest/v1/blobstores/google/${i} | jq -c '.credentialFilePath="/opt/sonatype/nexus/creds/gcp.json"| del(.softQuota)')
curl -vvv -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/blobstores/google/ -d @<(echo ${BB})
done
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://localhost:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $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 ${SRCCREDS} ${SOURCE}/service/rest/v1/repositories/${FORMAT}/${TYPE}/${NAME} | jq -c '.name=.name+"_v2"')
echo ${JJ}
curl -s -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/repositories/${FORMAT}/${TYPE} -d @<(echo ${JJ})
SRCCREDS="user:password"
DSTCREDS="user:password"
SOURCE="http://10.14.232.51:8081"
DEST="http://localhost:8081"
for i in $(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} $SOURCE/service/rest/v1/blobstores | jq '.[].name | select(contains("bmg"))' -r)
do
BB=$(curl -s -H"Content-Type: application/json" -u ${SRCCREDS} ${SOURCE}/service/rest/v1/blobstores/google/${i} | jq -c '.name=.name+"_v2"| .bucketName=.bucketName+"_v2" | .credentialFilePath="/opt/sonatype/nexus/creds/gcp.json"| del(.softQuota)')
curl -vvv -H"Content-Type: application/json" -u ${DSTCREDS} ${DEST}/service/rest/v1/blobstores/google/ -d @<(echo ${BB})
done