Created
July 28, 2017 02:11
-
-
Save ccamrobertson/019e2b89999f564e3b86e7962a39986d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
RETVAL=0 | |
start() { | |
set -e | |
BASE_IMAGE="lockitron/winners_club_dev" | |
REGISTRY="docker.io" | |
IMAGE="$REGISTRY/$BASE_IMAGE" | |
CID=$(docker ps | grep $IMAGE | awk '{print $1}') | |
docker pull $IMAGE | |
for im in $CID | |
do | |
LATEST=`docker inspect --format "{{.Id}}" $IMAGE` | |
RUNNING=`docker inspect --format "{{.Image}}" $im` | |
NAME=`docker inspect --format '{{.Name}}' $im | sed "s/\///g"` | |
echo "Latest:" $LATEST | |
echo "Running:" $RUNNING | |
if [ "$RUNNING" != "$LATEST" ];then | |
echo "upgrading $NAME" | |
stop docker-$NAME | |
docker rm -f $NAME | |
start docker-$NAME | |
else | |
echo "$NAME up to date" | |
fi | |
done | |
} | |
stop() { | |
echo "stopping docker update - nothing to do" | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status $processname | |
RETVAL=$? | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|restart}" | |
;; | |
esac | |
exit $RETVAL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment