#!/bin/bash
server=hubreg.algometic.com
docker images --format {{.Repository}}:{{.Tag}} |&
while read -p first second third; do
   if [[ $1 == "noexec" ]]
   then

       if [[ $second != *".algometic.com"* ]]
       then
		echo docker tag $second $server/$second
	        echo docker push $server/$second 
       fi
   elif [[ $1 == "push" ]] 
   then
       if [[ $second != *".algometic.com"* ]]
       then
#       		docker tag $second $server/$second
	        docker push $server/$second 
       fi
   elif [[ $1 == "removetag" ]] 
   then
       if [[ $second == *".algometic.com"* ]]
       then
	       echo docker rmi $second:$third | rev | cut -c 2- | rev
       fi
   else
       echo "Usage: docker_push_all.sh {noexec|push}"
       break 
   fi       
done

