auto-nginx/auto-nginx
2019-05-10 16:06:16 -04:00

62 lines
1.9 KiB
Bash

#!/bin/bash
###############################################################################
# auto-nginx - for setting up a simple nginx config for further tweaking
# a project by vala
#
# kopimi (k) 2019 - vala
#
# // this is a work in progress, so any constructive input is welcome. //
#
# auto-nginx [option] [argument] ...
#
#
###############################################################################
set -e # exit as soon as a line in the bash script fails
# set -x # prints each command executed (prefix with ++)
# set -ex # both the above
echo "auto-nginx"
echo -n "a simple script to generate a fully functional nginx site."
sudo -n true
test $? -eq 0 || exit 1 "for this script to be able to create an nginx configuration file, you must run this as root."
echo
# asks for domain.tld and insert it into the generated file at given points
echo "what is the name of your site (domain.tld or sub.domain.tld)?"
read domain
if (( $domain == true ))
then
echo -e "\nalright, let us setup an nginx configuration for $domain."
else
echo -e "\nyou cannot setup a nginx configuration without a domain."
fi
# asks where the server is located on the machine
echo "where is the root folder of the webserver located?"
read webroot
if (( $webroot == true ))
then
echo "okay, $webroot is configured as rootfolder of the website"
else
read -p "since you didnt specify, i assume it is located in /var/www/$domain? [y/n]" loop
# asks what port the internal server is running at.
echo "what internal port is the server running on (usually something like 8096, 4000 or 9999)?"
read port
echo "alright, nginx will forward requests to server running at port $port."
echo "do you want to add an ssl certificate, for higher site rankings and secure access to the website? "
# asks for port on localhost, and sets it accordingly
if [[ $domain =* ]]
echo
fi
echo "the site at $domain, is running at 127.0.0.1:$port"
exit