mirror of
https://github.com/nodemailer/wildduck.git
synced 2024-12-28 03:07:13 +08:00
88ee4c9ede
Fixed two issues: 82: need to install npm globally to get around permission problems 83: need to start nginx service before restarting it Better executable requirements (lsof, ps). It may be not installed on minimal systems. Better service detection on given port. It is especially useful, if the installation.sh got interrupted for some reason, and already installed some services. Minor doc update, so a single line is required to paste in terminal. curl vs. wget -> stayed with wget, it is installed by default on ubuntu Colors: added color support for the terminal output:)
53 lines
1.6 KiB
Bash
53 lines
1.6 KiB
Bash
#! /bin/bash
|
|
|
|
OURNAME=13_install_ssl_certs.sh
|
|
|
|
echo -e "\n-- Executing ${ORANGE}${OURNAME}${NC} subscript --"
|
|
|
|
#### SSL CERTS ####
|
|
|
|
curl https://get.acme.sh | sh
|
|
|
|
echo 'cert="/etc/wildduck/certs/fullchain.pem"
|
|
key="/etc/wildduck/certs/privkey.pem"' > /etc/wildduck/tls.toml
|
|
|
|
sed -i -e "s/key=/#key=/g;s/cert=/#cert=/g" /etc/zone-mta/interfaces/feeder.toml
|
|
echo '# @include "../../wildduck/tls.toml"' >> /etc/zone-mta/interfaces/feeder.toml
|
|
|
|
# vanity script as first run should not restart anything
|
|
echo '#!/bin/bash
|
|
echo "OK"' > /usr/local/bin/reload-services.sh
|
|
chmod +x /usr/local/bin/reload-services.sh
|
|
|
|
/root/.acme.sh/acme.sh --issue --nginx \
|
|
-d "$HOSTNAME" \
|
|
--key-file /etc/wildduck/certs/privkey.pem \
|
|
--fullchain-file /etc/wildduck/certs/fullchain.pem \
|
|
--reloadcmd "/usr/local/bin/reload-services.sh" \
|
|
--force || echo "Warning: Failed to generate certificates, using self-signed certs"
|
|
|
|
# Update site config, make sure ssl is enabled
|
|
echo "server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
|
|
server_name $HOSTNAME;
|
|
|
|
ssl_certificate /etc/wildduck/certs/fullchain.pem;
|
|
ssl_certificate_key /etc/wildduck/certs/privkey.pem;
|
|
|
|
location / {
|
|
proxy_set_header X-Real-IP \$remote_addr;
|
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
|
proxy_set_header HOST \$http_host;
|
|
proxy_set_header X-NginX-Proxy true;
|
|
proxy_pass http://127.0.0.1:3000;
|
|
proxy_redirect off;
|
|
}
|
|
}" > "/etc/nginx/sites-available/$HOSTNAME"
|
|
|
|
#See issue https://github.com/nodemailer/wildduck/issues/83
|
|
$SYSTEMCTL_PATH start nginx
|
|
$SYSTEMCTL_PATH reload nginx
|