joshua-d-miller / macOSLAPS

Swift binary that will change a local administrator password to a random generated password. Similar behavior to LAPS for Windows
MIT License
382 stars 57 forks source link

LaunchDaemon not immediately activating #66

Closed franton closed 1 year ago

franton commented 2 years ago

Minor one. Doing an install from fresh doesn't automatically start the launchdaemon supplied. We have to wait for first reboot for that.

It would be possible to have a pre and a post install script that looks like this to take care of upgrades and starts:

#!/bin/zsh

#preinstall script

ld="/Library/LaunchDaemons/edu.psu.macoslaps-check.plist"

if [ -f "$ld" ];
then
    /bin/launchctl unload -w "$ld"
    /bin/rm -f "$ld"
    sleep 1
fi

exit
#!/bin/zsh

#postinstall

ld="/Library/LaunchDaemons/edu.psu.macoslaps-check.plist"
/bin/launchctl load -w "$ld"

exit
franton commented 2 years ago

I've provided a PR for this.

joshua-d-miller commented 2 years ago

Hello @franton!

I saw your pull request and the scripts look good. I might however modify them to use bootstrap and bootout as I believe eventually macOS will be moving to those and that load and unload are deprecated even though they still remain. I'm hoping to incorporate these as part of the package for the 2.2.0 release that is currently in BETA in the #macoslaps Slack channel. Please let me know your results if you are testing 2.2.0. Thanks!

franton commented 2 years ago

Hi @joshua-d-miller !

Sounds like an excellent plan to me! (I need to learn the new way and this sounds like a good way to do it.) See you in Slack!

joshua-d-miller commented 2 years ago

Hello @franton!

The prerelease has implemented these changes. Please give it a try and let me know: https://github.com/joshua-d-miller/macOSLAPS/releases/tag/3.0.0(752)

Thanks!

joshua-d-miller commented 1 year ago

This has been put in place into the latest build 3.0.2.