Skip to content

Commit

Permalink
Merge pull request #2060 from jestabro/warning-boot-config-err
Browse files Browse the repository at this point in the history
T5320: warn on entering config mode if boot config errors present
  • Loading branch information
dmbaturin authored Jun 28, 2023
2 parents 6a2ddc4 + 186d05c commit 88282be
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
7 changes: 6 additions & 1 deletion op-mode-definitions/configure.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
echo "Please do it as an administrator level VyOS user instead."
else
if grep -q -e '^overlay.*/filesystem.squashfs' /proc/mounts; then
echo "WARNING: You are currently configuring a live-ISO environment, changes will not persist until installed"
echo "WARNING: You are currently configuring a live-ISO environment, changes will not persist until installed"
else
if grep -q -s '1' /tmp/vyos-config-status; then
echo "WARNING: There was a config error on boot: saving the configuration now could overwrite data."
echo "You may want to check and reload the boot config"
fi
fi
history -w
export _OFR_CONFIGURE=ok
Expand Down
13 changes: 13 additions & 0 deletions python/vyos/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
3 changes: 2 additions & 1 deletion src/op_mode/powerctrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 88282be

Please sign in to comment.