From 79688305fd69af7ed5694b72e34f8ff9264e4206 Mon Sep 17 00:00:00 2001
From: Simone Margaritelli <evilsocket@gmail.com>
Date: Thu, 17 Oct 2019 13:42:05 +0200
Subject: [PATCH] fix: fixed reboot procedure (fixes #313)

---
 pwnagotchi/__init__.py | 6 ++++++
 pwnagotchi/agent.py    | 4 +---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pwnagotchi/__init__.py b/pwnagotchi/__init__.py
index c75af90..af9d12d 100644
--- a/pwnagotchi/__init__.py
+++ b/pwnagotchi/__init__.py
@@ -65,3 +65,9 @@ def shutdown():
         time.sleep(5)
     os.system("sync")
     os.system("halt")
+
+
+def reboot():
+    logging.warning("rebooting ...")
+    os.system("sync")
+    os.system("shutdown -r now")
diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py
index 497c91e..24013fb 100644
--- a/pwnagotchi/agent.py
+++ b/pwnagotchi/agent.py
@@ -481,9 +481,7 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer):
     def _reboot(self):
         self.set_rebooting()
         self._save_recovery_data()
-        logging.warning("rebooting the system ...")
-        os.system("/usr/bin/sync")
-        os.system("/usr/sbin/shutdown -r now")
+        pwnagotchi.reboot()
 
     def next_epoch(self):
         was_stale = self.is_stale()