diff --git a/scripts/patch_network_manual_ip_field.py b/scripts/patch_network_manual_ip_field.py new file mode 100644 index 0000000..1ba459d --- /dev/null +++ b/scripts/patch_network_manual_ip_field.py @@ -0,0 +1,25 @@ +#!/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')