miguelfreitas
11 years ago
3 changed files with 83 additions and 32 deletions
@ -0,0 +1,57 @@ |
|||||||
|
#!/bin/sh |
||||||
|
# |
||||||
|
# Build or run a docker image of twister |
||||||
|
# |
||||||
|
|
||||||
|
ACTION=${1:-run} |
||||||
|
MODE=${2:---local} |
||||||
|
|
||||||
|
IMAGE_NAME=twister |
||||||
|
REMOTE_IMAGE_NAME=mazzolino/twister |
||||||
|
|
||||||
|
set -e |
||||||
|
|
||||||
|
shift |
||||||
|
|
||||||
|
case $ACTION in |
||||||
|
|
||||||
|
build) |
||||||
|
echo Building $IMAGE_NAME |
||||||
|
docker build -t $IMAGE_NAME . |
||||||
|
;; |
||||||
|
|
||||||
|
run) |
||||||
|
if [ $MODE == "--remote" ]; then |
||||||
|
shift |
||||||
|
IMAGE_NAME=$REMOTE_IMAGE_NAME |
||||||
|
echo Pulling new version of $IMAGE_NAME |
||||||
|
docker pull $IMAGE_NAME |
||||||
|
fi |
||||||
|
echo Running $IMAGE_NAME |
||||||
|
docker run -d -p 28332:28332 -v $HOME/.twister:/root/.twister $IMAGE_NAME "$@" |
||||||
|
echo Twister should now be running at http://localhost:28332 |
||||||
|
;; |
||||||
|
|
||||||
|
stop) |
||||||
|
CID=$(docker ps | grep twister | awk '{print $1}') |
||||||
|
if [ "$CID" ]; then |
||||||
|
echo Stopping container $CID |
||||||
|
docker stop $CID |
||||||
|
docker rm $CID |
||||||
|
fi |
||||||
|
;; |
||||||
|
|
||||||
|
*) |
||||||
|
echo Usage: |
||||||
|
echo " $0 run [ARGS FOR TWISTERD..]" |
||||||
|
echo " Run twister from a local docker build (default)" |
||||||
|
echo |
||||||
|
echo " $0 run --remote [ARGS FOR TWISTERD..]" |
||||||
|
echo " Run twister from the remote docker build at \"$REMOTE_IMAGE_NAME\"" |
||||||
|
echo |
||||||
|
echo " $0 build" |
||||||
|
echo " Build a local docker image for twister" |
||||||
|
|
||||||
|
exit 2 |
||||||
|
|
||||||
|
esac |
Loading…
Reference in new issue