Untitled
unknown
batchfile
3 years ago
1.7 kB
0
Indexable
Never
LOCAL_IP=$(ip address show eth0 | grep -w inet | awk '{print $2}' | cut -d/ -f1) RID=$(curl -s 'localhost/api/pki/certs' \ -H "Csphere-Api-Key: $API_KEY" \ -H 'Content-Type: application/json' \ --data '{"ip":"'"$LOCAL_IP"'","port":443,"cert":"","key":""}' | jq -r '.id' 2>/dev/null) # 获取 RID SRVID=$(curl -s 'localhost/api/svrpools' -H "Csphere-Api-Key: $API_KEY" | jq -r '.[1].nodes|.[]' 2>/dev/null) # 获取 SRVID curl -s -o /dev/null 'localhost/api/containers/create?nodes='$SRVID'&name=&job_name=&count=1®istry_id=&ips=' \ -H "Csphere-Api-Key: $API_KEY" \ -H 'Content-Type: application/json' \ --data "{\"quota\":{},\"ccfg_option\":[],\"container_config\":{\"Env\":[\"CSPHERE_REGISTRY_ID=$RID\",\"CSPHERE_AUTH_KEY=aaaaaaaaaaaaaaaaaaaaa\",\"CSPHERE_HTPASSWD_USER=\",\"CSPHERE_HTPASSWD_PASSWORD=\"],\"HostConfig\":{\"RestartPolicy\":{\"Name\":\"always\",\"MaximumRetryCount\":0},\"Binds\":[\"/data/registry:/data\"],\"PortBindings\":{\"443/tcp\":[{\"HostPort\":\"443\"}]}},\"Image\":\"csphere/registry-v2:latest\",\"ExposedPorts\":{\"443/tcp\":{}},\"Labels\":{\"CSPHERE_ROLE\":\"CSPHERE_REGISTRY\",\"CSPHERE_REGISTRY_ID\":\"$RID\",\"CSPHERE_USER\":\"$USER_EMAIL\"}}}" # 创建仓库 传入RID和SRVID curl -s -o /dev/null 'localhost/api/registry' \ -H "Csphere-Api-Key: $API_KEY" \ -H 'Content-Type: application/json' \ --data '{"name":"'"$LOCAL_IP"'","serveraddress":"https://'"$LOCAL_IP"'","username":"","password":""}' curl -s -o /dev/null 'localhost/api/registry' \ -H "Csphere-Api-Key: $API_KEY" \ -H 'Content-Type: application/json' \ --data '{"name":"Registry A","username":"","password":"","serveraddress":"https://example.com:443"}'