Skip to content

Instantly share code, notes, and snippets.

@jimanx2
Last active February 7, 2024 11:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimanx2/ebff4b3a3af171166b0b96da981ee26f to your computer and use it in GitHub Desktop.
Save jimanx2/ebff4b3a3af171166b0b96da981ee26f to your computer and use it in GitHub Desktop.
TrendMicroDeepSecurityInstallScript
#!/bin/bash
ACTIVATIONURL='dsm://agents.deepsecurity.trendmicro.com:443/'
MANAGERURL='https://app.deepsecurity.trendmicro.com:443'
CURLOPTIONS='--silent --tlsv1.2'
linuxPlatform='';
isRPM='';
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
echo You are not running as the root user. Please try again with root privileges.;
logger -t You are not running as the root user. Please try again with root privileges.;
exit 1;
fi;
if ! type curl >/dev/null 2>&1; then
echo "Please install CURL before running this script."
logger -t Please install CURL before running this script
exit 1
fi
CURLOUT=$(eval curl $MANAGERURL/software/deploymentscript/platform/linuxdetectscriptv1/ -o /tmp/PlatformDetection $CURLOPTIONS;)
err=$?
if [[ $err -eq 60 ]]; then
echo "TLS certificate validation for the agent package download has failed. Please check that your Deep Security Manager TLS certificate is signed by a trusted root certificate authority. For more information, search for \"deployment scripts\" in the Deep Security Help Center."
logger -t TLS certificate validation for the agent package download has failed. Please check that your Deep Security Manager TLS certificate is signed by a trusted root certificate authority. For more information, search for \"deployment scripts\" in the Deep Security Help Center.
exit 1;
fi
if [ -s /tmp/PlatformDetection ]; then
. /tmp/PlatformDetection
else
echo "Failed to download the agent installation support script."
logger -t Failed to download the Deep Security Agent installation support script
exit 1
fi
platform_detect
if [[ -z "${linuxPlatform}" ]] || [[ -z "${isRPM}" ]]; then
echo Unsupported platform is detected
logger -t Unsupported platform is detected
exit 1
fi
echo Downloading agent package...
if [[ $isRPM == 1 ]]; then package='agent.rpm'
else package='agent.deb'
fi
curl -H "Agent-Version-Control: on" $MANAGERURL/software/agent/${runningPlatform}${majorVersion}/${archType}/$package?tenantID=$TENANT_ID -o /tmp/$package $CURLOPTIONS
echo Installing agent package...
rc=1
if [[ $isRPM == 1 && -s /tmp/agent.rpm ]]; then
rpm -ihv /tmp/agent.rpm
rc=$?
elif [[ -s /tmp/agent.deb ]]; then
dpkg -i /tmp/agent.deb
rc=$?
else
echo Failed to download the agent package. Please make sure the package is imported in the Deep Security Manager
logger -t Failed to download the agent package. Please make sure the package is imported in the Deep Security Manager
exit 1
fi
if [[ ${rc} != 0 ]]; then
echo Failed to install the agent package
logger -t Failed to install the agent package
exit 1
fi
echo Install the agent package successfully
@en0h0
Copy link

en0h0 commented Feb 6, 2024

Hi, will this script download correct rpm if the machine is oracle linux or redhat linux? it distinguish between RPM distros?

@jimanx2
Copy link
Author

jimanx2 commented Feb 7, 2024

Hi, i am sorry i am not the author of this script. I posted to gist because i need to use it in one of my servers.

but by checking the script it supposed to be downloading RPM packages without regard to the OS distribution.

i hope this helps.

@en0h0
Copy link

en0h0 commented Feb 7, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment