I am trying to create my first script to install a pre-defined package (always in the same location on every machine).When I run the command via Terminal, it does prompt for the root/admin password, which I type in and the installation works perfectly. When I send the command via Kaseya, it states that the script was successful, but I do not see the application installed (I've check after a reboot as well).So, my question boils down to: how do I send across a typed root/admin password?
Here is the script that I current have.executeShellCommand("cd /Users/servicemax/Downloads/", "Execute as System", "Max OS X", "Halt on Fail")executeShellCommand("sudo installer -pkg 'Sophos Anti-Virus Home Edition.pkg' -target /", "Execute as System", "Max OS X", "Halt on Fail")I would greatly appreciate feedback! :)
Just to confirm, you used the "installPKG()" command right?
You need to basically have 4 specific commands for the agent procedure when installing packages. For the first command, you need to specify where the source file is stored on the server. Here they are:
1) writeFile ("nameofpackage", "/full/path/on/destination.pkg", "Mac OS X", "Halt on Fail")
2) installPKG("/full/path/on/destination.pkg", "Mac OS X", "Halt on Fail")
3) deleteFile("/full/path/on/destination.pkg", "Mac OS X", "Halt on Fail")
4) sendEmail ("firstname.lastname@example.org", "Software Deployed - XXX.pkg", "Sophos installed", "All Operating Systems", "Halt on Fail")
Hope this helps and if this fails, then there may be something wrong with the package. Are you using the package from the installation media or did you make your own?
I am far from an expert, but I wold think that it uses the credential settings. (Just like windows end points). So therefore a local user on the mac. And must be sys admin level. I use a user admin on every mac in our company with the same password as my windows administrator accounts. You need this for Mac screen sharing and other things anyway.
Why not try to change the type of Kaseya procedure you are using to install the package instead of running a shell command?
You can do this by going to Agent Procedures, create a new procedure and under Available Procedures, go to installPKG(). Now you can install any package (PKG) file by simply stating the location of that file on the system. You can even add a "sendEmail()" procedure to send out to you when the package has successfully installed. Let me know if you have any questions.
Thanks for the suggestion. I did upload the installation file and schedule it for installation onto my Macbook Pro - 2 minute window from the exact time. Unfortunately, 20 minutes later, and 1 restart too, it was not installed. No Sophos icon was present in the app bar across the top right.
I tested this theory by manually installing Sophos and rebooted (again, just to be sure). The Sophos icon appeared correctly in the app bar across the top right.
So, it is pretty clear that the scheduled installation did not work.
I hope there is a solution that works, as time goes on, the amount of installations I have to perform increases.
Thanks again for the reply. At current, this is the script exactly as it exists:
1. executeShellCommand("cd /Users/username/Downloads/", "Execute as System", "Max OS X", "Halt on Fail")
2. executeShellCommand("sudo installer -pkg 'Sophos Anti-Virus.pkg' -target /", "Execute as System", "Max OS X", "Halt on Fail")
I used the 'New Procedure' icon to create this. Apparently some things needs to be added later manually.
Thanks for the assistance! I'll try editing the script and see how it works.
Your notes concerning the full script were tremendously helpful and exactly what I needed! :)
I needed to sort out a few more details (file name, etc), but it works! :)
Thanks for the assistance!
Ok I have tried this just without the deletefile command and sendEmail. The package copies but doesn't install. Any ideas?
In your installDMG() step, make sure you use the full path: /tmp/Office 2011.pkg
Smason is correct - you made the same mistake in both procedures.
Kaseya does not execute shell commands in a continuous interactive-style shell.
Picture yourself opening a terminal/command prompt, typing a single command, and then exiting it after that command runs.
Your next command will follow the same process, meaning the directory you may have previous changed to or any variables that may have been set within the shell will be gone or back to their defaults.
One thing you *can* do if you really want is use "&&" between your commands in a single step, like this:
cd /Users/username/Downloads/ && sudo installer -pkg 'Sophos Anti-Virus.pkg' -target /
You should just use the installPKG command though, as it essentially does the same thing with some additional error handling.
I'm trying to do a shell command with Mac also. How do I build this with Kaseya. Do I do the executeshellcommand then type in my command:
do shell script "sudo spctl --master-disable" user name "Administrator" password "password29" with administrator privileges
Yes -- using rgw execute shell command step will run your command in the OS X terminal basically as 'root'.
Keep in mind certain characters may need to be escaped and it may not necessarily work exactly as if you were typing something in an interactive terminal.
Is there a way to install or open a app this way. I have Sophos Antivirus and its a .app file it opens and downloads the install info from a server. How would I make a procedure for this?
Sophos seems to support it, but I don't see any details about it being a .App.
Check this article here and ask Sophos for further assistance:
How can I run a .command file Its a uninstaller for Symantec antivirus?
You'll need to check with Symantec on that. I have personally not seen a .command, though I've only been using OS X for 6 years or so.