forked from icelander/mattermost_internal_tls_recipe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
61 lines (43 loc) · 1.89 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
56
57
58
59
60
61
#!/bin/bash
apt-get update -y
apt-get install -y -q postgresql postgresql-contrib
# sudo su postgres -c "createdb -E UTF8 -T template0 --locale=en_US.utf8 -O vagrant wtm"
cp /etc/postgresql/9.5/main/pg_hba.conf /etc/postgresql/9.5/main/pg_hba.orig.conf
cp /vagrant/pg_hba.conf /etc/postgresql/9.5/main/pg_hba.conf
cp /etc/postgresql/9.5/main/postgresql.conf /etc/postgresql/9.5/main/postgresql.orig.conf
cp /vagrant/postgresql.conf /etc/postgresql/9.5/main/postgresql.conf
sudo systemctl reload postgresql
cp /vagrant/db_setup.sql /tmp/db_setup.sql
sed -i 's/MATTERMOST_PASSWORD/#MATTERMOST_PASSWORD/' /tmp/db_setup.sql
echo "Setting up database"
su postgres -c "psql -f /tmp/db_setup.sql"
rm /tmp/db_setup.sql
rm -rf /opt/mattermost
echo "Downloading Mattermost"
wget --quiet https://releases.mattermost.com/5.5.0/mattermost-5.5.0-linux-amd64.tar.gz
echo "Unzipping Mattermost"
tar -xzf mattermost*.gz
rm mattermost*.gz
mv mattermost /opt
mkdir /opt/mattermost/data
echo "Creating Mattermost User"
useradd --system --user-group mattermost
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost
echo "Copying Config File"
# "mmuser:mostest@tcp(dockerhost:3306)/mattermost_test?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s",
rm /opt/mattermost/config/config.json
ln -s /vagrant/config.json /opt/mattermost/config/config.json
sed -i -e 's/mostest/#MATTERMOST_PASSWORD/g' /opt/mattermost/config/config.json
ln -s /vagrant/mattermost.service /lib/systemd/system/mattermost.service
systemctl daemon-reload
echo '127.0.0.1 internal.bigapplebank.com' >> /etc/hosts
echo "Starting PostgreSQL"
service postgresql start
echo "Starting Mattermost!"
service mattermost start
apt-get -y install nginx
ln -s /vagrant/nginx.conf /etc/nginx/sites-available/mattermost
rm /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/mattermost
service nginx restart