summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorAndrew Topp <andrewt@telekinetica.net>2024-06-19 09:48:45 +1000
committerAndrew Topp <andrewt@telekinetica.net>2024-06-19 09:48:45 +1000
commit8281383a09f12da20a1c9b4864b38ac3f541b48f (patch)
treea478d3a1fd38a2a58f49a25a56919e1707734948 /python/vyos
parentda5d29aa83666da52d5e7ba2c795a9220203e197 (diff)
downloadvyos-1x-8281383a09f12da20a1c9b4864b38ac3f541b48f.tar.gz
vyos-1x-8281383a09f12da20a1c9b4864b38ac3f541b48f.zip
op-mode: T5514: Allow safe reboots to config defaults when config.boot is deleted
* Added flag to vyos.config_mgmt.unsaved_commits() that will tolerate missing config.boot for specific circumstances * Shutdown/reboot uses this flag; config will regenerate from defaults after a reboot
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/config_mgmt.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/python/vyos/config_mgmt.py b/python/vyos/config_mgmt.py
index 70b6ea203..d518737ca 100644
--- a/python/vyos/config_mgmt.py
+++ b/python/vyos/config_mgmt.py
@@ -81,9 +81,11 @@ def save_config(target, json_out=None):
if rc != 0:
logger.critical(f'save config failed: {out}')
-def unsaved_commits() -> bool:
+def unsaved_commits(allow_missing_config=False) -> bool:
if get_full_version_data()['boot_via'] == 'livecd':
return False
+ if allow_missing_config and not os.path.exists(config_file):
+ return True
tmp_save = '/tmp/config.running'
save_config(tmp_save)
ret = not cmp(tmp_save, config_file, shallow=False)