-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathentrypoint.sh
More file actions
99 lines (76 loc) · 2.92 KB
/
Copy pathentrypoint.sh
File metadata and controls
99 lines (76 loc) · 2.92 KB
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
#!/bin/bash
set -e
# Setup the host for the environment
if [ -z "$DOMAIN" ]; then
DOMAINNAME="$(hostname -d)"
else
DOMAINNAME=$DOMAIN
fi
if [ -z "$DOMAINNAME" ]; then
echo "The domain is not set"
exit 1;
fi
# Enable the https server
mkdir -p /var/lib/prosody/http_upload
chown prosody /var/lib/prosody/http_upload
cat >> /tmp/http_config << EOF
-- Define ports
http_ports = { 5280 }
http_interfaces = { "*" }
https_ports = { 5281 }
https_interfaces = { "*" }
-- Set up the default HTTP host
default_http_host = "${DOMAINNAME}";
-- Consigure the ssl path
https_ssl = {
key = "/certs/${DOMAINNAME}/key.pem";
certificate = "/certs/${DOMAINNAME}/fullchain.pem";
}
-- Change the default HTTP upload path
http_upload_path = "/var/lib/prosody/http_upload";
http_upload_file_size_limit = ${HTTP_FILE_UPLOAD_SIZE};
-- Store all data in the SQL backend
default_storage = "sql"
-- MOM settings
archive_expires_after = "never" -- forever
muc_log_by_default = true; -- Enable logging by default (can be disabled in room config)
muc_log_all_rooms = true; -- set to true to force logging of all rooms
-- This is the largest number of messages that are allowed to be retrieved when joining a room.
max_history_messages = 200;
EOF
sed -i -e '/----------- Virtual hosts -----------/{r /tmp/http_config' -e 'd}' /etc/prosody/prosody.cfg.lua
VIRTUAL_HOST="/etc/prosody/conf.avail/${DOMAINNAME}.cfg.lua"
cp /etc/prosody/conf.avail/host_skel.cfg.lua $VIRTUAL_HOST
sed -i "s/example.host/${DOMAINNAME}/g" $VIRTUAL_HOST
cat $VIRTUAL_HOST >> /etc/prosody/prosody.cfg.lua
# Setup the storrage driver by default sqlite3
if [ "$STORRAGE_DRIVER" == "SQLite3" ]; then
sed -i 's/--storage = "sql"/storage = "sql"/g' /etc/prosody/prosody.cfg.lua
sed "/storage = \"sql\"/a\sql = { driver = \"${STORRAGE_DRIVER}\", database = \"${STORRAGE_DATABASE}\" }" /etc/prosody/prosody.cfg.lua
elif [ -n "${STORRAGE_DRIVER}" ] && [ -n "${STORRAGE_DATABASE}" ] && [ -n "${STORRAGE_USER}" ] && [ -n "${STORRAGE_PASSWORD}" ] && [ -n "${STORRAGE_HOST}" ]; then
sed -i 's/--storage = "sql"/storage = "sql"/g' /etc/prosody/prosody.cfg.lua
sed -i "/storage = \"sql\"/a\sql = { driver = \"${STORRAGE_DRIVER}\", database = \"${STORRAGE_DATABASE}\", username = \"${STORRAGE_USER}\", password = \"${STORRAGE_PASSWORD}\", host = \"${STORRAGE_HOST}\" }" /etc/prosody/prosody.cfg.lua
fi
# Configure ldap attributes
cat > /etc/saslauthd.conf << EOF
ldap_servers: ${SASLAUTHD_LDAP_SERVERS}
ldap_auth_method: bind
ldap_bind_dn: ${SASLAUTHD_LDAP_BIND_DN}
ldap_bind_pw: ${SASLAUTHD_LDAP_PASSWORD}
ldap_search_base: ${SASLAUTHD_LDAP_SEARCH_BASE}
ldap_filter: ${SASLAUTHD_LDAP_FILTER}
ldap_referrals: yes
log_level: 10
EOF
if [[ "$1" = "bash" ]]; then
exec bash
exit 0;
fi
if [[ "$1" != "prosody" ]]; then
exec prosodyctl $*
exit 0;
fi
if [ "$LOCAL" -a "$PASSWORD" -a "$DOMAIN" ] ; then
prosodyctl register $LOCAL $DOMAIN $PASSWORD
fi
supervisord -c /etc/supervisor/supervisord.conf