From cac1f2abc1faa8547edee5419e900294c5eb1574 Mon Sep 17 00:00:00 2001 From: lijinpei2008 Date: Sun, 16 Feb 2020 08:51:46 +0800 Subject: [PATCH 1/4] Update loop.sh file --- installAzCLIAndDocker.sh | 5 ++-- loop.sh | 63 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 4 deletions(-) diff --git a/installAzCLIAndDocker.sh b/installAzCLIAndDocker.sh index 77a80b9..bd09695 100644 --- a/installAzCLIAndDocker.sh +++ b/installAzCLIAndDocker.sh @@ -71,11 +71,12 @@ sudo apt install openjdk-8-jdk echo "============================================================================= Check Java SDK Version ===============================================================================" java -version -echo "========================================================================= The Installation Is Complete =============================================================================" -echo "=========================================================================== If Docker Is Not Running ===============================================================================" +echo "========================================================================== The Installation Is Complete ===============================================================================" +echo "=========================================================================== If Docker Is Not Running ================================================================================" echo "=========================================================== Restart Docker Desktop And Restart WSL As AdminiStrator ================================================================" echo "=================================== [sudo gpasswd -a \$USER docker] [newgrp docker] [sudo chown \"\$USER\":\"\$USER\" /home/\"\$USER\"/.docker -R] ===========================================" echo "============================================== [sudo chmod g+rwx \"/home/\$USER/.docker\" -R] [sudo chmod a+rw /var/run/docker.sock] ==================================================" +echo "============================================================= [export DOCKER_HOST=tcp://127.0.0.1:2375] input into [.bashrc] =====================================================================" #Find History history diff --git a/loop.sh b/loop.sh index 295fa9e..0d5676d 100644 --- a/loop.sh +++ b/loop.sh @@ -20,7 +20,7 @@ fi echo "==================================================================== Input Container Registry Name! ==========================================================================" read name -echo "=============================================================== Push Repositories(r/R)? Tags(t)? Task(T)? ====================================================================" +echo "======================================================== Push Repositories(r/R)? Tags(t)? Task(T)? ScopeMap(s/S) =============================================================" read tit echo "================================================================== Do you want to loop it a few times? =======================================================================" read num @@ -60,6 +60,62 @@ case ${tit} in done ;; + "s"|"S") + while ((${loopCount}<=${num})) + do + az acr scope-map create -n ${name}scopemap${loopCount} --repository hello-world${loopCount} content/read content/write -r ${name} --description "Sample scope map." + + az acr token create -n ${name}token${loopCount} --scope-map ${name}scopemap${loopCount} -r ${name} + + az acr token credential generate -n ${name}token${loopCount} -r ${name} + + echo "======================================================================== Input Token Password Name ============================================================================" + read tokenPassword + + docker login ${name}.azurecr.io -u ${name}token${loopCount} -p ${tokenPassword} + docker tag hello-world ${name}.azurecr.io/hello-world${loopCount} + docker tag hello-world ${name}.azurecr.io/alpine${loopCount} + docker push ${name}.azurecr.io/hello-world${loopCount} + docker push ${name}.azurecr.io/alpine${loopCount} + + az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/read content/write -r ${name} + docker push ${name}.azurecr.io/alpine${loopCount} + + az acr scope-map update -n ${name}scopemap${loopCount} --add hello-world${loopCount} metadata/read -r ${name} + + az acr repository show-manifests --repository hello-world${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} + az acr repository show-tags --repository hello-world${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} + + az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} metadata/write -r ${name} + + az acr repository update --repository alpine${loopCount} --write-enabled false --delete-enabled false -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} + az acr repository update --repository alpine${loopCount} --write-enabled true --delete-enabled true -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} + + az acr scope-map update -n ${name}scopemap${loopCount} --remove alpine${loopCount} content/read -r ${name} + docker pull ${name}.azurecr.io/hello-world${loopCount} + docker pull ${name}.azurecr.io/alpine${loopCount} + + az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/read -r ${name} + docker pull ${name}.azurecr.io/alpine${loopCount} + + az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/delete -r ${name} + + az acr repository delete --repository alpine${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} + + az acr token credential generate -n ${name}token${loopCount} -r ${name} + docker push ${name}.azurecr.io/alpine${loopCount} + + docker login -u ${name}token${loopCount} -p ${tokenPassword} ${name}.azurecr.io + docker push ${name}.azurecr.io/alpine${loopCount} + + az acr token update -n ${name}token${loopCount} -r ${name} --status disabled + docker tag hello-world ${name}a.azurecr.io/alpine${loopCount} + docker push ${name}a.azurecr.io/alpine${loopCount} + + let "loopCount++" + done + ;; + *) echo "Error: ${tit} could not be found." break @@ -75,7 +131,10 @@ read sthmessage loopCount=1 while ((${loopCount}<=${num})) do + docker rmi ${name}.${name}.azurecr.io/alpine${loopCount} + docker rmi ${name}a.${name}.azurecr.io/alpine${loopCount} + docker rmi ${name}.${name}.azurecr.io/hello-world${loopCount} docker rmi ${name}.azurecr.io/newimagename${loopCount} docker rmi ${name}.azurecr.io/newimagename:version${loopCount} let "loopCount++" -done +done \ No newline at end of file From 00d17d2199f54cd637aa3b59115a7bfb94e77a11 Mon Sep 17 00:00:00 2001 From: lijinpei2008 Date: Sun, 16 Feb 2020 08:59:26 +0800 Subject: [PATCH 2/4] To solve the WSL daemon open the failed problem --- installAzCLIAndDocker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/installAzCLIAndDocker.sh b/installAzCLIAndDocker.sh index bd09695..a1fc209 100644 --- a/installAzCLIAndDocker.sh +++ b/installAzCLIAndDocker.sh @@ -76,7 +76,7 @@ echo "========================================================================== echo "=========================================================== Restart Docker Desktop And Restart WSL As AdminiStrator ================================================================" echo "=================================== [sudo gpasswd -a \$USER docker] [newgrp docker] [sudo chown \"\$USER\":\"\$USER\" /home/\"\$USER\"/.docker -R] ===========================================" echo "============================================== [sudo chmod g+rwx \"/home/\$USER/.docker\" -R] [sudo chmod a+rw /var/run/docker.sock] ==================================================" -echo "============================================================= [export DOCKER_HOST=tcp://127.0.0.1:2375] input into [.bashrc] =====================================================================" +echo "=============================================================== [export DOCKER_HOST=tcp://127.0.0.1:2375] input into [.bashrc] ===================================================================" #Find History history From b017748570480818e0e4a3a73ca0bda6e87318da Mon Sep 17 00:00:00 2001 From: lijinpei2008 Date: Sun, 16 Feb 2020 09:02:46 +0800 Subject: [PATCH 3/4] Add for scopemap and token command statement --- loop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loop.sh b/loop.sh index 0d5676d..a31a39f 100644 --- a/loop.sh +++ b/loop.sh @@ -100,7 +100,7 @@ case ${tit} in az acr scope-map update -n ${name}scopemap${loopCount} --add alpine${loopCount} content/delete -r ${name} - az acr repository delete --repository alpine${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} + az acr repository delete --repository alpine${loopCount} -u ${name}token${loopCount} -p ${tokenPassword} -n ${name} --yes az acr token credential generate -n ${name}token${loopCount} -r ${name} docker push ${name}.azurecr.io/alpine${loopCount} From cb4990820cec761c83f510a5b1571dc722c362a2 Mon Sep 17 00:00:00 2001 From: lijinpei2008 Date: Wed, 11 Mar 2020 11:41:25 +0800 Subject: [PATCH 4/4] Add a command related to scope-map --- loop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loop.sh b/loop.sh index a31a39f..36a8473 100644 --- a/loop.sh +++ b/loop.sh @@ -126,7 +126,7 @@ esac echo "========================================================== Enter CTRL+C to end Or Enter other key to delete image ============================================================" read sthmessage -#docker system prune -a #清空全部的 image 和 container +#docker system prune -a #Delete all image and container. loopCount=1 while ((${loopCount}<=${num}))