Development
This commit is contained in:
parent
cc2f57aa83
commit
74166f03bd
11 changed files with 986 additions and 61 deletions
|
|
@ -2171,58 +2171,8 @@ def disable_avahi():
|
|||
|
||||
|
||||
def show_status(data):
|
||||
import shutil
|
||||
col = shutil.get_terminal_size((80, 24)).columns
|
||||
|
||||
def svc_row(unit, expected_active="active"):
|
||||
r_active = subprocess.run(["systemctl", "is-active", unit], capture_output=True, text=True)
|
||||
r_enabled = subprocess.run(["systemctl", "is-enabled", unit], capture_output=True, text=True)
|
||||
active = r_active.stdout.strip()
|
||||
enabled = r_enabled.stdout.strip()
|
||||
active_sym = "+" if active == "active" else "x"
|
||||
enabled_sym = "+" if enabled == "enabled" else "x"
|
||||
active_ok = "(OK) " if active == expected_active else "(BAD)"
|
||||
enabled_ok = "(OK) " if enabled == "enabled" else "(BAD)"
|
||||
return active_sym, active, active_ok, enabled_sym, enabled, enabled_ok
|
||||
|
||||
units = []
|
||||
for vlan in data["vlans"]:
|
||||
iface = derive_interface(vlan, data)
|
||||
if is_wg(vlan) and not wg_interface_up(iface):
|
||||
units.append((vlan_service_name(vlan, iface), "(wg0 not up)", "active"))
|
||||
else:
|
||||
units.append((vlan_service_name(vlan, iface), None, "active"))
|
||||
units.append((f"{BLIST_TIMER_NAME}.timer", None, "active"))
|
||||
units.append((NAT_SERVICE_NAME, None, "inactive")) # oneshot - exits after running
|
||||
units.append(("freeradius", None, "active"))
|
||||
units.append(("avahi-daemon", None, "active"))
|
||||
|
||||
print(f" {'UNIT':<45} {'ACTIVE':<18} {'ENABLED'}")
|
||||
print(f" {'-'*45} {'-'*18} {'-'*15}")
|
||||
for unit, note, expected_active in units:
|
||||
if note:
|
||||
print(f" {unit:<45} {note}")
|
||||
else:
|
||||
active_sym, active, active_ok, enabled_sym, enabled, enabled_ok = svc_row(unit, expected_active)
|
||||
print(f" {unit:<45} {active_sym} {active:<10} {active_ok} {enabled_sym} {enabled:<10} {enabled_ok}")
|
||||
|
||||
# Timer next trigger
|
||||
r = subprocess.run(
|
||||
["systemctl", "show", f"{BLIST_TIMER_NAME}.timer", "--property=NextElapseUSecRealtime,NextElapseUSecMonotonic"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
# Fall back to human-readable 'Trigger' field from status output
|
||||
r2 = subprocess.run(
|
||||
["systemctl", "status", f"{BLIST_TIMER_NAME}.timer", "--no-pager"],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
for line in r2.stdout.splitlines():
|
||||
line = line.strip()
|
||||
if line.startswith("Trigger:"):
|
||||
trigger = line.split("Trigger:", 1)[1].strip()
|
||||
if trigger and trigger != "n/a":
|
||||
print(f"\n Next blocklist update: {trigger}")
|
||||
break
|
||||
import status as _status
|
||||
_status.print_table(_status.run_and_write(data))
|
||||
|
||||
def show_configs(data):
|
||||
for vlan in data["vlans"]:
|
||||
|
|
@ -3167,6 +3117,9 @@ def cmd_apply(data, dry_run=False):
|
|||
|
||||
print("Done.")
|
||||
|
||||
import status as _status
|
||||
_status.print_table(_status.run_and_write(data))
|
||||
|
||||
|
||||
def cmd_update_blocklists(data):
|
||||
"""--update-blocklists: download and merge blocklists. On success, call
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue