Tweaks around restart handling after a successful startosinstall run

This commit is contained in:
Greg Neagle
2017-09-11 09:44:38 -07:00
parent c45b5e854b
commit 54713665be
2 changed files with 20 additions and 5 deletions

View File

@@ -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

View File

@@ -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