From 66a464f7d04b9b8abed578b7ba9456a50ee9a3f8 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 4 May 2023 12:56:26 +0200 Subject: live: rewrite reboot operation Add optional 'operation' parameter to _poweroff_oglive function. Reuse _poweroff_oglive code before the busybox subprocess when rebooting an ogLive client. --- src/live/ogOperations.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/live') diff --git a/src/live/ogOperations.py b/src/live/ogOperations.py index a86db5c..6f759d7 100644 --- a/src/live/ogOperations.py +++ b/src/live/ogOperations.py @@ -190,7 +190,7 @@ class OgLiveOperations: with open(logfile, 'wb', 0) as f: f.truncate(0) - def _poweroff_oglive(self): + def _poweroff_oglive(self, operation='poweroff'): interface = os.getenv('DEVICE') cmd_ethtool = shlex.split(f'ethtool -s {interface} wol g') cmd_browser = shlex.split('pkill -9 browser') @@ -198,7 +198,7 @@ class OgLiveOperations: busybox = 'busybox' else: busybox = shutil.which('busyboxOLD') - cmd_busybox = shlex.split(f'{busybox} poweroff') + cmd_busybox = shlex.split(f'{busybox} {operation}') umount_all() umount_cache() @@ -219,9 +219,7 @@ class OgLiveOperations: def reboot(self): logging.info('Rebooting client') if os.path.exists('/scripts/oginit'): - cmd = f'source {ogClient.OG_PATH}etc/preinit/loadenviron.sh; ' \ - f'{ogClient.OG_PATH}scripts/reboot' - subprocess.call([cmd], shell=True, executable=OG_SHELL) + self._poweroff_oglive(operation='reboot') else: subprocess.call(['/sbin/reboot']) -- cgit v1.2.3-18-g5258