From 073b68ef1808b8aaf8dff03f9532cd33767cdab0 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Wed, 3 Mar 2021 11:08:41 -0800 Subject: [PATCH] Added reboot and kernel checks --- adafruit_shell.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/adafruit_shell.py b/adafruit_shell.py index 2ad7526..2046130 100644 --- a/adafruit_shell.py +++ b/adafruit_shell.py @@ -490,6 +490,22 @@ class Shell: return raspbian return None + def prompt_reboot(self): + """Prompt the user for a reboot""" + if not self.prompt("REBOOT NOW?", default="y"): + print("Exiting without reboot.") + else: + print("Reboot started...") + os.sync() + self.reboot() + self.exit() + + def check_kernel_update_reboot_required(self): + """Checks if the pi needs to be rebooted since the last kernel update""" + if not self.exists("/lib/modules/{}".format(self.release())): + self.error("OS has not been rebooted since last kernel update.") + self.prompt_reboot() + # pylint: enable=invalid-name @staticmethod