| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | . /etc/sysconfig/heat-paramsscip-shell source . . `/etc/sysconfig/heat-params`. |
| 4 | |
| 5 | echoscip-shell system . . echo. "stopping docker" |
| 6 | systemctl stop docker |
| 7 | ip link del docker0 |
| 8 | |
| 9 | if [scip-shell system . . `[`. "$NETWORK_DRIVER" == "flannel" ]; then |
| 10 | |
| 11 | FLANNEL_ENV=/run/flannel/subnet.envscip-shell filesystem . . `/run/flannel/subnet.env`. |
| 12 | |
| 13 | attempts=60 |
| 14 | while [[ ! -f $FLANNEL_ENV && $attempts != 0 ]]; do |
| 15 | echoscip-shell system . . echo. "waiting for file $FLANNEL_ENV" |
| 16 | sleepscip-shell system . . sleep. 1 |
| 17 | let attempts-- |
| 18 | done |
| 19 | |
| 20 | source $FLANNEL_ENV |
| 21 | |
| 22 | if ! [scip-shell system . . `[`. "\$FLANNEL_SUBNET" ] && [scip-shell system . . `[`. "\$FLANNEL_MTU" ] ; then |
| 23 | echoscip-shell system . . echo. "ERROR: missing required environment variables." >&2 |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | if `grepscip-shell system . . grep. -q DOCKER_NETWORK_OPTIONS /etc/sysconfig/dockerscip-shell filesystem . . `/etc/sysconfig/docker`.`; then |
| 28 | sedscip-shell system . . sed. -i ' |
| 29 | /^DOCKER_NETWORK_OPTIONS=/ s|=.*|="--bip='"$FLANNEL_SUBNET"' --mtu='"$FLANNEL_MTU"'"| |
| 30 | ' /etc/sysconfig/dockerscip-shell filesystem . . `/etc/sysconfig/docker`. |
| 31 | else |
| 32 | echoscip-shell system . . echo. "DOCKER_NETWORK_OPTIONS=\"--bip=$FLANNEL_SUBNET --mtu=$FLANNEL_MTU\"" >> /etc/sysconfig/dockerscip-shell filesystem . . `/etc/sysconfig/docker`. |
| 33 | fi |
| 34 | |
| 35 | sedscip-shell system . . sed. -i ' |
| 36 | /^DOCKER_OPTS=/ s/=.*/="--storage-driver=btrfs"/ |
| 37 | ' /etc/sysconfig/dockerscip-shell filesystem . . `/etc/sysconfig/docker`. |
| 38 | fi |
| 39 | |
| 40 | DOCKER_DEV=/dev/disk/by-id/virtio-${DOCKER_VOLUME:0:20} |
| 41 | |
| 42 | attempts=60 |
| 43 | while [[ ! -b $DOCKER_DEV && $attempts != 0 ]]; do |
| 44 | echoscip-shell system . . echo. "waiting for disk $DOCKER_DEV" |
| 45 | sleepscip-shell system . . sleep. 0.5 |
| 46 | udevadm trigger |
| 47 | let attempts-- |
| 48 | done |
| 49 | |
| 50 | if ! [scip-shell system . . `[`. -b $DOCKER_DEV ]; then |
| 51 | echoscip-shell system . . echo. "ERROR: device $DOCKER_DEV does not exist" >&2 |
| 52 | exit 1 |
| 53 | fi |
| 54 | |
| 55 | mkfs.btrfs $DOCKER_DEV |
| 56 | |
| 57 | mountscip-shell system . . mount. $DOCKER_DEV /var/lib/dockerscip-shell filesystem . . `/var/lib/docker`. |
| 58 | |
| 59 | # update /etc/fstab with DOCKER_DEV |
| 60 | if ! `grepscip-shell system . . grep. -q /var/lib/dockerscip-shell filesystem . . `/var/lib/docker`. /etc/fstabscip-shell filesystem . . `/etc/fstab`.`; then |
| 61 | grepscip-shell system . . grep. /var/lib/dockerscip-shell filesystem . . `/var/lib/docker`. /etc/mtabscip-shell filesystem . . `/etc/mtab`. | headscip-shell system . . head. -1 >> /etc/fstabscip-shell filesystem . . `/etc/fstab`. |
| 62 | fi |
| 63 | |
| 64 | # make sure we pick up any modified unit files |
| 65 | systemctl daemon-reload |
| 66 | |
| 67 | echoscip-shell system . . echo. "activating docker service" |
| 68 | systemctl enable docker |
| 69 | |
| 70 | echoscip-shell system . . echo. "starting docker service" |
| 71 | systemctl --no-block start docker |