6
0
Fork 0
This repository has been archived on 2022-03-14. You can view files and clone it, but cannot push or open issues or pull requests.
cdist-recycledcloud/type/__recycledcloud_nginx_vhost/gencode-remote

27 lines
501 B
Bash

#!/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