2025-10-08 17:46:15 +02:00
|
|
|
#!/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"
|
|
|
|
|
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "\n${CYN} Dependency and Privilege Check running...${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
|
|
|
|
|
if (( $(id -u) == 0 )); then
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "${GRN} Privilege check passed...${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
|
|
|
|
|
else
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "${RED} Privilege check failed... Please run script with sudo or as root!${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if command -v "$pkgs" >/dev/null 2>&1; then
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "${GRN} Dependency check passed...${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
|
|
|
|
|
else
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "${YEL} Dependencies not met.${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
|
|
|
|
|
while true; do
|
2025-10-08 18:44:04 +02:00
|
|
|
read -p " Do you wish to install via APT? (Y/n) : " install
|
2025-10-08 18:50:02 +02:00
|
|
|
echo ""
|
2025-10-08 17:46:15 +02:00
|
|
|
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
|
|
|
|
|
sudo apt update && sudo apt install --install-suggests -y $pkgs --simulate ## DEV
|
2025-10-08 18:50:02 +02:00
|
|
|
echo -e "\n${GRN} Dependencies installed. Proceeding...${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
|
|
elif [[ "$install" == "n" || "$install" = "N" ]]; then
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "\n${RED} Missing dependencies... Exiting!${CRS}\n"
|
2025-10-08 17:46:15 +02:00
|
|
|
exit 1
|
|
|
|
|
|
|
|
|
|
else
|
2025-10-08 18:44:04 +02:00
|
|
|
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 "
|
2025-10-08 17:46:15 +02:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
### NGINX SETUP
|
|
|
|
|
|
2025-10-08 18:44:04 +02:00
|
|
|
#### CERTIFICATION
|
|
|
|
|
|
2025-10-08 17:46:15 +02:00
|
|
|
while true; do
|
2025-10-08 18:44:04 +02:00
|
|
|
read -p " Enable SSL and create self signed cetrificate? (Y/n) : " installSSL
|
2025-10-08 17:46:15 +02:00
|
|
|
if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then
|
2025-10-08 18:44:04 +02:00
|
|
|
read -p " Enter path to certificates folder (Will be created if not present) : " cert_path
|
2025-10-08 18:50:02 +02:00
|
|
|
echo ""
|
2025-10-08 18:44:04 +02:00
|
|
|
read -p " Enter file name for certificates (Without file ending) : " cert_name
|
2025-10-08 18:50:02 +02:00
|
|
|
echo ""
|
2025-10-08 17:46:15 +02:00
|
|
|
sudo mkdir -p "$cert_path"
|
2025-10-08 18:44:04 +02:00
|
|
|
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"
|
2025-10-08 18:50:02 +02:00
|
|
|
break
|
2025-10-08 17:46:15 +02:00
|
|
|
else
|
2025-10-08 18:44:04 +02:00
|
|
|
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 "
|
2025-10-08 17:46:15 +02:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
2025-10-08 18:44:04 +02:00
|
|
|
### DEV STATUS
|
2025-10-08 17:46:15 +02:00
|
|
|
|
2025-10-08 18:44:04 +02:00
|
|
|
echo -e "${GRN}\nScript ran through...${CRS}"
|