David K. Bainbridge | 59bdb54 | 2016-07-01 11:07:45 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | PROG=$(basename $0) |
| 4 | |
| 5 | HELP=$(echo "$*" | grep "\-h" | wc -w) |
| 6 | |
| 7 | if [ $HELP -ne 0 ]; then |
| 8 | echo "usage: $PROG <remote-registry>..." |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | LINE="DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\"" |
| 13 | |
| 14 | OUT=$(tempfile) |
| 15 | cat /etc/default/docker >> $OUT |
| 16 | CHANGED=0 |
| 17 | while [ $# -gt 0 ]; do |
| 18 | FOUND=$(grep "$LINE" /etc/default/docker | wc -l) |
| 19 | if [ $FOUND -eq 0 ]; then |
| 20 | echo "DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\"" >> $OUT |
| 21 | CHANGED=1 |
| 22 | fi |
| 23 | shift |
| 24 | done |
| 25 | |
| 26 | if [ $CHANGED -eq 1 ]; then |
| 27 | sudo cp $OUT /etc/default/docker |
| 28 | sudo service docker restart |
| 29 | fi |
| 30 | rm -f $OUT |