diff options
Diffstat (limited to 'netzbon/config_nginx.sh')
-rwxr-xr-x | netzbon/config_nginx.sh | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/netzbon/config_nginx.sh b/netzbon/config_nginx.sh index e318096..1d355fd 100755 --- a/netzbon/config_nginx.sh +++ b/netzbon/config_nginx.sh @@ -1,44 +1,54 @@ #!/bin/bash # This file is in the public domain. +set -eu + # Inputs: DOMAIN_NAME & ENABLE_TLS source functions.sh source config/user.conf source config/internal.conf -say "Configuring Nginx" - -systemctl start nginx +if test -z ${DOMAIN_NAME:-} +then + say "Error: config/user.conf does not specify DOMAIN_NAME" + exit 1 +fi +if test -z ${ENABLE_TLS:-} +then + say "Error: config/user.conf does not specify ENABLE_TLS" + exit 1 +fi -# Paths of NGINX +say "Configuring Nginx" SITES_AVAILABLE_DIR=/etc/nginx/sites-available SITES_ENABLED_DIR=/etc/nginx/sites-enabled -# SED replacements - NGINX sites-available - -# taler-exchange -sed -i 's/server_name localhost/server_name exchange.${DOMAIN_NAME}/g' ${SITES_AVAILABLE_DIR}/taler-exchange -sed -i 's/"localhost"/"exchange.${DOMAIN_NAME}"/g' ${SITES_AVAILABLE_DIR}/taler-exchange - -# taler-merchant -sed -i 's/server_name localhost/server_name merchant.${DOMAIN_NAME}/g' ${SITES_AVAILABLE_DIR}/taler-medrchant - -# libeufin-sandbox -sed -i 's/server_name localhost/server_name bank.${DOMAIN_NAME}/g' ${SITES_AVAILABLE_DIR}/libeufin-sandbox - -# Sym links for NGINX sites-enabled - -ln -s ${SITES_AVAILABLE_DIR}/taler-exchange ${SITES_ENABLED_DIR}/exchange.${DOMAIN_NAME} -ln -s ${SITES_AVAILABLE_DIR}/taler-merchant ${SITES_ENABLED_DIR}/backend.${DOMAIN_NAME} -ln -s ${SITES_AVAILABLE_DIR}/libeufin-sandbox ${SITES_ENABLED_DIR}/bank.${DOMAIN_NAME} - -# Obtain SSL certificates with Certbot - -# TODO: check nginx, check dns ping, first. - -if test ${ENABLE_TLS} = "y" +cat ${SITES_AVAILABLE_DIR}/taler-exchange \ + | sed -e "s/localhost/exchange.${DOMAIN_NAME}/g" \ + | sed -e "s/location \/taler-exchange\//location \//g" \ + > ${SITES_AVAILABLE_DIR}/taler-exchange.${DOMAIN_NAME} +rm -f ${SITES_ENABLED_DIR}/exchange.${DOMAIN_NAME} +ln -s ${SITES_AVAILABLE_DIR}/taler-exchange.${DOMAIN_NAME} ${SITES_ENABLED_DIR}/exchange.${DOMAIN_NAME} + +cat ${SITES_AVAILABLE_DIR}/taler-merchant \ + | sed -e "s/localhost/backend.${DOMAIN_NAME}/g" \ + | sed -e "s/location \/taler-merchant\//location \//g" \ + > ${SITES_AVAILABLE_DIR}/taler-merchant.${DOMAIN_NAME} +rm -f ${SITES_ENABLED_DIR}/backend.${DOMAIN_NAME} +ln -s ${SITES_AVAILABLE_DIR}/taler-merchant.${DOMAIN_NAME} ${SITES_ENABLED_DIR}/backend.${DOMAIN_NAME} + +cat ${SITES_AVAILABLE_DIR}/libeufin-sandbox \ + | sed -e "s/localhost/bank.${DOMAIN_NAME}/g" \ + > ${SITES_AVAILABLE_DIR}/libeufin-sandbox.${DOMAIN_NAME} +rm -f ${SITES_ENABLED_DIR}/bank.${DOMAIN_NAME} +ln -s ${SITES_AVAILABLE_DIR}/libeufin-sandbox.${DOMAIN_NAME} ${SITES_ENABLED_DIR}/bank.${DOMAIN_NAME} + +say "Restarting Nginx with new configuration" +systemctl restart nginx + +if test ${ENABLE_TLS} == "y" then say "Obtaining TLS certificates" |