Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions payload/Library/installapplications/installapplications.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,18 +342,32 @@ def cleanup(exit_code):
launchctl('/bin/launchctl', 'asuser', userid,
'/bin/launchctl', 'remove', laidentifier)

# Trigger a delayed reboot of 5 seconds
if reboot:
iaslog('Triggering reboot')
rebootcmd = [
'/usr/bin/osascript',
'-e',
'delay 5',
'-e',
'tell application "System Events" to restart'
]
try:
subprocess.Popen(rebootcmd, preexec_fn=os.setpgrp)
except: # noqa
pass

# Attempt to kill InstallApplications' path
iaslog('Attempting to remove InstallApplications directory: ' + iapath)
try:
shutil.rmtree(iapath)
except: # noqa
pass

if not reboot:
iaslog('Attempting to remove LaunchDaemon: ' + ldidentifier)
launchctl('/bin/launchctl', 'remove', ldidentifier)
iaslog('Cleanup done. Exiting.')
sys.exit(exit_code)
iaslog('Attempting to remove LaunchDaemon: ' + ldidentifier)
launchctl('/bin/launchctl', 'remove', ldidentifier)
iaslog('Cleanup done. Exiting.')
sys.exit(exit_code)


def main():
Expand Down Expand Up @@ -711,13 +725,9 @@ def main():
iaslog(
'Skipping DEPNotify notification event due to completion.')

# Cleanup and trigger a reboot if required.
# Cleanup and send good exit status
cleanup(0)

if reboot:
iaslog('Triggering reboot')
subprocess.call(['/sbin/shutdown', '-r', 'now'])


if __name__ == '__main__':
main()