Skip to main content

Edit: For those just looking for the final working version of the script, here it is:



#!/bin/bash



echo -e “Installing LsAgent…”

hdiutil attach “./LsAgent-osx.dmg” -nobrowse

/Volumes/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh --agentkey “Your_Cloud_Key” --mode unattended



echo -e “Cleaning up…”

hdiutil detach “/Volumes/LsAgent”

rm -f “/tmp/LsAgent-osx.dmg”



Helllo,


I am trying to install inventory agent LsAgent from Lansweeper to our MAC osx laptops without much luck.


Here is the required software code I am using:



#!/bin/bash



echo -e “Downloading LsAgent…”


curl -L “https://content.lansweeper.com/l/651653/2018-11-27/4d6yl” -o /tmp/LsAgent-osx.dmg



echo -e “Installing LsAgent…”


hdiutil attach “/tmp/LsAgent-osx.dmg” -nobrowse


~/Volumes/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh --agentkey “OUR-CODE” --mode unattended



echo -e “Cleaning up…”


hdiutil detach “/Volumes/LsAgent”


rm -f “/tmp/LsAgent-osx.dmg”



Any help would be appreciated.

Do you know where in the process it’s failing? Another approach would be to use the a required software policy, which allows you to upload the installer file and avoid having to download it each time the worklet runs.


Hi,


that is hard to tell because I don’t get any error message.


I think I am going to skip using curl to download the file to minimize the chance it is failing because of that.


If I include the file LSAgent-osx.dmg as the installation file in the worklet where does it gets downloaded to on the client computer?


It gets download into the same directory as the script that’s running, so you can just reference it directly:



Uploading Files



Any files you may need to reference in your remediation script can be uploaded as part of the policy. These files will download when the remediation runs and will be available in the current working directory of the script. As such, they can usually just be referred to by their file name, although some situations may require that you use the relative path. ( ./filename in Bash or .\filename in PowerShell)



from: https://support.automox.com/help/how-to-use-worklets


unfortunately if I do that I get this error:


Failed to install software: % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0 0 26.7M 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0 27 26.7M 27 7477k 0 0 4968k 0 0:00:05 0:00:01 0:00:04 4965k 41 26.7M 41 11.0M 0 0 4575k 0 0:00:05 0:00:02 0:00:03 4573k 58 26.7M 58 15.7M 0 0 4603k 0 0:00:05 0:00:03 0:00:02 4602k 75 26.7M 75 20.2M 0 0 4643k 0 0:00:05 0:00:04 0:00:01 4642k 89 26.7M 89 23.8M 0 0 4482k 0 0:00:06 0:00:05 0:00:01 4896k 99 26.7M 99 26.5M 0 0 4148k 0 0:00:06 0:00:06 --:–:-- 3903k 100 26.7M 100 26.7M 0 0 4130k 0 0:00:06 0:00:06 --:–:-- 3865k hdiutil: attach failed - No such file or directory /Library/Application Support/Automox/execDir330532400/execcmd649898447: line 10: /var/root/Volumes/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh: No such file or directory hdiutil: detach failed - No such file or directory


this is the updated script:


#!/bin/bash



echo -e “Installing LsAgent…”


hdiutil attach “LsAgent-osx.dmg” -nobrowse


~/Volumes/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh --agentkey “CLOUD-CODE” --mode unattended



echo -e “Cleaning up…”


hdiutil detach “/Volumes/LsAgent”


rm -f “/tmp/LsAgent-osx.dmg”


Actually I am not getting error code but it is not getting installed.


Try using ./LsAgent-osx.dmg instead of just LsAgent-osx.dmg inside the double quotes and see if it likes that better. That way it explicitly references the current directly in case it’s not explicitly in the $PATH variable.


Thank you,


unfortunately same result no error but it didn’t install.


Next thing I’d suspect is the use of the ~ since that’s going to be different when running as you versus running as root. Could we try expanding that to the full path?


That is what I just tried and was waiting to see if the computer reported home. (takes 10min)


and it worked thank you!


I will test it on couple more computers to make sure.


Glad that did the trick! One you have the final version of the script that’s working, you can send that to me and I can edit the top post in this thread to have your working script. That way others who are looking will find the final version first rather than having to scroll to the bottom.


thank you again for your help.


I gave up on using curl to download the file otherwise here is the working version of the script:


#!/bin/bash



echo -e “Installing LsAgent…”


hdiutil attach “./LsAgent-osx.dmg” -nobrowse


/Volumes/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh --agentkey “Your_Cloud_Key” --mode unattended



echo -e “Cleaning up…”


hdiutil detach “/Volumes/LsAgent”


rm -f “/tmp/LsAgent-osx.dmg”


So I hate to revive this old post but I am actually trying to get this working right now and simply cannot figure out how to determine if the install I am pushing to the mac is successful or not.

The only feedback I am getting in the Activity log report is “Installed Software”


Reply