setup script updated

This commit is contained in:
Fr4nz D13trich 2025-10-12 17:23:44 +02:00
parent f7589cafe0
commit 033049430b

View file

@ -24,9 +24,9 @@ dep_check() {
local pkg="$1" local pkg="$1"
if dpkg -s "$pkg" >/dev/null 2>&1; then if dpkg -s "$pkg" >/dev/null 2>&1; then
echo "$pkg" >>/tmp/installed_dev echo "$pkg" >>/tmp/LoMeS/installed_dev
else else
echo "$pkg" >>/tmp/missing_dev echo "$pkg" >>/tmp/LoMeS/missing_dev
fi fi
} }
@ -34,14 +34,14 @@ for pkg in "${deps[@]}"; do
dep_check "$pkg" dep_check "$pkg"
done done
installed="$(cat /tmp/installed_dev 2>/dev/null)" installed="$(cat /tmp/LoMeS/installed_dev 2>/dev/null)"
missing="$(cat /tmp/missing_dev 2>/dev/null)" missing="$(cat /tmp/LoMeS/missing_dev 2>/dev/null)"
if ! [ "$missing" ]; then if ! [ "$missing" ]; then
echo -e "\n ${GRN}Dependencies met. Proceeding...${CRS}\n" echo -e "\n ${GRN}Dependencies met. Proceeding...${CRS}\n"
else ### INSTALLING PKGS ! else ### INSTALLING PKGS !
echo -e "\n ${RED}Following dependencies are missing :${CRS}\n\n$missing" echo -e "\n ${RED}Following dependencies are missing :\n\n$missing${CRS}"
while true; do while true; do
echo -e "\n ${YEL}Do you wish to install via APT?" echo -e "\n ${YEL}Do you wish to install via APT?"
@ -49,14 +49,14 @@ else
echo -e "${CRS}" echo -e "${CRS}"
if [[ "$install_dep" = "" || "$install_dep" = "y" || "$install_dep" = "Y" ]]; then if [[ "$install_dep" = "" || "$install_dep" = "y" || "$install_dep" = "Y" ]]; then
sudo apt update && sudo apt install -y $missing sudo apt update && sudo apt install -y $missing > /dev/null 2>&1
echo -e "\n ${GRN}Dependencies installed. Proceeding...${CRS}\n" echo -e "\n ${GRN}Dependencies installed. Proceeding...${CRS}\n"
sudo rm /tmp/installed_dev /tmp/missing_dev 2>/dev/null sudo rm /tmp/LoMeS/installed_dev /tmp/LoMeS/missing_dev 2>/dev/null
break break
elif [[ "$install_dep" == "n" || "$install_dep" = "N" ]]; then elif [[ "$install_dep" == "n" || "$install_dep" = "N" ]]; then
echo -e "\n ${RED}Missing dependencies... Exiting!${CRS}\n" echo -e "\n ${RED}Missing dependencies... Exiting!${CRS}\n"
sudo rm /tmp/installed_dev /tmp/missing_dev 2>/dev/null sudo rm /tmp/LoMeS/installed_dev /tmp/LoMeS/missing_dev 2>/dev/null
exit 1 exit 1
else else
@ -95,7 +95,7 @@ echo -e " ${YEL}Current ip address : ${LCY}$ip4 ${YEL}@ ${LCY}$nif${CRS}"
echo -e "\n ${YEL}This information will be used to configure ${LCY}nginx.conf ${YEL}during the next steps.${CRS}" echo -e "\n ${YEL}This information will be used to configure ${LCY}nginx.conf ${YEL}during the next steps.${CRS}"
while true; do while true; do
read -p " Would you like to change the hostname? (y/N) --> " conf_hostname read -p " Would you like to change the hostname? (y/N) --> " conf_hostname ### HOST NAME CHANGE ?
if [[ "$conf_hostname" = "" || "$conf_hostname" = "n" || "$conf_hostname" = "N" ]]; then if [[ "$conf_hostname" = "" || "$conf_hostname" = "n" || "$conf_hostname" = "N" ]]; then
new_hostname=$(hostname) new_hostname=$(hostname)
@ -108,6 +108,7 @@ while true; do
sudo systemctl restart NetworkManager 2>/dev/null sudo systemctl restart NetworkManager 2>/dev/null
hostname -F /etc/hostname 2>/dev/null hostname -F /etc/hostname 2>/dev/null
echo -e "\n ${GRN}Host name changed to ${LCY}$(hostname)${CRS}" echo -e "\n ${GRN}Host name changed to ${LCY}$(hostname)${CRS}"
echo "HC" > /tmp/LoMeS/honacha
break break
else else
@ -119,8 +120,9 @@ done
###### CERTIFICATION & CONFIGURATION ###### CERTIFICATION & CONFIGURATION
while true; do while true; do
echo -e "\n ${YEL}Configure SSL and create a self signed cetrificate?${CRS}" echo -e "\n ${YEL}Configure SSL and create a self signed cetrificate?"
read -p " (Y/n) --> " installSSL read -p " (Y/n) --> " installSSL
echo -e "${CRS}"
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}"
@ -136,8 +138,9 @@ while true; do
: :
fi fi
echo -e " ${YEL}Enter file name for certificate and key${CRS}" echo -e " ${YEL}Enter file name for certificate and key"
read -p " default = $(hostname) --> " cert_name read -p " default = $(hostname) --> " cert_name
echo -e "${CRS}"
if ! [ "$cert_name" ]; then if ! [ "$cert_name" ]; then
cert_name=$(hostname) cert_name=$(hostname)
@ -169,20 +172,61 @@ while true; do
fi fi
done done
###### MAINTENANCE ###### NGINX MAINTENANCE & LANDING PAGE
sudo rm -rf /var/www/html sudo rm -rf /var/www/html
sudo cp -R assets/html /var/www sudo cp -R assets/html /var/www
sudo nginx -t
sudo nginx -s reload if ! [ "$(sudo nginx -t > /dev/null 2>&1)" ]; then ### NGINX CONF CHECK
echo -e "\n ${LGN}Nginx configuration checks out...${CRS}"
else
echo -e "\n ${LRD}Nginx configuration is malformed!${CRS}"
echo "nginx -t --> failed" >> /tmp/LoMeS/install_log
fi
if ! [ "$(sudo nginx -s reload > /dev/null 2>&1)" ]; then ### RELOAD NGINX
echo -e "\n ${LGN}Nginx reloaded...${CRS}"
else
echo -e "\n ${LRD}Nginx couldn't reload!${CRS}"
echo "nginx -s reload --> failed" >> /tmp/LoMeS/install_log
fi
if ! [ -f "/tmp/LoMeS/install_log" ]; then ### LOG CHECK
echo -e "\n ${LGN}No errors while setting up...${CRS}"
else
echo -e "\n ${LRD}Error occured while setting up! Please check ${LCY}/tmp/LoMeS/install_log ${LRD}for details...${CRS}"
fi
if [ -f "/tmp/LoMeS/honacha" ]; then ### HOST NAME CHANGE !?
echo -e "\n ${YEL}During setup you changed this machines host name. For the change to take effect, you should reboot\n "
while true; do
read -p " Would you like to reboot? (Y/n) --> " reboot
echo -e "${CRS}"
if [[ "$reboot" = "" || "$reboot" = "y" || "$reboot" = "Y" ]]; then
sudo reboot
break
elif [[ "$reboot" = "n" || "$reboot" = "N" ]]; then
break
else
echo -e "\n ${YEL}Invalid response... Try again...\n\n Y = (Yes, reboot)\n N = (No, don't reboot)${CRS}\n "
fi
done
else
:
fi
###### STATUS ###### STATUS
#echo -e "\n ${LGN}Mandatory packages have been installed\n ${LCY}$cert_name.crt ${LGN}and ${LCY}$cert_name.key ${LGN}created in ${LCY}$cert_path${CRS}\n"
### DEV STATUS
#echo -e "\n ${LGN}Script ran through...${CRS}"
###### JEFF ###### ###### JEFF ######
# #