#!/usr/bin/env python3 from pathlib import Path import sys app_path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path('/opt/virtuality/web/app.py') template_path = app_path.with_name('templates') / 'network.html' if not template_path.exists(): raise SystemExit(f'network.html not found: {template_path}') text = template_path.read_text() old = '' new = '''''' if old in text: text = text.replace(old, new, 1) template_path.write_text(text) print('network manual IP field added') elif 'name="guest_ip" value="auto" placeholder="auto' in text: print('network manual IP field already present') else: raise SystemExit('guest_ip marker not found in network.html')