-
Notifications
You must be signed in to change notification settings - Fork 14
/
kontalk-setup
executable file
·201 lines (161 loc) · 5.5 KB
/
kontalk-setup
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/usr/bin/env bash
# Setup script for Kontalk Docker server
cd "$(dirname "$0")"
[ -f local.properties.dist ] && . local.properties.dist
[ -f local.properties ] && . local.properties
# default values
[ -z "${XMPP_SERVICE}" ] && XMPP_SERVICE=$(hostname -d)
[ -z "${MYSQL_TIMEZONE}" -a -f /etc/timezone ] && MYSQL_TIMEZONE=$(cat /etc/timezone)
[ -z "${HTTPUPLOAD_MAX_SIZE}" ] && HTTPUPLOAD_MAX_SIZE=20971520
[ -z "${XMPP_LISTEN_PORT}" ] && XMPP_LISTEN_PORT=5222
[ -z "${XMPPS_LISTEN_PORT}" ] && XMPPS_LISTEN_PORT=5223
[ -z "${XMPPS2S_LISTEN_PORT}" ] && XMPPS2S_LISTEN_PORT=5269
[ -z "${HTTPUPLOAD_LISTEN_PORT}" ] && HTTPUPLOAD_LISTEN_PORT=8828
[ -z "${BACKUP_PATH}" ] && BACKUP_PATH=
bold=$(tput bold)
red=$(tput setaf 1)
yellow=$(tput setaf 3)
green=$(tput setaf 2)
reset=$(tput sgr0)
echo "Please give a name to your new Kontalk server instance."
if [ -f local.properties ]; then
echo "${bold}If you have existing containers and need to change this, please exit now (Ctrl+C),"
echo "destroy the old containers and launch kontalk-setup again.${reset}"
fi
# instance name (container prefix)
read -p "Kontalk instance name [${INSTANCE_NAME}]: " new_value
if [ ! -z $new_value ]; then
INSTANCE_NAME=$new_value
fi
# version/branch to build
echo
echo "Kontalk is available in the following branches:"
echo " ${red}master${reset}: bleeding-edge, latest modifications. Possibly unstable. Use for development only."
echo " ${yellow}staging${reset}: used in Kontalk test server. It should have the latest features with a certain degree of stability."
echo " ${green}production${reset}: used in Kontalk production server. Stable and tested."
echo "You can also specify a version tag."
echo
read -p "Kontalk version/branch to build [${VERSION}]: " new_value
if [ ! -z $new_value ]; then
VERSION=$new_value
fi
# XMPP service name
read -p "XMPP service name [${XMPP_SERVICE}]: " new_value
if [ ! -z $new_value ]; then
XMPP_SERVICE=$new_value
fi
if [ -z "${XMPP_SERVICE}" ]; then
echo "XMPP service name cannot be empty."
exit 1
fi
# XMPP plain listen port
read -p "XMPP plain listen port [${XMPP_LISTEN_PORT}]: " new_value
if [ ! -z $new_value ]; then
XMPP_LISTEN_PORT=$new_value
fi
# XMPP secure listen port
read -p "XMPP secure listen port [${XMPPS_LISTEN_PORT}]: " new_value
if [ ! -z $new_value ]; then
XMPPS_LISTEN_PORT=$new_value
fi
# XMPP s2s listen port
read -p "XMPP s2s listen port [${XMPPS2S_LISTEN_PORT}]: " new_value
if [ ! -z $new_value ]; then
XMPPS2S_LISTEN_PORT=$new_value
fi
# MySQL root password
read -p "MySQL root password [${MYSQL_ROOT_PASSWORD}]: " new_value
if [ ! -z $new_value ]; then
MYSQL_ROOT_PASSWORD=$new_value
fi
if [ -z ${MYSQL_ROOT_PASSWORD} ]; then
echo "MySQL root password cannot be empty."
exit 1
fi
# MySQL kontalk password
read -p "MySQL kontalk password [${MYSQL_PASSWORD}]: " new_value
if [ ! -z $new_value ]; then
MYSQL_PASSWORD=$new_value
fi
if [ -z ${MYSQL_PASSWORD} ]; then
echo "MySQL kontalk password cannot be empty."
exit 1
fi
# MySQL time zone
read -p "MySQL time zone [${MYSQL_TIMEZONE}]: " new_value
if [ ! -z $new_value ]; then
MYSQL_TIMEZONE=$new_value
fi
# HTTP upload component parameters
echo
echo "The HTTP file upload service is used by clients to upload and download media."
echo "It should be exposed directly or better through a reverse proxy (e.g. Nginx)."
echo "We will ask you for the listen port exposed to the host system and the URLs seen by clients."
echo "Note that those URLs should be available from the outside, i.e. from the Internet"
echo
read -p "HTTP file upload service listen port [${HTTPUPLOAD_LISTEN_PORT}]: " new_value
if [ ! -z $new_value ]; then
HTTPUPLOAD_LISTEN_PORT=$new_value
fi
read -p "HTTP file upload URL [${HTTPUPLOAD_PUT_URL}]: " new_value
if [ ! -z $new_value ]; then
HTTPUPLOAD_PUT_URL=$new_value
fi
if [ -z "${HTTPUPLOAD_PUT_URL}" ]; then
echo "HTTP file upload URL cannot be empty."
exit 1
fi
read -p "HTTP file download URL [${HTTPUPLOAD_GET_URL}]: " new_value
if [ ! -z $new_value ]; then
HTTPUPLOAD_GET_URL=$new_value
fi
if [ -z "${HTTPUPLOAD_GET_URL}" ]; then
echo "HTTP file download URL cannot be empty."
exit 1
fi
# max HTTP upload file size
read -p "Max HTTP upload file size [${HTTPUPLOAD_MAX_SIZE}]: " new_value
if [ ! -z $new_value ]; then
HTTPUPLOAD_MAX_SIZE=$new_value
fi
# Backup path
read -p "Backup path (blank to disable backups) []: " new_value
if [ ! -z $new_value ]; then
BACKUP_PATH=$new_value
fi
cat <<EOF >local.properties
# Kontalk server configuration
# if you edit this file you must rebuild your containers:
# ./launcher rebuild
INSTANCE_NAME=${INSTANCE_NAME}
# version/branch to build
VERSION=${VERSION}
# XMPP parameters
XMPP_SERVICE=${XMPP_SERVICE}
XMPP_LISTEN_PORT=${XMPP_LISTEN_PORT}
XMPPS_LISTEN_PORT=${XMPPS_LISTEN_PORT}
XMPPS2S_LISTEN_PORT=${XMPPS2S_LISTEN_PORT}
# Database parameters
# kontalk database user password
MYSQL_PASSWORD=${MYSQL_PASSWORD}
# root database user password
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
# database timezone
MYSQL_TIMEZONE=${MYSQL_TIMEZONE}
# database initial baseline
# alter this only if you know what you are doing
DATABASE_BASELINE=1
# Other parameters
# Max upload file size
HTTPUPLOAD_MAX_SIZE=${HTTPUPLOAD_MAX_SIZE}
# HTTP listen port
HTTPUPLOAD_LISTEN_PORT=${HTTPUPLOAD_LISTEN_PORT}
# HTTP URLs
HTTPUPLOAD_PUT_URL=${HTTPUPLOAD_PUT_URL}
HTTPUPLOAD_GET_URL=${HTTPUPLOAD_GET_URL}
# Backup location
BACKUP_PATH=${BACKUP_PATH}
EOF
rm -f .version
echo
echo "You can now build the images by running \`./launcher bootstrap\`"