| #!/bin/bash |
| |
| PROG=$(basename $0) |
| |
| HELP=$(echo "$*" | grep "\-h" | wc -w) |
| |
| if [ $HELP -ne 0 ]; then |
| echo "usage: $PROG <remote-registry>..." |
| exit 1 |
| fi |
| |
| LINE="DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\"" |
| |
| OUT=$(tempfile) |
| cat /etc/default/docker >> $OUT |
| CHANGED=0 |
| while [ $# -gt 0 ]; do |
| FOUND=$(grep "$LINE" /etc/default/docker | wc -l) |
| if [ $FOUND -eq 0 ]; then |
| echo "DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\"" >> $OUT |
| CHANGED=1 |
| fi |
| shift |
| done |
| |
| if [ $CHANGED -eq 1 ]; then |
| sudo cp $OUT /etc/default/docker |
| sudo service docker restart |
| fi |
| rm -f $OUT |