Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The script for CyberCNS V3:Linux

View file
namelinux.sh

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

...

Code Block
#!/bin/bash


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

# checking wetherwhether 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
   exitcode=$?
   if [ $exitcode -eq 0 ]; then
      echo "lightweight agent already running in the machine"
   else
      echo "Downloading http://<domain>.mycybercns.com/agents/ccnsagent/cybercnsagent_linux"
      exitcode=$(curl --write-out %{http_code} -L -g "http://<domain>.mycybercns.com/agents/ccnsagent/cybercnsagent_linux" -s -o cybercnsagent_linux)
      if [ $exitcode -ne 200 ]; then
              if [ "$exitcode" == "000" ]; then
                 exitcode=-1
              fi
              
              echo "Was not able to fetch the lightweight cybercnsagent agent for ubuntu"
              exit $exitcode
      fi
      chmod +x cybercnsagent_linux;
      sudo ./cybercnsagent_linux -c $cybercnscompanyid -a $cybercnsclientid  -s $cybercnsclientsecret -b $cybercnsdomain -i LightWeight
   fi
}


function install {
    check_root
    install_lightweight
}

install

...

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

...

Code Block
#!/bin/bash


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

# checking wetherwhether 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
   exitcode=$?
   if [ $exitcode -eq 0 ]; then
      echo "Probe agent already running in the machine"
   else
      echo "Downloading http://<domain>.mycybercns.com/agents/ccnsagent/cybercnsagent_linux"
      exitcode=$(curl --write-out %{http_code} -L -g "http://<domain>.mycybercns.com/agents/ccnsagent/cybercnsagent_linux" -s -o cybercnsagent_linux)
      if [ $exitcode -ne 200 ]; then
              if [ "$exitcode" == "000" ]; then
                 exitcode=-1
              fi
              
              echo "Was not able to fetch the Probe cybercnsagent agent for ubuntu"
              exit $exitcode
      fi
      chmod +x cybercnsagent_linux;
      sudo ./cybercnsagent_linux -c $cybercnscompanyid -a $cybercnsclientid  -s $cybercnsclientsecret -b $cybercnsdomain -i Probe
   fi
}


function install {
    check_root
    install_probe
}

install