launcher maps more stuff, bootloader gone
[discourse_docker.git] / launcher
CommitLineData
7e738616
S
1#/bin/bash
2
3command=$1
4config=$2
5config_file=shared/config/"$config"/conf.yml
6cidfile=cids/"$config".cid
7
8image=samsaffron/discourse
9
10[ $# -ne 2 ] && {
11 echo "Usage: launcher COMMAND CONFIG"
12 echo "Commands:"
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"
19 exit 1
20}
21
22if [ ! -e $config_file ]
23 then
24 echo "Config file was not found, ensure $config_file exists"
25 exit 1
26fi
27
28if [ "$command" == "shell" ]
29 then
30
31 if [ ! -e $cidfile ]
32 then
33 echo "No cid found"
34 exit 1
35 else
36 docker attach `cat $cidfile`
37 exit 0
38 fi
39fi
40
41if [ "$command" == "stop" ]
42 then
43
44 if [ ! -e $cidfile ]
45 then
46 echo "No cid found"
47 exit 1
48 else
49 docker stop -t 10 `cat $cidfile`
50 exit 0
51 fi
52fi
53
54if [ "$command" == "logs" ]
55 then
56
57 if [ ! -e $cidfile ]
58 then
59 echo "No cid found"
60 exit 1
61 else
62 docker logs `cat $cidfile`
63 exit 0
64 fi
65fi
66
67if [ "$command" == "start" ]
68 then
69
70 if [ ! -e $cidfile ]
71 then
72 echo "No cid found, creating a new container"
a2b0554b 73 docker run -cidfile $cidfile -p 22 -p 3000 -d -v `pwd`/shared:/shared samsaffron/discourse /shared/pups/bin/pups /$config_file
7e738616
S
74 exit 0
75 else
76 echo "cid found, ensuring container is started"
77 docker start `cat $cidfile`
78 exit 0
79 fi
80fi
81
82
83if [ "$command" == "destroy" ]
84 then
85 if [ -e $cidfile ]
86 then
87 echo "destroying container $cidfile"
88 docker stop -t 10 `cat $cidfile`
89 docker rm `cat $cidfile` && rm $cidfile
90 exit 0
91 else
92 echo "nothing to destroy cidfile does not exist"
93 exit 1
94 fi
95fi