From 88b6343c203e0fef08ab9ced3c77e10c64af503b Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Fri, 5 Jan 2024 18:32:31 -0500 Subject: [PATCH] Update beta.sh Fix persistence --- beta.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/beta.sh b/beta.sh index 7ec59a4..c6342ca 100644 --- a/beta.sh +++ b/beta.sh @@ -143,8 +143,9 @@ configure_simple_firewall() { return fi - echo "Current firewall configuration:" - ports=$(grep '^PORTS=' "$SIMPLE_FIREWALL_SCRIPT" | cut -d'=' -f2 | tr -d '()' | tr ' ' '\n' | grep -o '[0-9]\+') + # Extract current ports configuration + current_ports_line=$(grep '^PORTS=' "$SIMPLE_FIREWALL_SCRIPT") + ports=$(echo "$current_ports_line" | cut -d'=' -f2 | tr -d '()' | tr ' ' '\n' | grep -o '[0-9]\+') echo "$ports" | awk '{print NR") "$0}' while true; do @@ -165,15 +166,18 @@ configure_simple_firewall() { fi done - # Update the script with new ports + # Prepare updated ports line new_ports_line="PORTS=($(echo "$ports" | tr '\n' ' '))" - sed -i "s/^PORTS=(.*)$/$new_ports_line/" "$SIMPLE_FIREWALL_SCRIPT" + + # Update the script with new ports + sed -i "s/$current_ports_line/$new_ports_line/" "$SIMPLE_FIREWALL_SCRIPT" systemctl restart simplefirewall echo "Firewall configuration updated." } + # Function for Simplefirewall Submenu simplefirewall_menu() { while true; do