diff --git a/assets/config/nginx/meshpi.conf b/assets/config/nginx/nginx.conf similarity index 90% rename from assets/config/nginx/meshpi.conf rename to assets/config/nginx/nginx.conf index b401cb4..17f00c5 100644 --- a/assets/config/nginx/meshpi.conf +++ b/assets/config/nginx/nginx.conf @@ -6,13 +6,13 @@ server { listen 80; - server_name meshpi.local 192.168.1.8; + server_name DOMAIN IPADDR; return 301 https://$host$request_uri; } server { listen 443 ssl; - server_name meshpi.local 192.168.1.8; + server_name DOMAIN IPADDR; ssl_certificate /etc/nginx/ssl/meshpi.crt; ssl_certificate_key /etc/nginx/ssl/meshpi.key; diff --git a/assets/shell/setup.sh b/dev_env_setup.sh similarity index 81% rename from assets/shell/setup.sh rename to dev_env_setup.sh index 64e3d05..c1c85d2 100755 --- a/assets/shell/setup.sh +++ b/dev_env_setup.sh @@ -13,6 +13,8 @@ pkgs="openssl nginx" echo -e "\n${CYN} Dependency and Privilege Check running...${CRS}\n" +### PRIVILEGES + if (( $(id -u) == 0 )); then echo -e "${GRN} Privilege check passed...${CRS}\n" @@ -21,6 +23,8 @@ else exit 1 fi +### DEPENDENCIES + if command -v "$pkgs" >/dev/null 2>&1; then echo -e "${GRN} Dependency check passed...${CRS}\n" @@ -45,12 +49,18 @@ else done fi -### NGINX SETUP +### NGINX SETUP & CONFIG -#### CERTIFICATION +###### DOMAIN & IP + +# ask for network interface & get IP +# get hostname from /etc/hostname +# ask to change hostname in /etc/hosts & /etc/hostname + +###### CERTIFICATION while true; do - read -p " Enable SSL and create self signed cetrificate? (Y/n) : " installSSL + read -p " Configure SSL and create a self signed cetrificate? (Y/n) : " installSSL if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then read -p " Enter path to certificates folder (Will be created if not present) : " cert_path echo "" @@ -58,6 +68,12 @@ while true; do echo "" sudo mkdir -p "$cert_path" sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "$cert_path"/"$cert_name".key -out "$cert_path"/"$cert_name".crt + #sudo cp -R assets/config/nginx/nginx.conf /etc/nginx/sites-enabled/ +## JEFF +# utilise sed to edit config +# test nginx config +# restart nginx +## JEFF END echo -e "\n${GRN} Nginx configured${CRS}\n" break elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then