diff options
-rw-r--r-- | python/vyos/util.py | 13 | ||||
-rwxr-xr-x | src/op_mode/powerctrl.py | 3 |
2 files changed, 15 insertions, 1 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index e62f9d5cf..33da5da40 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -1139,6 +1139,19 @@ def boot_configuration_complete() -> bool: return True return False +def boot_configuration_success() -> bool: + from vyos.defaults import config_status + + try: + with open(config_status) as f: + res = f.read().strip() + except FileNotFoundError: + return False + + if int(res) == 0: + return True + return False + def sysctl_read(name): """ Read and return current value of sysctl() option """ tmp = cmd(f'sysctl {name}') diff --git a/src/op_mode/powerctrl.py b/src/op_mode/powerctrl.py index 239f766fd..dfacd45c2 100755 --- a/src/op_mode/powerctrl.py +++ b/src/op_mode/powerctrl.py @@ -104,8 +104,9 @@ def cancel_shutdown(): def check_unsaved_config(): from vyos.config_mgmt import unsaved_commits + from vyos.util import boot_configuration_success - if unsaved_commits(): + if unsaved_commits() 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: |