#!/bin/sh os="$(cat "${__global:?}"/explorer/os)" case "$os" in alpine) reload_hook="service nginx --ifstopped start;\ service nginx --ifstarted reload" ;; debian|ubuntu|*) reload_hook="systemctl reload-or-restart nginx" ;; esac # Check configuration and reload if valid. # TODO: only check if configuration was changed (= listen for __file's # messages). cat << EOF if nginx -t; then $reload_hook else echo "NGINX configuration is invalid. Exiting." >2& nginx -t >2& exit 1 fi EOF