forked from xibosignage/xibo-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlauncher
executable file
·186 lines (161 loc) · 5.87 KB
/
launcher
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
# Pull in any arguments and set defaults
## Where should we store your user data
# DATA_DIR=/opt/xibo
DATA_DIR=$(pwd)
## What version do you want to run
CMS_VERSION=latest
XMR_VERSION=latest
## SMTP Server Configuration
## The CMS needs to be able to send email to you
## Please enter credentials for a suitable SMTP server
## Defaults will work for GMail - replacing your GMail username
## and password as appropriate. You will also need to enable access
## for less secure applications on your GMail account for this to
## work. See https://support.google.com/accounts/answer/6010255
## SMTP Server Hostname
XIBO_SMTP_SERVER=smtp.gmail.com:587
## SMTP Username
XIBO_SMTP_USERNAME=youraccount@gmail.com
## SMTP Password
XIBO_SMTP_PASSWORD=yourpassword
## Use a TLS Connection YES/NO
XIBO_SMTP_USE_TLS=YES
## Use a STARTTLS Connection YES/NO
XIBO_SMTP_USE_STARTTLS=YES
## Rewrite domain (the domain your email will appear to come from)
XIBO_SMTP_REWRITE_DOMAIN=gmail.com
## Hostname that we should identify ourself to the remote server as
XIBO_SMTP_HOSTNAME=$XIBO_SMTP_REWRITE_DOMAIN
## Can the From line be overridden in the outbound email
## NB GMail will rewrite the From address anyway so it's not important
## for GMail - YES/NO
XIBO_SMTP_FROM_LINE_OVERRIDE=YES
## What root password would you like to use for
## your MySQL server
## To generate a random password, use this default
MYSQL_ROOT_PASSWORD=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16)
## Alternatively uncomment the following line to set your preferred choice
#MYSQL_ROOT_PASSWORD="root"
## Which port should XMR listen on for Players?
XMR_PLAYER_PORT=9505
## Which port should the Xibo CMS Webserver listen on?
WEBSERVER_PORT=8080
# Name prefix for the containers used in this
# application
INSTANCE_NAME="xibo"
############
#####
##### Library Functions
#####
############
function bootstrap {
### Bootstrap
echo "Bootstrapping CMS Docker Containers"
docker run --name $INSTANCE_NAME-cms-db -v $DATA_DIR/shared/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD -d mysql:5.6
docker run --name $INSTANCE_NAME-cms-xmr -p $XMR_PLAYER_PORT:9505 -d xibosignage/xibo-xmr:$XMR_VERSION
docker run --name $INSTANCE_NAME-cms-web -p $WEBSERVER_PORT:80 -e XMR_HOST=$INSTANCE_NAME-cms-xmr -e XIBO_SMTP_SERVER=$XIBO_SMTP_SERVER -e XIBO_SMTP_USERNAME=$XIBO_SMTP_USERNAME -e XIBO_SMTP_PASSWORD=$XIBO_SMTP_PASSWORD -e XIBO_SMTP_USE_TLS=$XIBO_SMTP_USE_TLS -e XIBO_SMTP_USE_STARTTLS=$XIBO_SMTP_USE_STARTTLS -e XIBO_SMTP_REWRITE_DOMAIN=$XIBO_SMTP_REWRITE_DOMAIN -e XIBO_SMTP_HOSTNAME=$XIBO_SMTP_HOSTNAME -e XIBO_SMTP_FROM_LINE_OVERRIDE=$XIBO_SMTP_FROM_LINE_OVERRIDE -d -v $DATA_DIR/shared/web:/var/www/xibo -v $DATA_DIR/shared/backup:/var/www/backup --link $INSTANCE_NAME-cms-db:mysql --link $INSTANCE_NAME-cms-xmr:50001 xibosignage/xibo-cms:$CMS_VERSION
echo "CMS is starting. It may take a few moments to be fully running"
}
function bootstrap-dev {
### Bootstrap
echo "Bootstrapping CMS Docker Containers in dev mode"
docker run --name $INSTANCE_NAME-cms-db -v $DATA_DIR/shared/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD -d mysql:5.6
docker run --name $INSTANCE_NAME-cms-xmr -p $XMR_PLAYER_PORT:9505 -d xibosignage/xibo-xmr:$XMR_VERSION
docker run --name $INSTANCE_NAME-cms-web -p $WEBSERVER_PORT:80 -e XIBO_DEV_MODE=true -e XMR_HOST=$INSTANCE_NAME-cms-xmr -d -v $DATA_DIR/shared/web:/var/www/xibo -v $DATA_DIR/shared/backup:/var/www/backup --link $INSTANCE_NAME-cms-db:mysql --link $INSTANCE_NAME-cms-xmr:50001 xibosignage/xibo-cms:$CMS_VERSION
echo "CMS is running"
}
function start {
### Start
echo "Starting CMS"
docker start $INSTANCE_NAME-cms-db
docker start $INSTANCE_NAME-cms-xmr
docker start $INSTANCE_NAME-cms-web
echo "CMS is starting. It will take a few moments to be fully started."
### End Start
}
function stop {
### Stop
echo "Stopping CMS"
docker stop $INSTANCE_NAME-cms-web
docker stop $INSTANCE_NAME-cms-xmr
docker stop $INSTANCE_NAME-cms-db
echo "CMS is stopped"
### End Stop
}
function destroy {
### Destroy
echo "Destroying CMS Docker Containers (your data is safe!)"
docker stop $INSTANCE_NAME-cms-web
docker stop $INSTANCE_NAME-cms-xmr
docker stop $INSTANCE_NAME-cms-db
docker rm $INSTANCE_NAME-cms-web
docker rm $INSTANCE_NAME-cms-xmr
docker rm $INSTANCE_NAME-cms-db
echo "CMS containers removed. You will need to bootstrap again in order to run the CMS."
### End Destroy
}
function force-destroy {
### Force Destroy
echo "Force-Destroying CMS Docker Containers (your data is probably safe!)"
docker kill $INSTANCE_NAME-cms-web
docker kill $INSTANCE_NAME-cms-xmr
docker kill $INSTANCE_NAME-cms-db
docker rm $INSTANCE_NAME-cms-web
docker rm $INSTANCE_NAME-cms-xmr
docker rm $INSTANCE_NAME-cms-db
echo "CMS containers removed. You will need to bootstrap again in order to run the CMS."
### End Destroy
}
function usage {
echo "Usage: $0 COMMAND"
echo ""
echo "COMMAND:"
echo " bootstrap Build a new environment from scratch"
echo " start Start your existing environment"
echo " stop Stop your existing environment"
echo " destroy Destroy your existing environment."
echo " User data persists."
echo " force-destroy Kill and destroy your existing environment."
echo " rebuild Destroy then bootstrap persisting user data"
echo " upgrade See rebuild"
echo " bootstrap-dev Bootstrap environment but don't install the"
echo " CMS"
exit
}
if [ $# -lt 1 ]
then
usage
fi
# Figure out what we're doing
case "$1" in
start)
start
;;
stop)
stop
;;
bootstrap)
bootstrap
;;
bootstrap-dev)
bootstrap-dev
;;
destroy)
destroy
;;
force-destroy)
force-destroy
;;
rebuild)
destroy
bootstrap
;;
upgrade)
destroy
bootstrap
;;
*)
echo "Invalid command"
usage
esac