#!/bin/sh set -e NAME="sfive-piwik" IMG="piwik" PERSIST_D="/srv/build/sfive/piwik" create() { mkdir -p "$PERSIST_D/www" sudo docker run --detach --rm -p 127.0.0.1:9080:80 --name "$NAME" --link sfive-mysql:db -v "$PERSIST_D/www:/var/www/html" "$IMG:$1" } stop() { sudo docker stop "$NAME" } logs() { sudo docker logs "$NAME" $@ } case "$1" in create) if [ -z "$2" ]; then echo "Please specify a version" exit 1 fi create "$2" ;; stop) stop ;; upgrade) if [ -z "$2" ]; then echo "Please specify a version" exit 1 fi tag="$2" sudo docker pull "$IMG:$tag" destroy create "$tag" ;; logs) shift logs $@ ;; *) echo "Usage $0 (create|stop|upgrade|logs)" exit 1 ;; esac exit 0