38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
import re
|
|
|
|
src = "/Users/christophemsenhuber/dev/bf-network-r6/routeros/crs326-core-pre-cutover-20260806-073712.rsc"
|
|
dst = "/Users/christophemsenhuber/dev/bf-network-r6/routeros/crs326-core-pre-cutover-20260806-073712-fixed.rsc"
|
|
|
|
with open(src) as f:
|
|
lines = f.readlines()
|
|
|
|
out = []
|
|
i = 0
|
|
while i < len(lines):
|
|
line = lines[i]
|
|
if line.startswith("add admin-mac=04:F4:1C:B4:17:76 auto-mac=no comment=defconf name=bridge"):
|
|
out.append("set [find name=bridge] admin-mac=04:F4:1C:B4:17:76 auto-mac=no vlan-filtering=yes\n")
|
|
i += 1
|
|
while i < len(lines) and (lines[i].startswith(" ") or lines[i].strip().startswith("vlan-filtering")):
|
|
i += 1
|
|
continue
|
|
if re.match(r'set \[ find default-name=ether(3|4|5|6|7|8|9|1[0-9]|2[0-4]) \] disabled=yes', line):
|
|
i += 1
|
|
continue
|
|
if line.startswith("/interface bridge port"):
|
|
out.append(line)
|
|
i += 1
|
|
while i < len(lines) and not lines[i].startswith("/"):
|
|
i += 1
|
|
out.append("set [find interface=ether2] pvid=40\n")
|
|
out.append("set [find interface=ether3] pvid=40\n")
|
|
out.append("set [find interface=ether5] pvid=40\n")
|
|
continue
|
|
out.append(line)
|
|
i += 1
|
|
|
|
with open(dst, "w") as f:
|
|
f.writelines(out)
|
|
print("fixed rsc written to", dst)
|