Skip to content

Commit

Permalink
FIX auto reboot: only ask user if a restart is needed, not always
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmax committed Dec 28, 2023
1 parent ed5b0d9 commit 13a3b1f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions FabLabKasse/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ def autoRebootOnUpdates(self):
Assumption: This function is only called directly after a successful payment, before the user has any chance to add new things to the cart or even start a new payment.
"""

# Determine if reboot/restart is needed
if os.path.isfile("/var/run/reboot-required"):
restart_type = "reboot"
elif time.monotonic() > self.startup_time + 48 * 3600:
restart_type = "restart"
else:
restart_type = None

if restart_type is None:
return

dialog = QtWidgets.QMessageBox(self)
dialog.setWindowModality(QtCore.Qt.WindowModal)
dialog.setText(
Expand All @@ -344,10 +356,8 @@ def autoRebootOnUpdates(self):
dialog.setEscapeButton(QtWidgets.QMessageBox.Cancel)
if dialog.exec_() != QtWidgets.QMessageBox.Ok:
return
if os.path.isfile("/var/run/reboot-required"):
self.do_restart("reboot")
elif time.monotonic() > self.startup_time + 48 * 3600:
self.do_restart("restart")

self.do_restart(restart_type)

def serviceMode(self):
"""was the service mode enabled recently? check and disable again"""
Expand Down

0 comments on commit 13a3b1f

Please sign in to comment.