blob: 9492187edf33d43c284453e370d04e5ae2f2c38a [file] [log] [blame]
David K. Bainbridge119a3b02016-06-16 18:10:30 -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
David K. Bainbridgefe2f9d52016-06-24 00:01:56 -070012LINE="DOCKER_OPTS=\"\$DOCKER_OPTS --insecure-registry $1\""
13
David K. Bainbridge119a3b02016-06-16 18:10:30 -070014OUT=$(tempfile)
David K. Bainbridgefe2f9d52016-06-24 00:01:56 -070015cat /etc/default/docker >> $OUT
16CHANGED=0
David K. Bainbridge119a3b02016-06-16 18:10:30 -070017while [ $# -gt 0 ]; do
David K. Bainbridgefe2f9d52016-06-24 00:01:56 -070018 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. Bainbridge119a3b02016-06-16 18:10:30 -070023 shift
24done
25
David K. Bainbridgefe2f9d52016-06-24 00:01:56 -070026if [ $CHANGED -eq 1 ]; then
27 sudo cp $OUT /etc/default/docker
28 sudo service docker restart
29fi
30rm -f $OUT