From fe8a4e8e5bf1e8f665bb0e7a99437e60d0d43ce2 Mon Sep 17 00:00:00 2001 From: Jakub Kadlcik Date: Thu, 18 May 2023 00:27:41 +0200 Subject: [PATCH] Create /var/run/reboot-required file Fix #195 --- tracer/controllers/default.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tracer/controllers/default.py b/tracer/controllers/default.py index d0ea3a0..a6848f5 100644 --- a/tracer/controllers/default.py +++ b/tracer/controllers/default.py @@ -69,6 +69,7 @@ def render(self): view.assign("applications", self.applications) view.assign("args", self.args) view.render() + self.create_reboot_required_file() exit(self.status_code()) def render_helpers(self): @@ -136,6 +137,15 @@ def status_code(self): code = 104 return code + def create_reboot_required_file(self): + """ + If a reboot is needed, create a /var/run/reboot-required file. + This is how Debian/Ubuntu distros does it. + """ + if self.applications.count_type(Applications.TYPES["STATIC"]): + with open("/var/run/reboot-required", "w") as fp: + fp.write("Tracer says reboot is required\n") + def _restartable_applications(self, applications, args): return applications.exclude_types([ Applications.TYPES['STATIC'],