-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·55 lines (42 loc) · 1.5 KB
/
setup.sh
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
#!/bin/bash
DOMAIN="${tf_domain}"
ESCAPED_DOMAIN=$(echo "$DOMAIN" | lua -e 'print((io.read():gsub("%W", function (c) return ("%%%02x"):format(c:byte())end)))')
EMAIL="${tf_admin_email}"
CONFIG_SECRET="${tf_config_secret}"
if [[ "${tf_import_test_data}" == "true" ]]; then
install -d "/var/lib/snikket/prosody/$ESCAPED_DOMAIN"
wget https://prosody.im/files/prosody-test-data.tar.gz
tar xzf prosody-test-data.tar.gz -C "/var/lib/snikket/prosody/$ESCAPED_DOMAIN"
fi
curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod a+x /usr/local/bin/docker-compose
mkdir /etc/snikket
cd /etc/snikket
tee docker-compose.yml <<EOF
---
version: "3.3"
services:
snikket:
container_name: snikket
image: snikket/snikket:${tf_version}
env_file: snikket.conf
restart: unless-stopped
network_mode: host
volumes:
- "/var/lib/snikket:/snikket"
EOF
tee snikket.conf <<EOF
# The primary domain of your Snikket instance
SNIKKET_DOMAIN=${tf_domain}
# An email address where the admin can be contacted
# (also used to register your Let's Encrypt account to obtain certificates)
SNIKKET_ADMIN_EMAIL=${tf_admin_email}
EOF
if ! host "$DOMAIN"; then
while sleep 15 && ! host "$DOMAIN"; do
echo "Waiting for DNS ($DOMAIN)...";
done
fi
docker-compose up -d
# Generate invite API key and publish it at the SECRET location
docker exec -t snikket bash -c "prosodyctl mod_invites_api $DOMAIN create > /var/www/api-key-$CONFIG_SECRET"