You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nginx.sh 526B

1234567891011121314151617181920212223242526272829
  1. #!/bin/sh
  2. set -e
  3. out="/etc/nginx/sites-available/autogen"
  4. if ! [ -w "$out" ]; then
  5. echo "Must have write access to $out."
  6. exit 1
  7. fi
  8. cp "$out" "$out.bak"
  9. output="$(m4 -P -I ../conf/nginx nginx.m4)"
  10. echo "$output" \
  11. | sed '/^\s*$/d' \
  12. | tee "$out" >/dev/null
  13. if ! sudo nginx -t; then
  14. cp "$out" "../nginx-error.conf"
  15. echo "Reverting to backup file."
  16. echo "Bad file saved to nginx-error.conf."
  17. mv "$out.bak" "$out"
  18. else
  19. echo "Press enter to restart nginx."
  20. read _
  21. echo "Restarting..."
  22. systemctl restart nginx
  23. fi