Check if required tools are available for the current platform.
(self)
| 35 | self.bridge_ip: Optional[str] = None |
| 36 | |
| 37 | def check_prerequisites(self) -> bool: |
| 38 | """Check if required tools are available for the current platform.""" |
| 39 | if self.os_type == "Darwin": # macOS |
| 40 | required_commands = ["ifconfig", "route", "sysctl", "pfctl"] |
| 41 | elif self.os_type == "Linux": |
| 42 | required_commands = ["ip", "brctl", "sysctl", "iptables"] |
| 43 | else: |
| 44 | return False |
| 45 | |
| 46 | for cmd in required_commands: |
| 47 | if not shutil.which(cmd): |
| 48 | print(f"❌ Error: Required command '{cmd}' not found") |
| 49 | if self.os_type == "Linux" and cmd == "brctl": |
| 50 | print(" Install with: sudo apt-get install bridge-utils") |
| 51 | return False |
| 52 | return True |
| 53 | |
| 54 | def run_command(self, cmd: list, check: bool = True, capture: bool = True) -> subprocess.CompletedProcess: |
| 55 | """Run a shell command with error handling.""" |