Skip to content

Commit 8281383

Browse files
committedJun 18, 2024·
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
1 parent da5d29a commit 8281383

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed
 

‎python/vyos/config_mgmt.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ def save_config(target, json_out=None):
8181
if rc != 0:
8282
logger.critical(f'save config failed: {out}')
8383

84-
def unsaved_commits() -> bool:
84+
def unsaved_commits(allow_missing_config=False) -> bool:
8585
if get_full_version_data()['boot_via'] == 'livecd':
8686
return False
87+
if allow_missing_config and not os.path.exists(config_file):
88+
return True
8789
tmp_save = '/tmp/config.running'
8890
save_config(tmp_save)
8991
ret = not cmp(tmp_save, config_file, shallow=False)

‎src/op_mode/powerctrl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def check_unsaved_config():
110110
from vyos.config_mgmt import unsaved_commits
111111
from vyos.utils.boot import boot_configuration_success
112112

113-
if unsaved_commits() and boot_configuration_success():
113+
if unsaved_commits(allow_missing_config=True) and boot_configuration_success():
114114
print("Warning: there are unsaved configuration changes!")
115115
print("Run 'save' command if you do not want to lose those changes after reboot/shutdown.")
116116
else:

0 commit comments

Comments
 (0)
Please sign in to comment.