From 54713665be52965bd70d41fc39833f0b9fbfa6c7 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Mon, 11 Sep 2017 09:44:38 -0700 Subject: [PATCH] Tweaks around restart handling after a successful startosinstall run --- code/client/managedsoftwareupdate | 19 ++++++++++++++++--- code/client/munkilib/osinstaller.py | 6 ++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/code/client/managedsoftwareupdate b/code/client/managedsoftwareupdate index 0531db96..e8b8b9cc 100755 --- a/code/client/managedsoftwareupdate +++ b/code/client/managedsoftwareupdate @@ -251,15 +251,28 @@ def doInstallTasks(do_apple_updates, only_unattended=False): # install macOS try: success = osinstaller.run(finishing_tasks=doFinishingTasks) - except: + except SystemExit: + # we _expect_ this since startosinstall or osinstaller will + # initiate a restart after successfully setting up a macOS + # install. + pass + except Exception: + # some other non-system-exiting exception occurred display.display_error( 'Unexpected error in munkilib.osinstaller:') munkilog.log(traceback.format_exc()) reports.savereport() raise if success: - # startosinstall will be restarting; get out of the way - sys.exit() + # we really should not get here. If successful, either + # startosinstall or osinstaller.run should have initiated a + # restart. + # Print a warning, and restart anyway. + display.display_warning( + 'Restart not initiated by startosinstall; will initiate ' + 'restart ourselves') + if not authrestartd.restart(): + authrestart.do_authorized_or_normal_restart() if do_apple_updates: # install Apple updates diff --git a/code/client/munkilib/osinstaller.py b/code/client/munkilib/osinstaller.py index 50fb38d1..dee385eb 100644 --- a/code/client/munkilib/osinstaller.py +++ b/code/client/munkilib/osinstaller.py @@ -359,8 +359,10 @@ class StartOSInstallRunner(object): # startosinstall exited munkistatus.percent(100) retcode = job.returncode() - if self.dmg_mountpoint: - dmgutils.unmountdmg(self.dmg_mountpoint) + # previously we unmounted the disk image, but since we're going to + # restart very very soon, don't bother + #if self.dmg_mountpoint: + # dmgutils.unmountdmg(self.dmg_mountpoint) if retcode and not (retcode == 255 and self.got_sigusr1): # append stderr to our startosinstall_output