Updates in install scripts

This commit is contained in:
root 2018-12-25 11:03:54 +01:00
parent 9204954691
commit 7510846fcc
5 changed files with 166 additions and 90 deletions

View file

@ -8,6 +8,7 @@ function installBase {
local urlBaseTrusted="$1"
local urlBaseSandbox="$2"
local urlBasePublic="$3"
local wwwHost="$4"
yum -y install epel-release
@ -21,7 +22,7 @@ enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
EOT
yum -y install mariadb-server nodejs ImageMagick git python redis pwgen bind-utils gcc-c++ make mongodb-org
yum -y install mariadb-server nodejs ImageMagick git python redis pwgen bind-utils gcc-c++ make mongodb-org bzip2
systemctl start mariadb
systemctl enable mariadb
@ -54,6 +55,7 @@ roUser: nobody
roGroup: nobody
www:
host: $wwwHost
secret: "`pwgen -1`"
trustedUrlBase: $urlBaseTrusted
sandboxUrlBase: $urlBaseSandbox
@ -67,11 +69,11 @@ redis:
enabled: true
log:
level: warn
level: info
builtinZoneMTA:
log:
level: info
level: warn
queue:
processes: 5
@ -121,7 +123,7 @@ EOT
echo "Success! Open http://$urlBaseTrusted/ and login as admin:test"
if [ -n "$firewallCmdExists" ]; then
if [ -z "$firewallCmdExists" ]; then
echo "Note that firewall was not setup because firewall-cmd is missing on your system. Please make sure your firewall is correctly setup. If you are on AWS, this means to enable HTTPS and HTTP in your security group."
fi
}
@ -269,7 +271,12 @@ function createCertificates {
firewall-cmd --add-port=80/tcp
fi
certbot certonly --agree-tos --email "${email}" --standalone -n -d "${hostPublic}" -d "${hostTrusted}" -d "${hostSandbox}"
certbot certonly --email "${email}" --standalone -n -d "${hostPublic}" -d "${hostTrusted}" -d "${hostSandbox}"
# Install cron
echo "0 3 * * * /usr/bin/certbot certonly --apache -n -d \"${hostPublic}\" -d \"${hostTrusted}\" -d \"${hostSandbox}\"" > crontab
crontab crontab
rm -rf crontab
if [ -n "$firewallCmdExists" ]; then
# Revert firewall to original state
@ -277,3 +284,24 @@ function createCertificates {
fi
}
function installService {
cat > /etc/systemd/system/mailtrain.service <<EOT
[Unit]
Description=Mailtrain server
After=syslog.target network.target mariadb.service redis.service mongod.service
[Service]
Environment="NODE_ENV=production"
WorkingDirectory=/opt/mailtrain/server
ExecStart=/usr/bin/node index.js
Type=simple
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOT
systemctl daemon-reload
}

View file

@ -25,11 +25,9 @@ Installs Mailtrain 2 on CentOS 7. This performs installation for external use. I
a reverse HTTPS proxy using Apache HTTPD, sets up firewall rules, and obtains a certificate from Letsencrypt.
You have to allocate three endpoints for Mailtrain - trusted (admin UI), sandbox (editors for templates), public (subscription forms and archive).
These endpoints have to differ in hostname. It's fine to host them all from one IP address.
These endpoints have to differ in hostname. It's fine to host them all from one IP address. The email parameters is needed by certbot.
The email is needed by certbot. Please note that by running the script, you agree with Letsencrypt's conditions.
Example: install-centos7-https.sh mailtrain.example.com sbox.mailtrain.example.com mail.example.com admin@example.com
Example: install-centos7-https.sh mailtrain.example.com sbox.mailtrain.example.com lists.example.com admin@example.com
EOF
exit 1
@ -49,4 +47,6 @@ createCertificates "${hostTrusted}" "${hostSandbox}" "${hostPublic}" "${email}"
installHttps "${hostTrusted}" 443 "${hostSandbox}" 443 "${hostPublic}" 443 "/etc/letsencrypt/live/${hostPublic}/cert.pem" "/etc/letsencrypt/live/${hostPublic}/privkey.pem" "/etc/letsencrypt/live/${hostPublic}/chain.pem"
installBase "https://${hostTrusted}" "https://${hostSandbox}" "https://${hostPublic}" "${email}"
installBase "https://${hostTrusted}" "https://${hostSandbox}" "https://${hostPublic}" 127.0.0.1
installService

View file

@ -36,4 +36,6 @@ if [ $# -lt 0 ]; then
HELP
fi
installBase http://localhost:3000 http://localhost:3003 http://localhost:3004
installBase http://localhost:3000 http://localhost:3003 http://localhost:3004 0.0.0.0
installService