Re-install JSS Management

yurypanasyuk
New Contributor III

Hey Everyone,

Is there a script available to properly re-install management? Im currently trying with the below bash script but it seems to get hung up on 'jamf removeFramework'. If i run it as a single command via terminal it works fine. Our installer is copied to every machine and also works fine if run one command at a time.

#!/bin/sh

sudo /usr/sbin/jamf removeFramework

cd /Library/ClientEng/security/installers/Casper

sudo installer -pkg QuickAdd.pkg -target /

networksetup -setairportpower airport on

exit 0
5 REPLIES 5

mm2270
Legendary Contributor III

Well, if you're running your entire script from a Jamf Pro policy, then the first line is essentially telling it to remove itself, which would be why it's hanging up. There's no way for the script to continue to run after the jamf binary was just removed, since the jamf binary is what's running it to begin with.
You'd need to come up with some other method of kicking off the installation of the package, like creating a LaunchDaemon and script that would get triggered after the jamf binary is removed, so it's completely independent of the main script.

But the bigger question is, what exactly are you attempting to solve with the above? I sense there's some larger issue you haven't explained that caused you to go down this direction. Maybe there's a better solution than ripping out the framework and re-installing it.

rhoward
Contributor

You can also just use:

sudo jamf removemdmprofile
sudo jamf manage

This won't remove the framework which should fix the issue you are having.

yurypanasyuk
New Contributor III

We have a few configuration profiles and every now and then a machine will have issues re-authenticating to our network for whatever reason. So reinstalling management does the trick since it removes all profiles and adds them back in.

yurypanasyuk
New Contributor III

Thanks everyone. But i need a solution through bash. Can anyone point me to an example of a script to create a LaunchDaemon or another solution?

rtrouton
Release Candidate Programs Tester

@yurypanasyuk,

I wrote a script a while back for running a post-OS upgrade inventory, which deployed a LaunchDaemon and script to kick off the inventory using the jamf binary. You may be able to adapt it to your needs. It's available via the link below:

https://github.com/rtrouton/rtrouton_scripts/tree/master/rtrouton_scripts/Casper_Scripts/post_os_upg...