Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

setup 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. if [ ! -d /run/nginx ]; then
  3. mkdir -p /run/nginx
  4. mkdir -p /run/nginx/challenges
  5. chown -R nginx /run/nginx
  6. fi
  7. # cleanup and copy nginx configuration file from embedded template
  8. if [ -f /etc/nginx/conf.d/default.conf ]; then
  9. rm /etc/nginx/conf.d/default.conf
  10. fi
  11. cp /etc/templates/nginx.conf /etc/nginx/nginx.conf
  12. # handle preparing to run ssl
  13. if [ -n ENABLE_SSL ]; then
  14. NGINX_CONF_TEMPLATE=/etc/templates/nginx_site_ssl.conf
  15. if [ ! -f /data/ssl/cert.crt ] || [ ! -f /data/ssl/cert.key ]; then
  16. # we need to obtain certificates from ACME
  17. if [ ! -f /data/ssl/account.key ]; then
  18. # there is no account key so create one
  19. openssl genrsa 4096 > /data/ssl/account.key
  20. fi
  21. openssl genrsa 4096 > /data/ssl/cert.key
  22. openssl req -new -sha256 -key /data/ssl/cert.key -subj "/CN=$DOMAIN" > /data/ssl/domain.csr
  23. # we need to start nginx with special configuration file
  24. cp /etc/templates/nginx_site_letsencryptinit.conf /etc/nginx/conf.d/gitea.conf
  25. nginx -c /etc/nginx/nginx.conf -g 'daemon off;' &
  26. pid="$!"
  27. python3 -m acme_tiny --account-key /data/ssl/account.key --csr /data/ssl/domain.csr --acme-dir /run/nginx/challenges > /data/ssl/cert.crt
  28. if ! kill -s TERM "$pid" || ! wait "$pid"; then
  29. echo >&2 'nginx process failed while attempting to get certification'
  30. exit 1
  31. fi
  32. fi
  33. else
  34. NGINX_CONF_TEMPLATE=/etc/templates/nginx_site_nossl.conf
  35. fi
  36. # avoiding race condition and waiting for gitea configuration file to be prepared by its own startup script
  37. while [ ! -f /data/gitea/conf/app.ini ]; do
  38. echo "Gitea configuration is still not ready waiting 10 seconds..."
  39. sleep 10
  40. done
  41. GITEA_DOMAIN=${DOMAIN:-$(iniget /data/gitea/conf/app.ini server DOMAIN)}
  42. GITEA_DOMAIN=${GITEA_DOMAIN:-"localhost"} envsubst '${GITEA_DOMAIN}' < $NGINX_CONF_TEMPLATE > /etc/nginx/conf.d/gitea.conf