Skip to main content

Hello
We are deploying an asset management tool called magma3 in our environment.
With that, I needed a worklet that would install the agent on Linux machines.

The agent is a .sh file

any worklet?

 

Thank you very much

 

 

There is no specific worklet for installing Magma3, however I can help you in the right direction. 

 

Manage → (Scroll downwards to “Worklet Policy”) Linux 

Remember to upload the file “setup.sh”

It should look something like this, after uploading your payload “setup.sh” and assigning the policy to your groups/targeted devices then proceed to scroll down to the codes section.

 

Enter your Evaluation Code and Remediation Code

 

Evaluation Code

#!/bin/sh

"Application name"=$(ps -e | grep ir_agent)

if l "Application name" ]
then 
  exit 0
else 
  exit 1
fi

 

 

Remediation Code

#!/bin/sh


cp setup.sh /tmp/setup.sh
chmod u+x /tmp/setup.sh
sudo /tmp/setup.sh install_start --token #if any

"Application name"=$( ps -e | grep ir_agent)

if a "$Application name" ]
then
  echo "installed succesfully"
  exit 0
else
  echo "failed to install"
  exit 1
fi

 

 

 

Proceed to save the policy and you’re all set to go! 
Do forgive me if there are any errors, I am not an expert with Linux

For further information regarding uninstall and install, refer to this answer from:

 

 

Happy coding! 😀


Hello
Thanks for replying 
But now it has complicated the situation a little more.
I found out from the vendor that it is necessary to download a zipped folder in one of the Linux directories, unzip that folder and run the .sh file that is inside this unzipped folder.
All this because inside the folder there are other files that the .sh will need.
Any ideas?


Hello
Thanks for replying 
But now it has complicated the situation a little more.
I found out from the vendor that it is necessary to download a zipped folder in one of the Linux directories, unzip that folder and run the .sh file that is inside this unzipped folder.
All this because inside the folder there are other files that the .sh will need.
Any ideas?



Okay, not an issue. It is a simple alteration! :D  

 

So in the remediation code, just alter it as such that it unzips the zip file, and then changes directory into the place where you want it to extract everything, from there it will run the setup.sh file

 

Remediation Code

# Variables
zipfile="/tmp/Magma3.zip"   # Or whatever the name of the Zip file is
extractpath="/tmp/Magma3Installation"   

 

# Main
unzip -o "$zipfile" -d "$extractpath"
cd "$extractpath" || { echo "Failed to change directory to $extractpath"; exit 1; }
chmod u+x ./setup.sh
sudo ./setup.sh install_start --token #if any

 

Proceed to save the policy and you’re all set to go! 
Do forgive me if there are any errors, I am not an expert with Linux

 

Happy coding! 😀


Hello
I tried using the script below:

 

# Variables
zipfile="/opt/Magma3.zip"   # Diretório padrão para cargas úteis no Automox
extractpath="/tmp/Magma3Installation"

# Creates the directory if it does not exist
mkdir -p "$extractpath"

# Main
unzip -o "$zipfile" -d "$extractpath" || { echo "Failed to unzip $zipfile"; exit 1; }
cd "$extractpath" || { echo "Failed to change directory to $extractpath"; exit 1; }
chmod u+x ./setup.sh
sudo ./setup.sh install_start --token # 

 

But it always gives an error, it does not download the folder .zip even though it is in the payload

If the file is .zip in the payload, does it download automatically? No need to point a url?


Reply