Turn shutdown into restart

UESCDurandal
Contributor II

I'm setting a policy to run at logout but I need the Mac to always restart, even if the user had chosen to shutdown. Setting the policy to restart immediately does not override the original shutdown command.

Is there any way I can replace the shutdown command with a restart or set the Mac to power back on after the shutdown finishes?

1 ACCEPTED SOLUTION

tkimpton
Valued Contributor II

Hi there

That's quite a difficult one. Not sure if it's possible but you could always test it out scope to a specific machine. shutdown -r now at log out and see what happens when you shutdown.

My instinct tells me the machine will just shut down :(

Only way is possible to disable the Shutdown button which would force the user to select logout.

I've done that in the past on 10.5 but the framework on nib files changed by Apple and it's not longer possible to modify them :(

View solution in original post

5 REPLIES 5

tkimpton
Valued Contributor II

Hi there

That's quite a difficult one. Not sure if it's possible but you could always test it out scope to a specific machine. shutdown -r now at log out and see what happens when you shutdown.

My instinct tells me the machine will just shut down :(

Only way is possible to disable the Shutdown button which would force the user to select logout.

I've done that in the past on 10.5 but the framework on nib files changed by Apple and it's not longer possible to modify them :(

UESCDurandal
Contributor II

Just confirmed that "shutdown -r now" in the execute command field of the policy DOES turn a shutdown into a restart! Thanks!

skinford
Contributor III

I'm very new to Casper and this is what I've wanted to do for shutdown restarts.

I will learn things as I progress but if someone tells me where this should be created and how, I would like to try it on a test system first. I've gone through many of the menus looking for a logical place to create it but I alas am stumped. Thank you for any and all input on how to create and implement this.

Have a very great afternoon today!

mm2270
Legendary Contributor III

@skinford This is a bit of an old thread, and not really sure if the above would work now under 10.10 or 10.11, but my guess is the OP created a policy scoped to all Macs, or a subset of Macs, that uses the Logout trigger set to execute on a recurring frequency. In the "Files and Processes" payload he put a command in the "Execute Command" field that had the following:

shutdown -r now

This would presumably mean that at logout the policy would trigger and do an immediate reboot of the Mac.

Some thing to keep in mind with this. Doing shutdown -r now is not a "graceful" reboot as you would get from choosing restart from the Apple menu. It forces the Mac to immediately restart, ignoring any processes that need to be closed in a proper way. I'd be wary of using something like this myself. Also, there is no "shutdown" trigger, so the only trigger you can use is "logout". This means if a user decides to log out and log back into their Mac, the Mac will suddenly restart instead making it to the login window. This may effectively make it impossible to log out of one account and into another on these Macs since it will never make it to the login window, at least not long enough to actually log in as someone else. The only way to bypass it, short of removing it from scope would be to disconnect it from the network prior to doing a logout, that is, assuming you don't use the "Make available offline" option in the policy, which would make it run all the time regardless of if it can contact the JSS.

Just a few caveats to keep in mind.

skinford
Contributor III

@mm2270 Thank you for the comment. I was trying to make it so the IMac's couldn't be turned off. We are a college in 7 locations all over the county. So when classes turn them off its not easy getting them turned on when we need them on.

I appreciate your help and if you might know a script or something to address that, it would be greatly appreciated.