summaryrefslogtreecommitdiff
path: root/src/op_mode/powerctrl.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2023-06-06 21:17:52 +0100
committerGitHub <noreply@github.com>2023-06-06 21:17:52 +0100
commit4d029a3d0b23a8b11ffd18da9cb4e9c543e70d06 (patch)
tree671467a0459063b40dfe659c4a5bbac1495eb085 /src/op_mode/powerctrl.py
parentee14f9cd28313e76992e37ac0bf4856ddf1c5d76 (diff)
parent39b9959de61f407b5f25c24578a649c348ae3426 (diff)
downloadvyos-1x-4d029a3d0b23a8b11ffd18da9cb4e9c543e70d06.tar.gz
vyos-1x-4d029a3d0b23a8b11ffd18da9cb4e9c543e70d06.zip
Merge pull request #2028 from dmbaturin/T5262-reboot-warning
op mode: T5262: add a warning message about unsaved config changes on reboot and shutdown attempts
Diffstat (limited to 'src/op_mode/powerctrl.py')
-rwxr-xr-xsrc/op_mode/powerctrl.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/op_mode/powerctrl.py b/src/op_mode/powerctrl.py
index fd4f86d88..b517527bb 100755
--- a/src/op_mode/powerctrl.py
+++ b/src/op_mode/powerctrl.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2018 VyOS maintainers and contributors
+# Copyright (C) 2023 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -102,8 +102,19 @@ def cancel_shutdown():
else:
print("Reboot or poweroff is not scheduled")
+def check_unsaved_config():
+ from vyos.config_mgmt import ConfigMgmt
+
+ c = ConfigMgmt()
+ if c._unsaved_commits():
+ print("Warning: there are unsaved configuration changes!")
+ print("Run 'save' command if you do not want to lose those changes after reboot/shutdown.")
+ else:
+ pass
def execute_shutdown(time, reboot=True, ask=True):
+ check_unsaved_config()
+
action = "reboot" if reboot else "poweroff"
if not ask:
if not ask_yes_no(f"Are you sure you want to {action} this system?"):