Skip to content

Commit

Permalink
Merge pull request #3695 from vyos/mergify/bp/sagitta/pr-3654
Browse files Browse the repository at this point in the history
op-mode: T5514: Allow safe reboots to config defaults when config.boot is deleted (backport #3654)
  • Loading branch information
dmbaturin authored Jun 22, 2024
2 parents 5d46c64 + e5bb052 commit f9c45bb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion python/vyos/config_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/op_mode/powerctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def check_unsaved_config():
from vyos.config_mgmt import unsaved_commits
from vyos.utils.boot import boot_configuration_success

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

0 comments on commit f9c45bb

Please sign in to comment.