Script added

This commit is contained in:
Fr4nz D13trich 2025-10-08 19:59:38 +02:00
parent a8addbec49
commit 1588f31e88
2 changed files with 21 additions and 5 deletions

View file

@ -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;

View file

@ -1,73 +0,0 @@
#!/bin/bash
## SOME COLOR
CYN="\e[0;36m"
YEL="\e[0;33m"
RED="\e[0;31m"
GRN="\e[0;32m"
CRS="\e[0m"
### DEPENDENCY CHECK & INSTALLER
pkgs="openssl nginx"
echo -e "\n${CYN} Dependency and Privilege Check running...${CRS}\n"
if (( $(id -u) == 0 )); then
echo -e "${GRN} Privilege check passed...${CRS}\n"
else
echo -e "${RED} Privilege check failed... Please run script with sudo or as root!${CRS}\n"
exit 1
fi
if command -v "$pkgs" >/dev/null 2>&1; then
echo -e "${GRN} Dependency check passed...${CRS}\n"
else
echo -e "${YEL} Dependencies not met.${CRS}\n"
while true; do
read -p " Do you wish to install via APT? (Y/n) : " install
echo ""
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
sudo apt update && sudo apt install --install-suggests -y $pkgs --simulate ## DEV
echo -e "\n${GRN} Dependencies installed. Proceeding...${CRS}\n"
break
elif [[ "$install" == "n" || "$install" = "N" ]]; then
echo -e "\n${RED} Missing dependencies... Exiting!${CRS}\n"
exit 1
else
echo -e "\n${YEL} Invalid response... Try again...\n\n Y = (Yes, install dependencies and continue)\n N = (No, don't install dependencies and exit)${CRS}\n "
fi
done
fi
### NGINX SETUP
#### CERTIFICATION
while true; do
read -p " Enable SSL and create 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 ""
read -p " Enter file name for certificates (Without file ending) : " cert_name
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
echo -e "\n${GRN} Nginx configured${CRS}\n"
break
elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then
echo -e "\n${RED} No SSL in nginx configured${CRS}\n"
break
else
echo -e "\n${YEL} Invalid response... Try again...\n\nY = (Yes, configure SSL certificate and continue)\nN = (No, don't configure SSL certificate and continue)${CRS}\n "
fi
done
### DEV STATUS
echo -e "${GRN}\nScript ran through...${CRS}"