Noob to Bash—Having Trouble Restarting RMM Service via Script, Need Help"

Although I have a workaround, it's not ideal. The workaround is to force the computer to restart once the service stops, but it doesn't always work, and it’s not a reliable solution.

I’m running the bash script via an RMM tool where the script executes as root. The issue arises when using sudo through the terminal, as the script works fine there.

Here’s the command that works when run manually:

sudo launchctl bootout system /Library/LaunchDaemons/com.cenra.cag.plist sudo launchctl bootstrap system /Library/LaunchDaemons/com.cenra.cag.plist

The challenging part is that the service I'm trying to restart is actually the RMM itself (yes, the RMM is broken, haha).

What I’ve tried so far is running a cron job and saving the script in the logged-in user's profile under /Library, then executing it. The script is able to bootout the service, but it fails to bootstrap it.

I’ve even attempted to pass temporary admin credentials through the script itself.

I know I might be overthinking this, as this is only my second bash script. Any help would be greatly appreciated!