@@ -121,13 +121,18 @@ def _emergency_lockdown(self) -> None:
121121
122122 # Step 4: Stop services
123123 self .console .print ("[blue]4. Stopping non-essential services...[/blue]" )
124- services_to_stop = ["vector" , "opencanary" ]
124+ services_to_stop = ["vector" ]
125125 for service in services_to_stop :
126126 try :
127127 run_cmd (["sudo" , "systemctl" , "stop" , f"{ service } .service" ], timeout = 15 )
128128 self .console .print (f"[green]✓ { service } stopped[/green]" )
129129 except Exception :
130130 self .console .print (f"[yellow]! { service } stop failed[/yellow]" )
131+ try :
132+ run_cmd (["sudo" , "docker" , "stop" , "azazel_opencanary" ], timeout = 30 )
133+ self .console .print ("[green]✓ azazel_opencanary stopped[/green]" )
134+ except Exception :
135+ self .console .print ("[yellow]! azazel_opencanary stop failed[/yellow]" )
131136
132137 self .console .print ("\n [bold red]EMERGENCY LOCKDOWN COMPLETED[/bold red]" )
133138 self .console .print ("[yellow]System is now in maximum security lockdown mode.[/yellow]" )
@@ -163,10 +168,10 @@ def _reset_network(self) -> None:
163168 run_cmd (["sudo" , "systemctl" , "stop" , "wpa_supplicant" ], timeout = 10 )
164169
165170 # Backup and reset wpa_supplicant.conf
166- run_cmd ([
167- "sudo" , "cp" , "/etc/wpa_supplicant/wpa_supplicant.conf" ,
168- f"/etc/wpa_supplicant/wpa_supplicant.conf.backup.{ datetime .now ().strftime ('%Y%m%d_%H%M%S' )} "
169- ], timeout = 5 )
171+ run_cmd ([
172+ "sudo" , "cp" , "/etc/wpa_supplicant/wpa_supplicant.conf" ,
173+ f"/etc/wpa_supplicant/wpa_supplicant.conf.backup.{ datetime .now ().strftime ('%Y%m%d_%H%M%S' )} "
174+ ], timeout = 5 )
170175
171176 # Create minimal wpa_supplicant.conf
172177 minimal_config = """ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
@@ -190,23 +195,23 @@ def _reset_network(self) -> None:
190195 # Reset network interfaces
191196 self .console .print ("[blue]2. Resetting network interfaces...[/blue]" )
192197 try :
193- run_cmd (["sudo" , "ip" , "link" , "set" , self .wan_if , "down" ], timeout = 5 )
194- run_cmd (["sudo" , "ip" , "link" , "set" , self .wan_if , "up" ], timeout = 5 )
195- run_cmd (["sudo" , "ip" , "link" , "set" , self .lan_if , "down" ], timeout = 5 )
196- run_cmd (["sudo" , "ip" , "link" , "set" , self .lan_if , "up" ], timeout = 5 )
198+ run_cmd (["sudo" , "ip" , "link" , "set" , self .wan_if , "down" ], timeout = 5 )
199+ run_cmd (["sudo" , "ip" , "link" , "set" , self .wan_if , "up" ], timeout = 5 )
200+ run_cmd (["sudo" , "ip" , "link" , "set" , self .lan_if , "down" ], timeout = 5 )
201+ run_cmd (["sudo" , "ip" , "link" , "set" , self .lan_if , "up" ], timeout = 5 )
197202 self .console .print ("[green]✓ Network interfaces reset[/green]" )
198203 except Exception as e :
199204 self .console .print (f"[red]✗ Interface reset failed: { e } [/red]" )
200205
201206 # Restart network services
202207 self .console .print ("[blue]3. Restarting network services...[/blue]" )
203208 services = ["dhcpcd" , "hostapd" ]
204- for service in services :
205- try :
206- run_cmd (["sudo" , "systemctl" , "restart" , service ], timeout = 15 )
207- self .console .print (f"[green]✓ { service } restarted[/green]" )
208- except Exception :
209- self .console .print (f"[yellow]! { service } restart failed[/yellow]" )
209+ for service in services :
210+ try :
211+ run_cmd (["sudo" , "systemctl" , "restart" , service ], timeout = 15 )
212+ self .console .print (f"[green]✓ { service } restarted[/green]" )
213+ except Exception :
214+ self .console .print (f"[yellow]! { service } restart failed[/yellow]" )
210215
211216 self .console .print ("\n [bold green]Network configuration reset completed[/bold green]" )
212217
@@ -292,7 +297,7 @@ def _system_report(self) -> None:
292297 # Service status
293298 report .write ("SERVICE STATUS\n " )
294299 report .write ("-" * 15 + "\n " )
295- services = ["azctl" , "azctl-serve" , "suricata" , "opencanary" , " vector" ]
300+ services = ["azctl" , "azctl-serve" , "suricata" , "vector" ]
296301 for service in services :
297302 try :
298303 result = run_cmd (
@@ -303,6 +308,7 @@ def _system_report(self) -> None:
303308 report .write (f"{ service } : { status } \n " )
304309 except Exception :
305310 report .write (f"{ service } : UNKNOWN\n " )
311+ report .write (f"azazel_opencanary (Docker): { 'ACTIVE' if self ._is_container_running ('azazel_opencanary' ) else 'INACTIVE' } \n " )
306312
307313 report .write ("\n " )
308314
@@ -402,4 +408,18 @@ def _factory_reset(self) -> None:
402408
403409 def _pause (self ) -> None :
404410 """Pause for user input."""
405- Prompt .ask ("\n [dim]Press Enter to continue[/dim]" , default = "" , show_default = False )
411+ Prompt .ask ("\n [dim]Press Enter to continue[/dim]" , default = "" , show_default = False )
412+
413+ def _is_container_running (self , container_name : str ) -> bool :
414+ """Check whether a Docker container is running."""
415+ try :
416+ result = run_cmd (
417+ ["docker" , "inspect" , "-f" , "{{.State.Running}}" , container_name ],
418+ capture_output = True ,
419+ text = True ,
420+ timeout = 5 ,
421+ check = False ,
422+ )
423+ return result .returncode == 0 and (result .stdout or "" ).strip ().lower () == "true"
424+ except Exception :
425+ return False
0 commit comments