MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / restart_networking

Method restart_networking

wifi_manager.py:2957–2979  ·  view source on GitHub ↗

Restart networking services

(self)

Source from the content-addressed store, hash-verified

2955 stdout, stderr = self.hostapd_process.communicate()
2956 self.logger.error("hostapd failed to start")
2957 self.ap_logger.error("hostapd failed to start")
2958 self.ap_logger.error(f"Hostapd stdout: {stdout.decode()}")
2959 self.ap_logger.error(f"Hostapd stderr: {stderr.decode()}")
2960 return False
2961
2962 self.ap_logger.info("Hostapd started successfully")
2963
2964 self.ap_logger.info("Starting dnsmasq service...")
2965 # Start dnsmasq with explicit interface binding
2966 self.dnsmasq_process = subprocess.Popen(['sudo', 'dnsmasq', '-C', '/tmp/ragnar/dnsmasq.conf', '-d', '--no-daemon'],
2967 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
2968
2969 self.ap_logger.debug(f"Dnsmasq process started with PID: {self.dnsmasq_process.pid}")
2970 time.sleep(1) # Give dnsmasq time to start
2971
2972 if self.dnsmasq_process.poll() is not None:
2973 stdout, stderr = self.dnsmasq_process.communicate()
2974 self.logger.warning("dnsmasq failed to start with DNS enabled, trying DHCP-only mode")
2975 self.ap_logger.warning("dnsmasq failed to start with DNS enabled")
2976 self.ap_logger.warning(f"Dnsmasq stdout: {stdout.decode()}")
2977 self.ap_logger.warning(f"Dnsmasq stderr: {stderr.decode()}")
2978
2979 # Try fallback mode without DNS
2980 self.ap_logger.info("Attempting fallback: DHCP-only mode without DNS")
2981
2982 # Create new config without DNS

Callers

nothing calls this directly

Calls 6

stop_ap_modeMethod · 0.95
infoMethod · 0.80
errorMethod · 0.80
runMethod · 0.45
sleepMethod · 0.45

Tested by

no test coverage detected