nginx-config.sh 898 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. export DOLAR='$'
  3. for fn in `ls /etc/nginx/conf.d/*.conf.tpl`; do
  4. # remove .conf.tpl
  5. fnn=${fn:0:(-9)}
  6. # get the name of file
  7. name=${fnn##*/}
  8. # apply uppercase
  9. name=${name^^}
  10. # generete string to find
  11. host_name="HOST_${name}="
  12. # greo in host.env
  13. module=$(set | grep ${host_name} | head -1)
  14. # get the url access
  15. value=${module##*=}
  16. # get length
  17. exist=${#value}
  18. if [ "${exist}" != "0" ];
  19. then
  20. echo "--------------------------------------------------------------------------------------"
  21. echo "Config file -> " ${fn:0:(-4)}
  22. # module is installed
  23. envsubst < $fn > ${fn:0:(-4)}
  24. cat ${fn:0:(-4)}
  25. else
  26. echo "--------------------------------------------------------------------------------------"
  27. echo "VARIABLE IS NOT DEFINED IN FILE host.env -> $fn"
  28. fi
  29. done
  30. nginx -g "daemon off;"