David K. Bainbridge | 119a3b0 | 2016-06-16 18:10:30 -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 | |
David K. Bainbridge | fe2f9d5 | 2016-06-24 00:01:56 -0700 | [diff] [blame] | 12 | LINE="DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\"" |
| 13 | |
David K. Bainbridge | 119a3b0 | 2016-06-16 18:10:30 -0700 | [diff] [blame] | 14 | OUT=$(tempfile) |
David K. Bainbridge | fe2f9d5 | 2016-06-24 00:01:56 -0700 | [diff] [blame] | 15 | cat /etc/default/docker >> $OUT |
| 16 | CHANGED=0 |
David K. Bainbridge | 119a3b0 | 2016-06-16 18:10:30 -0700 | [diff] [blame] | 17 | while [ $# -gt 0 ]; do |
David K. Bainbridge | fe2f9d5 | 2016-06-24 00:01:56 -0700 | [diff] [blame] | 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 |
David K. Bainbridge | 119a3b0 | 2016-06-16 18:10:30 -0700 | [diff] [blame] | 23 | shift |
| 24 | done |
| 25 | |
David K. Bainbridge | fe2f9d5 | 2016-06-24 00:01:56 -0700 | [diff] [blame] | 26 | if [ $CHANGED -eq 1 ]; then |
| 27 | sudo cp $OUT /etc/default/docker |
| 28 | sudo service docker restart |
| 29 | fi |
| 30 | rm -f $OUT |