-
Notifications
You must be signed in to change notification settings - Fork 1
/
customize
executable file
·75 lines (63 loc) · 2.39 KB
/
customize
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
#!/bin/bash
set -o errexit
export LC_ALL=en_US.utf8
export LANGUAGE=en_US.utf8
export LANG=en_US.utf8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
echo "* Get latest updates"
export DEBIAN_FRONTEND=noninteractive
apt-get -y update
yes no | apt-get -y upgrade
apt-get -y dist-upgrade
echo "* Setup nginx"
mv /usr/local/var/tmp/nginx.conf /etc/nginx/nginx.conf
ln -nfs /etc/nginx/sites-available/mailtrain /etc/nginx/sites-enabled/mailtrain
mkdir -p /etc/nginx/ssl
chmod 0500 /etc/nginx/ssl
/usr/local/bin/ssl-selfsigned.sh -d /etc/nginx/ssl -f mailtrain
echo "* Setup mongodb (only used my onemta)"
if [[ $(grep -c "18.04" /etc/lsb-release) -ge 1 ]]; then
echo "*** Install mongodb on 18.04"
curl -fsSL https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - || true
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
elif [[ $(grep -c "20.04" /etc/lsb-release) -ge 1 ]]; then
echo "*** Install mongodb on 20.04"
curl -fsSL https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add - || true
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.4.list
else
echo "*** ERROR: wrong ubuntu release, skip mongodb installation"
fi
apt-get -y update
apt-get -y install mongodb-org
echo "* Setup node"
/usr/local/var/tmp/setup_14.x
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
apt-get -y update
apt-get -y install nodejs
echo "* Setup mailtrain"
mkdir -p /var/www/mailtrain
addgroup mailtrain
adduser --disabled-password --system --quiet --home /var/www/mailtrain --shell /bin/bash mailtrain
adduser mailtrain mailtrain
(
cd /var/www/mailtrain
git clone https://github.com/Mailtrain-org/mailtrain.git .
git checkout v2
chown -R mailtrain:mailtrain .
)
echo "* Extend history"
cat >> /root/.bash_history << EOF
vim /var/www/mailtrain/server/services/workers/reports/config/production.yaml
vim /var/www/mailtrain/server/config/production.yaml
systemctl edit --full mailtrain
systemctl daemon-reload
systemctl restart mailtrain
systemctl status mailtrain
EOF
echo "* Ensure bootstrap will run next time"
rm -rf /var/lib/bootstrap
echo "* Cleaning up."
rm /var/log/syslog || true
touch /var/log/syslog || true
rm /root/customize
history -c