CyberCNS Lightweight Agent Installation Script for MacOS

Please use your CyberCNS Domain/Tenant name in the CyberCNS Agent download link mentioned in the script as shown below:

e.g. cybercnstenant should be learn in case CyberCNS Domain/Tenant is learn. Please use your allocated CyberCNS Domain/Tenant name here.

The script used for CyberCNS V3:

Note: The script for new infrastructure: ( this script has changed agent download URL which is suitable for new infrastructure)

The script used for CyberCNS V2:

#!/bin/bash


# checking wether the user is root or normal user
function check_root {
    if [[ "x$(id -u)" != 'x0' ]]; then
        echo 'Error: this script can only be executed by root'
        exit 1
    fi
}

# checking wether the agent already exists if not will install the agent
function install_lightweight {

   if [ -z "$cybercnscompanyid" ]
   then
         echo "\$cybercnscompanyid  is NULL"
         exit 1
   fi

   if [ -z "$cybercnsclientid" ]
   then
         echo "\$cybercnsclientid  is NULL"
         exit 1
   fi

   if [ -z "$cybercnsclientsecret" ]
   then
         echo "\$cybercnsclientsecret  is NULL"
         exit 1
   fi

   if [ -z "$cybercnsdomain" ]
   then
         echo "\$cybercnsdomain  is NULL"
         exit 1
   fi

   pgrep cybercnsagentv2_darwin
   exitcode=$?
   if [ $exitcode -eq 0 ]; then
      echo "lightweight agent already running in the machine"
   else
      echo "Downloading https://domain.mycybercns.com/agents/ccnsagent/cybercnsagent_darwin"
      exitcode=$(curl --write-out %{http_code} -L -g "https://domain.mycybercns.com/agents/ccnsagent/cybercnsagent_darwin" -s -o cybercnsagent_darwin)
      if [ $exitcode -ne 200 ]; then
              if [ "$exitcode" == "000" ]; then
                 exitcode=-1
              fi
              
              echo "Was not able to fetch the lightweight cybercnsagent agent for mac os"
              exit $exitcode
      fi
      chmod +x cybercnsagent_darwin;
      sudo ./cybercnsagent_darwin -c $cybercnscompanyid -a $cybercnsclientid  -s $cybercnsclientsecret -b $cybercnsdomain -i LightWeight
   fi
}


function install {
    check_root
    install_lightweight
}

install

CyberCNS Probe Agent Installation Script for MacOS

Note: The script for new infrastructure: ( this script has changed agent download URL which is suitable for new infrastructure)

The script used for CyberCNS V3:

The script used for CyberCNS V2:

#!/bin/bash


# checking wether the user is root or normal user
function check_root {
    if [[ "x$(id -u)" != 'x0' ]]; then
        echo 'Error: this script can only be executed by root'
        exit 1
    fi
}

# checking wether the agent already exists if not will install the agent
function install_probe {

   if [ -z "$cybercnscompanyid" ]
   then
         echo "\$cybercnscompanyid  is NULL"
         exit 1
   fi

   if [ -z "$cybercnsclientid" ]
   then
         echo "\$cybercnsclientid  is NULL"
         exit 1
   fi

   if [ -z "$cybercnsclientsecret" ]
   then
         echo "\$cybercnsclientsecret  is NULL"
         exit 1
   fi

   if [ -z "$cybercnsdomain" ]
   then
         echo "\$cybercnsdomain  is NULL"
         exit 1
   fi

   pgrep cybercnsagentv2_darwin
   exitcode=$?
   if [ $exitcode -eq 0 ]; then
      echo "Probe agent already running in the machine"
   else
      echo "Downloading https://domain.mycybercns.com/agents/ccnsagent/cybercnsagent_darwin"
      exitcode=$(curl --write-out %{http_code} -L -g "https://domain.mycybercns.com/agents/ccnsagent/cybercnsagent_darwin" -s -o cybercnsagent_darwin)
      if [ $exitcode -ne 200 ]; then
              if [ "$exitcode" == "000" ]; then
                 exitcode=-1
              fi
              
              echo "Was not able to fetch the Probe cybercnsagent agent for mac os"
              exit $exitcode
      fi
      chmod +x cybercnsagent_darwin;
      sudo ./cybercnsagent_darwin -c $cybercnscompanyid -a $cybercnsclientid  -s $cybercnsclientsecret -b $cybercnsdomain -i Probe
   fi
}


function install {
    check_root
    install_probe
}

install