code added

This commit is contained in:
Fr4nz D13trich 2025-10-09 17:57:13 +02:00
parent 1e5b6677d2
commit c9223ecffc
3 changed files with 38 additions and 13 deletions

View file

@ -0,0 +1 @@
pkgs="openssl nginx"

View file

@ -1,10 +1,11 @@
#!/bin/bash #!/bin/bash
source assets/shell/shell_colors
source assets/shell/colors
source assets/config/deps/dependencies
### DEPENDENCY CHECK & INSTALLER ### DEPENDENCY CHECK & INSTALLER
pkgs="openssl nginx" echo -e "\n${LCY} Dependency and Privilege Check running...${CRS}\n"
echo -e "\n${CYN} Dependency and Privilege Check running...${CRS}\n"
### PRIVILEGES ### PRIVILEGES
@ -22,11 +23,11 @@ if command -v "$pkgs" >/dev/null 2>&1; then
echo -e "${GRN} Dependency check passed...${CRS}\n" echo -e "${GRN} Dependency check passed...${CRS}\n"
else else
echo -e "${YEL} Dependencies not met.${CRS}\n" echo -e "${RED} Dependencies not met.${CRS}\n"
while true; do while true; do
echo -e " ${YEL}Do you wish to install via APT? (${GRN}Y${YEL}/${RED}n${YEL})${CRS}" echo -e " ${YEL}Do you wish to install via APT?"
read -p " --> " install read -p " (Y/n) --> " install
echo "" echo ""
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
sudo apt update && sudo apt install --install-suggests -y $pkgs --simulate ## DEV sudo apt update && sudo apt install --install-suggests -y $pkgs --simulate ## DEV
@ -45,11 +46,22 @@ fi
### NGINX SETUP & CONFIG ### NGINX SETUP & CONFIG
###### HOST
ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
echo -e " ${YEL}Current hostname : ${LCY}$HOSTNAME${CRS}"
echo -e " ${YEL}Current ip address : ${LCY}$ip4${CRS}"
echo -e "\n ${YEL}This information will be used to configure ${LCY}nginx.conf ${YEL}during the next steps.${CRS}"
read -p " Would you like to change the hostname? (y/N) --> " conf_host_ip
# ask for network interface
# ask to change hostname in /etc/hosts & /etc/hostname
###### CERTIFICATION ###### CERTIFICATION
while true; do while true; do
echo -e " ${YEL}Configure SSL and create a self signed cetrificate? (Y/n)${CRS}" echo -e "\n ${YEL}Configure SSL and create a self signed cetrificate?${CRS}"
read -p " --> " installSSL read -p " (Y/n) --> " installSSL
if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then
echo -e " ${YEL}Enter path to certificates folder${CRS}" echo -e " ${YEL}Enter path to certificates folder${CRS}"
read -p " default = /etc/nginx/ssl --> " cert_path read -p " default = /etc/nginx/ssl --> " cert_path
@ -62,16 +74,16 @@ while true; do
fi fi
echo "" echo ""
echo -e " ${YEL}Enter file name for certificate and key${CRS}" echo -e " ${YEL}Enter file name for certificate and key${CRS}"
read -p " default --> $HOSTNAME --> " cert_name read -p " default = $HOSTNAME --> " cert_name
if ! [ "$cert_name" ]; then if ! [ "$cert_name" ]; then
cert_name=$HOSTNAME cert_name=$HOSTNAME
else else
: :
fi fi
echo "" echo ""
sudo mkdir -p "$cert_path" #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 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} SSL certificate files ${YEL}$cert_name.crt ${GRN}and ${YEL}$cert_name.key ${GRN}created and stored in ${YEL}$cert_path${CRS}\n" echo -e "\n${GRN} SSL certificate files ${LCY}$cert_name.crt ${GRN}and ${LCY}$cert_name.key ${GRN}created and stored in ${LCY}$cert_path${CRS}\n"
break break
elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then
echo -e "\n${RED} No encryption established${CRS}\n" echo -e "\n${RED} No encryption established${CRS}\n"
@ -80,3 +92,15 @@ while true; do
echo -e "\n${YEL} Invalid response... Try again...\n\nY = (Yes, configure SSL certificate and continue)\nN = (No, leave unencrypted and continue)${CRS}\n " echo -e "\n${YEL} Invalid response... Try again...\n\nY = (Yes, configure SSL certificate and continue)\nN = (No, leave unencrypted and continue)${CRS}\n "
fi fi
done done
### DEV STATUS
#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 "${GRN}\nScript ran through...${CRS}"