From 477d393116e46a2fd97ae15d0193e218cdec8e7a Mon Sep 17 00:00:00 2001 From: iamromulan <50184035+iamromulan@users.noreply.github.com> Date: Sat, 20 Jul 2024 23:01:41 -0400 Subject: [PATCH] Update RM55x_rcPCIe_toolkit.sh --- RM55x_rcPCIe_toolkit.sh | 99 +++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 49 deletions(-) diff --git a/RM55x_rcPCIe_toolkit.sh b/RM55x_rcPCIe_toolkit.sh index 61c0244..6f728ec 100644 --- a/RM55x_rcPCIe_toolkit.sh +++ b/RM55x_rcPCIe_toolkit.sh @@ -155,65 +155,66 @@ ttl_setup() { overlay_check || return - if [ -f "$ttl_file" ]; then - while true; do - echo "Would you like to edit the TTL settings? (yes to continue, exit to quit):" - read -r response - if [ "$response" = "exit" ]; then - echo "Exiting..." - break - elif [ "$response" = "yes" ]; then - if [ ! -s "$ttl_file" ]; then - echo -e "\e[31mTTL is not enabled\e[0m" - else - ipv4_ttl=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}') - ipv6_ttl=$(grep 'ip6tables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}') - echo -e "\e[32mCurrent IPv4 TTL: $ipv4_ttl\e[0m" - echo -e "\e[32mCurrent IPv6 TTL: $ipv6_ttl\e[0m" - fi - echo -e "\e[32mType 0 to disable TTL\e[0m" - echo "Enter the TTL value (number only):" - read -r ttl_value - if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then - echo "Invalid input, please enter a number." - else - if [ "$ttl_value" -eq 0 ]; then - echo "Disabling TTL..." - > "$ttl_file" - else - echo "Setting TTL to $ttl_value..." - echo "iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value" > "$ttl_file" - echo "ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value" >> "$ttl_file" - fi - /bin/ash "$lan_utils_script" - fi + while true; do + if [ ! -f "$ttl_file" ]; then + echo "Creating $ttl_file..." + touch "$ttl_file" + + echo "Modifying $combine_function in $lan_utils_script..." + + # Backup the original script + cp "$lan_utils_script" "${lan_utils_script}.bak" + + # Add the local ttl_firewall_file line if it's not already present + if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then + sed -i '/local tcpmss_firewall_filev6/a \ local ttl_firewall_file=/etc/firewall.user.ttl' "$lan_utils_script" fi - done - else - echo "Creating $ttl_file..." - touch "$ttl_file" - echo "Modifying $combine_function in $lan_utils_script..." - - # Backup the original script - cp "$lan_utils_script" "${lan_utils_script}.bak" - - # Add the local ttl_firewall_file line if it's not already present - if ! grep -q "local ttl_firewall_file" "$lan_utils_script"; then - sed -i '/local tcpmss_firewall_filev6/a \ local ttl_firewall_file=/etc/firewall.user.ttl' "$lan_utils_script" + # Add the condition to include the ttl_firewall_file if it's not already present + if ! grep -q "if \[ -f \"\$ttl_firewall_file\" \]; then" "$lan_utils_script"; then + sed -i '/if \[ -f "\$tcpmss_firewall_filev6" \]; then/i \ if [ -f "\$ttl_firewall_file" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi' "$lan_utils_script" + fi fi - # Add the condition to include the ttl_firewall_file if it's not already present - if ! grep -q "if \[ -f \"\$ttl_firewall_file\" \]; then" "$lan_utils_script"; then - sed -i '/if \[ -f "\$tcpmss_firewall_filev6" \]; then/i \ if [ -f "\$ttl_firewall_file" ]; then\n cat \$ttl_firewall_file >> \$firewall_file\n fi' "$lan_utils_script" + if [ ! -s "$ttl_file" ]; then + echo -e "\e[31mTTL is not enabled\e[0m" + else + ipv4_ttl=$(grep 'iptables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}') + ipv6_ttl=$(grep 'ip6tables -t mangle -A POSTROUTING' "$ttl_file" | awk '{print $10}') + echo -e "\e[32mCurrent IPv4 TTL: $ipv4_ttl\e[0m" + echo -e "\e[32mCurrent IPv6 TTL: $ipv6_ttl\e[0m" fi - ttl_setup - fi + echo -e "\e[32mType 0 to disable TTL\e[0m" + echo "Would you like to edit the TTL settings? (yes to continue, exit to quit):" + read -r response + + if [ "$response" = "exit" ]; then + echo "Exiting..." + break + elif [ "$response" = "yes" ]; then + echo "Enter the TTL value (number only):" + read -r ttl_value + if ! [[ "$ttl_value" =~ ^[0-9]+$ ]]; then + echo "Invalid input, please enter a number." + else + if [ "$ttl_value" -eq 0 ]; then + echo "Disabling TTL..." + > "$ttl_file" + else + echo "Setting TTL to $ttl_value..." + echo "iptables -t mangle -A POSTROUTING -o rmnet+ -j TTL --ttl-set $ttl_value" > "$ttl_file" + echo "ip6tables -t mangle -A POSTROUTING -o rmnet+ -j HL --hl-set $ttl_value" >> "$ttl_file" + fi + /bin/ash "$lan_utils_script" + fi + fi + done } + # Function for Tailscale Submenu tailscale_menu() { while true; do