#!/bin/sh set -eu render_locations() { surface="$1" SHOP_SURFACE="$surface" export SHOP_SURFACE BACKEND_PORT envsubst '${SHOP_SURFACE} ${BACKEND_PORT}' \ < /etc/nginx/templates/snippets/nullcart-locations.conf.template \ > "/etc/nginx/snippets/nullcart-locations-${surface}.conf" } render_server() { template_path="$1" output_path="$2" surface="$3" SHOP_SURFACE="$surface" export SHOP_SURFACE CLEARNET_DOMAIN BACKEND_PORT envsubst '${CLEARNET_DOMAIN} ${BACKEND_PORT} ${SHOP_SURFACE}' \ < "$template_path" \ > "$output_path" } mkdir -p /etc/nginx/snippets render_locations clearnet render_locations onion render_server /etc/nginx/templates/conf.d/clearnet.conf.template /etc/nginx/conf.d/clearnet.conf clearnet render_server /etc/nginx/templates/conf.d/onion.conf.template /etc/nginx/conf.d/onion.conf onion exec nginx -g 'daemon off;'