HEX
Server: Apache/2
System: Linux nexus-01 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: aglcoke (1118)
PHP: 8.2.31
Disabled: mail,exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/cwaf/setup.sh
#! /bin/sh

################### Check if this help request ###################
if [ x"$1" = x"--help" -o  x"$1" = x"--examples" ]; then
  bash ./installer.sh $@
  exit 0
fi

################### Install Pre-Requisites ###################

echo "------------------------------------------------------"
echo "Checking pre-requisites"
echo "------------------------------------------------------"

# Crypt::SSLeay always give a headache so preinstall it first
if [ $(uname) = 'FreeBSD' ]; then
  mount -t procfs proc /proc
  if [ -x /usr/local/bin/perl ]; then
    ln -s /usr/local/bin/perl /usr/bin/perl
  fi
  PKG_BIN=$(which pkg)
  # required for FreeBSD
  SSLEAY_TEST=`$PKG_BIN info p5-Net-SSLeay 2>&1 | grep 'No package'`
  if [ ! -z "${SSLEAY_TEST}" ]; then
    $PKG_BIN install -y p5-Net-SSLeay
  fi
else
  PERL_BIN='/usr/bin/perl'
  if [ -x /usr/local/cpanel/3rdparty/bin/perl ]; then
    PERL_BIN='/usr/local/cpanel/3rdparty/bin/perl'
  fi
  CRYPT_TEST=$($PERL_BIN -e "use Crypt::SSLeay" 2>&1)
  if [ -n "$CRYPT_TEST" ]; then
      if [ -e "/etc/debian_version" ]; then
        apt-get -y install libcrypt-ssleay-perl
      elif [ -e "/etc/redhat-release" ]; then
        yum -y install perl-Crypt-SSLeay
      elif [ -e "/etc/SuSE-release" ]; then
        zypper -n install perl-Crypt-SSLeay
      fi
  fi
fi

CURDIR=$(pwd)

# bash check
BASH_BIN=$(which bash)
if [ ! -e "${BASH_BIN}" ]; then
  echo "Cannot find bash. Trying to install it automatically."
  if [ -x "${PKG_BIN}" ]; then
    pkg install -y bash
    if [ $? -ne 0 ]; then
      echo "Cannot install bash automatically. Please install it and relaunch this script"
      exit 1
    fi
    ln -s /usr/local/bin/bash /bin/bash
  else
    cd /usr/ports/shells/bash && make install clean BATCH=yes
    ln -s /usr/local/bin/bash /bin/bash
    cd ${CURDIR}
  fi
else
  echo "BASH bin OK ($BASH_BIN)"
fi

# sudo check
#SUDO_BIN=$(which sudo)
#if [ ! -e "${SUDO_BIN}" ]; then
#  echo "Cannot find sudo. Trying to install it automatically. It can take few minutes."
#  if [ $(uname) = 'FreeBSD' ]; then
#     if [ -x "${PKG_BIN}" ]; then
#       pkg install -y sudo
#       if [ $? -ne 0 ]; then
#         echo "Cannot install sudo automatically. Please install it and relaunch this script"
#         exit 1
#       fi
#     else
#       cd /usr/ports/security/sudo && make install clean BATCH=yes
#       cd ${CURDIR}
#     fi
#  elif [ -e "/etc/debian_version" ]; then
#    apt-get -y install sudo
#  elif [ -e "/etc/redhat-release" ]; then
#    yum -y install sudo
#  elif [ -e "/etc/SuSE-release" ]; then
#    zypper -n install sudo
#  else
#    echo "Cannot install sudo automatically. Please install it and relaunch this script"
#    exit 1
#  fi
#else
#  echo "SUDO bin OK ($SUDO_BIN)"
#fi

# cpan check
CPAN_BIN=$(which cpan)
if [ ! -e "${CPAN_BIN}" ]; then
  echo "Cannot find CPAN. Trying to install it automatically by installing latest Perl. It can take few minutes."
  if [ $(uname) = 'FreeBSD' ]; then
    if [ -x "${PKG_BIN}" ]; then
      PERL_LASTVER=$(pkg search perl5 | sort -r | head -1)
      pkg install -y ${PERL_LASTVER}
      if [ $? -ne 0 ]; then
        echo "Cannot install CPAN automatically. Please install it and relaunch this script"
        exit 1
      fi
    else
      LANG_PATH='/usr/ports/lang'
      PERL_LASTVER=$(ls $LANG_PATH | grep 'perl5' | sort -r | head -1)
      PERL_PATH="${LANG_PATH}/${PERL_LASTVER}"
      if [ -n "${PERL_LASTVER}" -a -d "${PERL_PATH}" ]; then
        cd ${PERL_PATH} && make install clean BATCH=yes
        cd ${CURDIR}
      else
        echo "Cannot install latest Perl automatically. Please install Perl and relaunch this script"
        exit 1
      fi
    fi
  elif [ -e "/etc/debian_version" ]; then
    apt-get -y install perl
  elif [ -e "/etc/redhat-release" ]; then
    yum -y install perl-CPAN;
  else
    echo "Cannot install CPAN automatically. Please install it and relaunch this script"
    exit 1
  fi
else
  echo "CPAN bin OK ($CPAN_BIN)"
fi

# Build reuirements check
GCC_BIN=$(which gcc)
MAKE_BIN=$(which make)
if [ ! -e "${GCC_BIN}" -o ! -e "${MAKE_BIN}" ]; then
  echo "Cannot find build essentials. Trying to install them automatically."
  if [ -e "/etc/debian_version" ]; then
    apt-get -y install build-essential
  elif [ -e "/etc/redhat-release" ]; then
    yum -y install gcc make
  elif [ -e "/etc/SuSE-release" ]; then
    zypper -n install gcc make
  else
    echo "Cannot install build essentials automatically. Please install and relaunch this script"
    exit 1
  fi
else
  echo "GCC bin OK ($GCC_BIN)"
  echo "MAKE bin OK ($MAKE_BIN)"
fi

# strings check
STRINGS_BIN=$(which strings)
if [ ! -e "${STRINGS_BIN}" ]; then
  echo "Cannot find strings. Trying to install it automatically by installing binutils."
  if [ -e "/etc/debian_version" ]; then
    apt-get -y install binutils
  elif [ -e "/etc/redhat-release" ]; then
    yum -y install binutils
  elif [ -e "/etc/SuSE-release" ]; then
    zypper -n install binutils
  else
    echo "Cannot install binutils automatically. Please install and relaunch this script"
    exit 1
  fi
else
  echo "STRINGS bin OK ($STRINGS_BIN)"
fi

################### Run Installer ###################

echo "------------------------------------------------------"
echo "Running installer"
echo "------------------------------------------------------"
bash ./installer.sh $@

exit 0