mirror of
https://git.myvelabs.com/docker/myvemail.git
synced 2025-12-18 01:36:19 +00:00
renamed: 01-nginx-setup.sh -> 01-setup.sh
deleted: 02-generate-env.sh
This commit is contained in:
parent
d42b05171b
commit
cfcba20e0f
2 changed files with 64 additions and 54 deletions
|
|
@ -1,19 +1,26 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Fill in the following variables
|
# Fill in the following variables
|
||||||
appname= #google
|
appname= #google
|
||||||
proxyurl= #http://webapps.kvm:4001
|
proxyurl= #http://webapps.kvm
|
||||||
|
proxyport= #4000
|
||||||
domain= #www.google.com
|
domain= #www.google.com
|
||||||
eff_email_address= #eff@eff.com
|
eff_email_address= #eff@eff.com
|
||||||
|
|
||||||
# Check privilege
|
# Exit on any error
|
||||||
if [ $(id -u) -ne 0 ]
|
set -e
|
||||||
|
|
||||||
|
# Check for subdomain
|
||||||
|
if [ $(echo ${domain} | awk -F . '{print $3}') ]
|
||||||
then
|
then
|
||||||
echo "This script must be run by root" >&2
|
_subdomain=$(echo ${domain} | awk -F . '{print $1}')
|
||||||
|
_domain="$(echo ${domain} | awk -F . '{print $2}').$(echo ${domain_url} | awk -F . '{print $3}')"
|
||||||
|
else
|
||||||
|
echo "Invalid \${domain} variable, exiting"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Variable check
|
# Variable check
|
||||||
if [ -z ${appname} ] || [ -z ${proxyurl} ] || [ -z ${domain} ] || [ -z ${eff_email_address} ]
|
if [ -z ${appname} ] || [ -z ${proxyurl} ] || [ -z ${proxyport} ] || [ -z ${domain} ] || [ -z ${eff_email_address} ]
|
||||||
then
|
then
|
||||||
echo "Missing variable, exiting..."
|
echo "Missing variable, exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -26,7 +33,7 @@ then
|
||||||
elif grep -q 'include.*sites-available' /etc/nginx/nginx.conf
|
elif grep -q 'include.*sites-available' /etc/nginx/nginx.conf
|
||||||
then
|
then
|
||||||
nginxdir=/etc/nginx/sites-available
|
nginxdir=/etc/nginx/sites-available
|
||||||
ln -s -f /etc/nginx/sites-available/${appname}.conf /etc/nginx/sites-enabled/
|
sudo ln -s -f /etc/nginx/sites-available/${appname}.conf /etc/nginx/sites-enabled/
|
||||||
else
|
else
|
||||||
echo "Missing nginx directory, exiting..."
|
echo "Missing nginx directory, exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
|
|
@ -36,12 +43,13 @@ fi
|
||||||
cat <<- 'proxy' | \
|
cat <<- 'proxy' | \
|
||||||
sed -e "s|{{domain}}|${domain}|" \
|
sed -e "s|{{domain}}|${domain}|" \
|
||||||
-e "s|{{proxyurl}}|${proxyurl}|" \
|
-e "s|{{proxyurl}}|${proxyurl}|" \
|
||||||
-e "s|{{appname}}|${appname}|" | tee ${nginxdir}/${appname}.conf >/dev/null
|
-e "s|{{proxyport}}|${proxyport}|" \
|
||||||
|
-e "s|{{appname}}|${appname}|" | sudo tee ${nginxdir}/${appname}.conf >/dev/null
|
||||||
server {
|
server {
|
||||||
server_name {{domain}};
|
server_name {{domain}};
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass {{proxyurl}};
|
proxy_pass {{proxyurl}}:{{proxyport}}:;
|
||||||
error_log /var/log/nginx/{{appname}}_error.log;
|
error_log /var/log/nginx/{{appname}}_error.log;
|
||||||
access_log /var/log/nginx/{{appname}}_access.log;
|
access_log /var/log/nginx/{{appname}}_access.log;
|
||||||
|
|
||||||
|
|
@ -95,22 +103,65 @@ server {
|
||||||
proxy
|
proxy
|
||||||
|
|
||||||
# Run certbot
|
# Run certbot
|
||||||
if nginx -t
|
if sudo nginx -t
|
||||||
then
|
then
|
||||||
certbot --nginx --non-interactive --agree-tos --no-eff-email -m ${eff_email_address} -d ${domain} \
|
sudo certbot --nginx --non-interactive --agree-tos --no-eff-email -m ${eff_email_address} -d ${domain} \
|
||||||
--staple-ocsp --hsts --no-redirect --renew-hook 'docker exec --interactive --tty myvemail /bin/ash -c "dovecot reload; postfix reload"'
|
--staple-ocsp --hsts --no-redirect --renew-hook 'docker exec --interactive --tty myvemail /bin/ash -c "dovecot reload; postfix reload"'
|
||||||
else
|
else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# SSL
|
# SSL
|
||||||
[ -d ./data/ssl/ ] || mkdir -p ./data/ssl
|
[ -d ./data/ssl/ ] || install --directory ./data/ssl/
|
||||||
ln -s /etc/letsencrypt/live/${domain}/fullchain.pem ./data/ssl/tls.pem
|
sudo ln -s /etc/letsencrypt/live/${domain}/fullchain.pem ./data/ssl/tls.pem
|
||||||
ln -s /etc/letsencrypt/live/${domain}/privkey.pem ./data/ssl/tls.key
|
sudo ln -s /etc/letsencrypt/live/${domain}/privkey.pem ./data/ssl/tls.key
|
||||||
[ -f ./data/ssl/dh.pem ] || openssl dhparam -out ./data/ssl/dh.pem 4096
|
[ -f ./data/ssl/dh.pem ] || openssl dhparam -out ./data/ssl/dh.pem 4096
|
||||||
|
|
||||||
# Postwhite
|
# Postwhite
|
||||||
[ -f ./data/postwhite ] || touch ./data/postwhite
|
[ -f ./data/postwhite ] || touch ./data/postwhite
|
||||||
|
|
||||||
|
# Environment file
|
||||||
|
cat >./.env <<- gen-env
|
||||||
|
# Required
|
||||||
|
# Mail domain
|
||||||
|
MYVEMAIL_SUBDOMAIN=${_subdomain}
|
||||||
|
MYVEMAIL_DOMAIN=${_domain}
|
||||||
|
|
||||||
|
# Webmail port
|
||||||
|
MYVEMAIL_PORT=${proxyport}
|
||||||
|
|
||||||
|
# Optional
|
||||||
|
# Version: latest or stable (defaults to latest)
|
||||||
|
MYVEMAIL_VERSION=
|
||||||
|
|
||||||
|
# Additional mail domains separated by commas
|
||||||
|
MYVEMAIL_ADDMX=
|
||||||
|
|
||||||
|
# Backup mail servers separated by commas
|
||||||
|
MYVEMAIL_BACKUPMX=
|
||||||
|
|
||||||
|
# Volumes
|
||||||
|
MYVEMAIL_VOLUME_MARIADB=
|
||||||
|
MYVEMAIL_VOLUME_SSL=
|
||||||
|
MYVEMAIL_VOLUME_DATA=
|
||||||
|
MYVEMAIL_VOLUME_MAIL=
|
||||||
|
MYVEMAIL_VOLUME_DKIM=
|
||||||
|
MYVEMAIL_VOLUME_POSTWHITE=
|
||||||
|
|
||||||
|
# MariaDB
|
||||||
|
# Roundcube
|
||||||
|
MYVEMAIL_ROUNDCUBE_DBNAME=roundcube
|
||||||
|
MYVEMAIL_ROUNDCUBE_DBUSER=roundcube
|
||||||
|
MYVEMAIL_ROUNDCUBE_DBPASS=$(openssl rand -hex 32)
|
||||||
|
# Postfixadmin
|
||||||
|
MYVEMAIL_POSTFIXADMIN_DBNAME=postfixadmin
|
||||||
|
MYVEMAIL_POSTFIXADMIN_DBUSER=postfixadmin
|
||||||
|
MYVEMAIL_POSTFIXADMIN_DBPASS=$(openssl rand -hex 32)
|
||||||
|
gen-env
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
rm -f ${0}
|
rm -f ${0}
|
||||||
|
|
||||||
|
# Myvemail initial setup
|
||||||
|
docker compose pull
|
||||||
|
docker compose run --rm -it myvemail setup
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
cat >./.env <<- gen-env
|
|
||||||
# Required
|
|
||||||
# Mail domain
|
|
||||||
MYVEMAIL_SUBDOMAIN=${SUBDOMAIN}
|
|
||||||
MYVEMAIL_DOMAIN=${DOMAIN}
|
|
||||||
|
|
||||||
# Webmail port
|
|
||||||
MYVEMAIL_PORT=${PORT}
|
|
||||||
|
|
||||||
# Optional
|
|
||||||
# Version: latest or stable (defaults to latest)
|
|
||||||
MYVEMAIL_VERSION=
|
|
||||||
|
|
||||||
# Additional mail domains separated by commas
|
|
||||||
MYVEMAIL_ADDMX=
|
|
||||||
|
|
||||||
# Backup mail servers separated by commas
|
|
||||||
MYVEMAIL_BACKUPMX=
|
|
||||||
|
|
||||||
# Volumes
|
|
||||||
MYVEMAIL_VOLUME_MARIADB=
|
|
||||||
MYVEMAIL_VOLUME_SSL=
|
|
||||||
MYVEMAIL_VOLUME_DATA=
|
|
||||||
MYVEMAIL_VOLUME_MAIL=
|
|
||||||
MYVEMAIL_VOLUME_DKIM=
|
|
||||||
MYVEMAIL_VOLUME_POSTWHITE=
|
|
||||||
|
|
||||||
# MariaDB
|
|
||||||
# Roundcube
|
|
||||||
MYVEMAIL_ROUNDCUBE_DBNAME=roundcube
|
|
||||||
MYVEMAIL_ROUNDCUBE_DBUSER=roundcube
|
|
||||||
MYVEMAIL_ROUNDCUBE_DBPASS=$(openssl rand -hex 32)
|
|
||||||
# Postfixadmin
|
|
||||||
MYVEMAIL_POSTFIXADMIN_DBNAME=postfixadmin
|
|
||||||
MYVEMAIL_POSTFIXADMIN_DBUSER=postfixadmin
|
|
||||||
MYVEMAIL_POSTFIXADMIN_DBPASS=$(openssl rand -hex 32)
|
|
||||||
gen-env
|
|
||||||
|
|
||||||
# Cleanup
|
|
||||||
rm -f ${0}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue