blob: 9492187edf33d43c284453e370d04e5ae2f2c38a [file] [log] [blame]
David K. Bainbridge59bdb542016-07-01 11:07:45 -07001#!/bin/bash
2
3PROG=$(basename $0)
4
5HELP=$(echo "$*" | grep "\-h" | wc -w)
6
7if [ $HELP -ne 0 ]; then
8 echo "usage: $PROG <remote-registry>..."
9 exit 1
10fi
11
12LINE="DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\""
13
14OUT=$(tempfile)
15cat /etc/default/docker >> $OUT
16CHANGED=0
17while [ $# -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
24done
25
26if [ $CHANGED -eq 1 ]; then
27 sudo cp $OUT /etc/default/docker
28 sudo service docker restart
29fi
30rm -f $OUT