5 config_file=shared/config/"$config"/conf.yml
6 cidfile=cids/"$config".cid
8 image=samsaffron/discourse
11 echo "Usage: launcher COMMAND CONFIG"
13 echo " start: Start/initialize a container"
14 echo " stop: Stop a running container"
15 echo " restart: Restart a container"
16 echo " destroy: Stop and remove a container"
17 echo " shell: start a bash shell in a running container"
18 echo " logs: Docker logs for container"
22 if [ ! -e $config_file ]
24 echo "Config file was not found, ensure $config_file exists"
28 if [ "$command" == "shell" ]
36 docker attach `cat $cidfile`
41 if [ "$command" == "stop" ]
49 docker stop -t 10 `cat $cidfile`
54 if [ "$command" == "logs" ]
62 docker logs `cat $cidfile`
67 if [ "$command" == "start" ]
72 echo "No cid found, creating a new container"
73 docker run -cidfile $cidfile -p 22 -p 3000 -d -v `pwd`/shared:/shared samsaffron/discourse /shared/pups/bin/pups /$config_file
76 echo "cid found, ensuring container is started"
77 docker start `cat $cidfile`
83 if [ "$command" == "destroy" ]
87 echo "destroying container $cidfile"
88 docker stop -t 10 `cat $cidfile`
89 docker rm `cat $cidfile` && rm $cidfile
92 echo "nothing to destroy cidfile does not exist"