Browse Source

Complying with PR

Wesley Reuel Marques Silva 3 months ago
parent
commit
0d7cf0f227
1 changed files with 23 additions and 6 deletions
  1. 23 6
      install/docker-install.sh

+ 23 - 6
install/docker-install.sh

@@ -398,6 +398,14 @@ parse_args() {
     done
 }
 
+check_sudo() {
+    if ! command -v sudo &>/dev/null; then
+        log_error "sudo is required for iptables redirect but is not installed. Skipping iptables redirect."
+        return 1
+    fi
+    return 0
+}
+
 configure_iptables_redirect() {
     if [[ "$OS_TYPE" != "linux" ]]; then
         log_warn "iptables redirect only supported on Linux. Skipping."
@@ -408,6 +416,10 @@ configure_iptables_redirect() {
         return
     fi
 
+    if ! check_sudo; then
+        return
+    fi
+
     log_info "Configuring iptables redirect: 990 -> 9990"
 
     # Check if rule already exists
@@ -451,11 +463,16 @@ gather_config() {
     fi
 
     # Redirect port 990 -> 9990 (Linux only)
-    if [[ "$OS_TYPE" == "linux" ]] && [[ "$REDIRECT_990" != "true" ]]; then
-        echo ""
-        echo "Optional network configuration:"
-        if prompt_yes_no "Add iptables redirect (990 -> 9990)?" "n"; then
-            REDIRECT_990="true"
+    if [[ "$OS_TYPE" == "linux" ]]; then
+        if [[ "$NON_INTERACTIVE" == "true" ]]; then
+            # In non-interactive mode, only set REDIRECT_990 if explicitly passed
+            : # Do nothing, REDIRECT_990 is set only if --redirect-990 is passed
+        elif [[ "$REDIRECT_990" != "true" ]]; then
+            echo ""
+            echo "Optional network configuration:"
+            if prompt_yes_no "Add iptables redirect (990 -> 9990)?" "n"; then
+                REDIRECT_990="true"
+            fi
         fi
     fi
 
@@ -594,4 +611,4 @@ main() {
     fi
 }
 
-main "$@"
+main "$@"