Update INSTALL.sh

This commit is contained in:
Stefan Pejcic 2024-07-23 12:08:21 +02:00 committed by GitHub
parent 84b4c5f6b2
commit 0f4134c724
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -171,6 +171,28 @@ if [ "$CUSTOM_VERSION" = false ]; then
fi fi
fi fi
# helper function used by nginx to edit https://github.com/stefanpejcic/openpanel-configuration/blob/main/nginx/vhosts/default.conf
is_valid_ipv4() {
local ip=$1
local IFS=.
local -a octets=($ip)
if [ ${#octets[@]} -ne 4 ]; then
return 1
fi
for octet in "${octets[@]}"; do
if ! [[ $octet =~ ^[0-9]+$ ]] || [ $octet -lt 0 ] || [ $octet -gt 255 ]; then
return 1
fi
done
return 0
}
# print fullwidth line # print fullwidth line
print_space_and_line() { print_space_and_line() {
@ -182,14 +204,11 @@ print_space_and_line() {
# Progress bar script # Progress bar script
PROGRESS_BAR_URL="https://raw.githubusercontent.com/pollev/bash_progress_bar/master/progress_bar.sh" PROGRESS_BAR_URL="https://raw.githubusercontent.com/pollev/bash_progress_bar/master/progress_bar.sh"
PROGRESS_BAR_FILE="progress_bar.sh" PROGRESS_BAR_FILE="progress_bar.sh"
wget "$PROGRESS_BAR_URL" -O "$PROGRESS_BAR_FILE" > /dev/null 2>&1 wget "$PROGRESS_BAR_URL" -O "$PROGRESS_BAR_FILE" > /dev/null 2>&1
if [ ! -f "$PROGRESS_BAR_FILE" ]; then if [ ! -f "$PROGRESS_BAR_FILE" ]; then
echo "Failed to download progress_bar.sh" echo "ERROR: Failed to download progress_bar.sh - Github is not reachable by your server: https://raw.githubusercontent.com"
exit 1 exit 1
fi fi
@ -198,7 +217,6 @@ source "$PROGRESS_BAR_FILE"
# Dsiplay progress bar # Dsiplay progress bar
FUNCTIONS=( FUNCTIONS=(
#FUNKCIJE
detect_os_and_package_manager detect_os_and_package_manager
update_package_manager update_package_manager
install_packages install_packages
@ -209,7 +227,6 @@ add_file_watcher
configure_docker configure_docker
download_and_import_docker_images download_and_import_docker_images
docker_compose_up docker_compose_up
#docker_compose_check_health
panel_customize panel_customize
set_premium_features set_premium_features
configure_nginx configure_nginx
@ -220,7 +237,7 @@ setup_ftp
set_system_cronjob set_system_cronjob
set_custom_hostname set_custom_hostname
generate_and_set_ssl_for_panels generate_and_set_ssl_for_panels
setup_ufw setup_firewall_service
setup_swap setup_swap
clean_apt_cache clean_apt_cache
verify_license verify_license
@ -253,6 +270,7 @@ main() {
# END helper functions # END helper functions
@ -556,31 +574,6 @@ configure_docker() {
} }
docker_compose_check_health(){
all_healthy=true
containers=$(docker ps --format '{{.Names}}\t{{.Status}}')
while IFS=$'\t' read -r name status; do
if [[ "$status" != *"(healthy)"* ]]; then
echo "Container $name is not healthy. Status: $status"
all_healthy=false
fi
done <<< "$containers"
# Proceed if all containers are healthy
if $all_healthy; then
echo "All containers are healthy. Proceeding with next installation steps..."
else
echo "Some containers are not healthy. Investigate and retry."
exit 1
fi
}
docker_compose_up(){ docker_compose_up(){
echo "Setting Openpanel and MySQL docker containers.." echo "Setting Openpanel and MySQL docker containers.."
@ -653,7 +646,7 @@ add_file_watcher(){
setup_ufw() { setup_firewall_service() {
if [ -z "$SKIP_FIREWALL" ]; then if [ -z "$SKIP_FIREWALL" ]; then
echo "Setting up the firewall.." echo "Setting up the firewall.."
@ -863,22 +856,13 @@ helper_function_for_nginx_on_aws_and_azure(){
# #
# https://stackoverflow.com/questions/3191509/nginx-error-99-cannot-assign-requested-address/13141104#13141104 # https://stackoverflow.com/questions/3191509/nginx-error-99-cannot-assign-requested-address/13141104#13141104
# #
# Check the status of nginx service and capture the output
nginx_status=$(systemctl status nginx 2>&1) nginx_status=$(systemctl status nginx 2>&1)
# Search for "Cannot assign requested address" in the output # Search for "Cannot assign requested address" in the output
if echo "$nginx_status" | grep -q "Cannot assign requested address"; then if echo "$nginx_status" | grep -q "Cannot assign requested address"; then
# If found, append the required line to /etc/sysctl.conf
echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf echo "net.ipv4.ip_nonlocal_bind = 1" >> /etc/sysctl.conf
# Reload the sysctl configuration
sysctl -p /etc/sysctl.conf sysctl -p /etc/sysctl.conf
# Change the bind ip in default nginx config
sed -i "s/IP_HERE/*/" /etc/nginx/sites-enabled/default sed -i "s/IP_HERE/*/" /etc/nginx/sites-enabled/default
debug_log "echo Configuration updated and applied." debug_log "echo Configuration updated and applied."
else else
debug_log "echo Nginx started normally." debug_log "echo Nginx started normally."
@ -967,8 +951,12 @@ configure_nginx() {
ln -s /etc/openpanel/nginx/vhosts/default.conf /etc/nginx/sites-enabled/default ln -s /etc/openpanel/nginx/vhosts/default.conf /etc/nginx/sites-enabled/default
# Replace IP_HERE with the value of $current_ip # Replace IP_HERE with the value of $current_ip
#sed -i "s/listen 80;/listen $current_ip:80;/" /etc/nginx/sites-enabled/default if is_valid_ipv4 "$current_ip"; then
# MAKES PROBLEMS, REWRITE! sed -i "s/listen 80;/listen $current_ip:80;/" /etc/nginx/sites-enabled/default
echo "Disabled access on IP address $current_ip:80 and Nginx will deny access to domains that are not added by users."
else
echo "WARNING: Invalid IPv4 address: $current_ip - First available domain will be served by Nginx on direct IP access."
fi
# Setting pretty error pages for nginx, but need to add them inside containers also! # Setting pretty error pages for nginx, but need to add them inside containers also!
mkdir /etc/nginx/snippets/ > /dev/null 2>&1 mkdir /etc/nginx/snippets/ > /dev/null 2>&1