Skip to content

Commit 20926bc

Browse files
committed
check for firewalld before unlocking ports
1 parent 6ae0af0 commit 20926bc

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

install.sh

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,6 @@ enable_passwordless_sudo() {
364364
install_nginx_and_php() {
365365
clear
366366

367-
# Check if firewalld is installed
368-
if ! command -v firewall-cmd &>/dev/null; then
369-
echo "Firewalld is not installed. Please install it before configuring firewall rules."
370-
return
371-
fi
372-
373367
# Check if NGINX is already installed
374368
if dpkg -l | grep -q "nginx"; then
375369
echo "NGINX is already installed. Skipping NGINX installation."
@@ -400,25 +394,31 @@ install_nginx_and_php() {
400394
echo "Firewall configuration"
401395
echo "#######################################################"
402396

403-
# Check if port 80 is open
404-
if ! sudo firewall-cmd --list-ports | grep -q "80/tcp"; then
405-
echo "Opening port 80 [TCP]..."
406-
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
407-
else
408-
echo "Port 80 [TCP] is already open. Skipping."
409-
fi
397+
# Check if firewalld is installed
398+
if ! command -v firewall-cmd &>/dev/null; then
399+
echo "Firewalld is not installed. Skipping."
410400

411-
# Check if port 443 is open
412-
if ! sudo firewall-cmd --list-ports | grep -q "443/tcp"; then
413-
echo "Opening port 443 [TCP]..."
414-
sudo firewall-cmd --permanent --zone=public --add-port=443/tcp
415401
else
416-
echo "Port 443 [TCP] is already open. Skipping."
417-
fi
402+
# Check if port 80 is open
403+
if ! sudo firewall-cmd --list-ports | grep -q "80/tcp"; then
404+
echo "Opening port 80 [TCP]..."
405+
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
406+
else
407+
echo "Port 80 [TCP] is already open. Skipping."
408+
fi
418409

419-
echo "Reload configuration..."
420-
sudo firewall-cmd --reload
421-
echo
410+
# Check if port 443 is open
411+
if ! sudo firewall-cmd --list-ports | grep -q "443/tcp"; then
412+
echo "Opening port 443 [TCP]..."
413+
sudo firewall-cmd --permanent --zone=public --add-port=443/tcp
414+
else
415+
echo "Port 443 [TCP] is already open. Skipping."
416+
fi
417+
418+
echo "Reload configuration..."
419+
sudo firewall-cmd --reload
420+
echo
421+
fi
422422

423423
# Create a directory for SSL certs if it doesn't exist
424424
if [ -d "/etc/nginx/cert" ]; then

0 commit comments

Comments
 (0)