init: workspace opencode sync
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import librouteros
|
||||
|
||||
api = librouteros.connect('192.168.100.2', 'mi4', 'm14', port=8728)
|
||||
|
||||
scheduler_names = ["Bulanan2", "Bulanan4", "vc-2K3J", "vc-5K10J", "Family", "DevB2"]
|
||||
|
||||
print("=== Fixing scheduler on-event ===")
|
||||
all_schedulers = list(api('/system/scheduler/print'))
|
||||
for item in all_schedulers:
|
||||
name = item['name']
|
||||
if name not in scheduler_names:
|
||||
continue
|
||||
|
||||
oe = item['on-event']
|
||||
if ':pic' not in oe:
|
||||
print(f"{name}: no :pic found (already fixed)")
|
||||
continue
|
||||
|
||||
fixed = oe.replace(':pic', ':pick')
|
||||
count = oe.count(':pic')
|
||||
|
||||
try:
|
||||
api('/system/scheduler/set', '.id=' + item['.id'], 'on-event=' + fixed)
|
||||
print(f"{name}: fixed {count} occurrences")
|
||||
except Exception as e:
|
||||
print(f"{name}: ERROR - {e}")
|
||||
|
||||
# Verify
|
||||
print("\n=== Verification ===")
|
||||
for item in list(api('/system/scheduler/print')):
|
||||
name = item['name']
|
||||
oe = item.get('on-event', '')
|
||||
has_pic = ':pic' in oe
|
||||
has_pick = ':pick' in oe
|
||||
status = 'FIXED' if has_pick and not has_pic else ('BROKEN' if has_pic else 'NONE')
|
||||
print(f" {name}: {status} (pic={has_pic} pick={has_pick})")
|
||||
|
||||
# Fix profile on-login
|
||||
print("\n=== Fixing profile on-login ===")
|
||||
profile_names = ["Bulanan2", "Bulanan4", "vc-2K3J", "vc-5K10J", "Family", "home", "DevB2"]
|
||||
|
||||
for item in list(api('/ip/hotspot/user/profile/print')):
|
||||
name = item['name']
|
||||
if name not in profile_names:
|
||||
continue
|
||||
|
||||
ol = item.get('on-login', '')
|
||||
if ':pic' not in ol:
|
||||
print(f"{name}: no :pic found (already fixed)")
|
||||
continue
|
||||
|
||||
fixed = ol.replace(':pic', ':pick')
|
||||
count = ol.count(':pic')
|
||||
|
||||
try:
|
||||
api('/ip/hotspot/user/profile/set', '.id=' + item['.id'], 'on-login=' + fixed)
|
||||
print(f"{name}: fixed {count} occurrences")
|
||||
except Exception as e:
|
||||
print(f"{name}: ERROR - {e}")
|
||||
|
||||
# Verify profiles
|
||||
print("\n=== Profile Verification ===")
|
||||
for item in list(api('/ip/hotspot/user/profile/print')):
|
||||
name = item['name']
|
||||
ol = item.get('on-login', '')
|
||||
has_pic = ':pic' in ol
|
||||
has_pick = ':pick' in ol
|
||||
status = 'FIXED' if has_pick and not has_pic else ('BROKEN' if has_pic else 'NONE')
|
||||
print(f" {name}: {status}")
|
||||
|
||||
api.close()
|
||||
print("\nDONE")
|
||||
Reference in New Issue
Block a user