auto-nginx - for setting up a simple nginx config for further tweaking
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.

62 lines
1.9KB

  1. #!/bin/bash
  2. ###############################################################################
  3. # auto-nginx - for setting up a simple nginx config for further tweaking
  4. # a project by vala
  5. #
  6. # kopimi (k) 2019 - vala
  7. #
  8. # // this is a work in progress, so any constructive input is welcome. //
  9. #
  10. # auto-nginx [option] [argument] ...
  11. #
  12. #
  13. ###############################################################################
  14. set -e # exit as soon as a line in the bash script fails
  15. # set -x # prints each command executed (prefix with ++)
  16. # set -ex # both the above
  17. echo "auto-nginx"
  18. echo -n "a simple script to generate a fully functional nginx site."
  19. sudo -n true
  20. test $? -eq 0 || exit 1 "for this script to be able to create an nginx configuration file, you must run this as root."
  21. echo
  22. # asks for domain.tld and insert it into the generated file at given points
  23. echo "what is the name of your site (domain.tld or sub.domain.tld)?"
  24. read domain
  25. if (( $domain == true ))
  26. then
  27. echo -e "\nalright, let us setup an nginx configuration for $domain."
  28. else
  29. echo -e "\nyou cannot setup a nginx configuration without a domain."
  30. fi
  31. # asks where the server is located on the machine
  32. echo "where is the root folder of the webserver located?"
  33. read webroot
  34. if (( $webroot == true ))
  35. then
  36. echo "okay, $webroot is configured as rootfolder of the website"
  37. else
  38. read -p "since you didnt specify, i assume it is located in /var/www/$domain? [y/n]" loop
  39. # asks what port the internal server is running at.
  40. echo "what internal port is the server running on (usually something like 8096, 4000 or 9999)?"
  41. read port
  42. echo "alright, nginx will forward requests to server running at port $port."
  43. echo "do you want to add an ssl certificate, for higher site rankings and secure access to the website? "
  44. # asks for port on localhost, and sets it accordingly
  45. if [[ $domain =* ]]
  46. echo
  47. fi
  48. echo "the site at $domain, is running at 127.0.0.1:$port"
  49. exit