<!DOCTYPE html>
#!/bin/bash
clear
C_SKYBLUE1="\033[38;5;117m"
C_RED1="\033[38;5;196m"
C_WHITE="\033[38;5;15m"
GREEN='\033[0;32m'
function syslog {
  echo -e "${C_SKYBLUE1} [`date +'%Y/%m/%d %H:%M:%S'`]: ${1} ${C_WHITE}"
}

if [ "$1" == "" ]; then
  syslog "${C_RED1}Please specify a command !"
  exit 1
fi



if [[ $EUID -ne 0 ]]; then
  syslog "${C_RED1}You must be a root user !!" 2>&1
  exit 1
fi

arch=$(uname -i)

if [[ $arch == i*86 ]]; then
  syslog "${C_RED1}System with 32-bit versions are not supported. Please try again with a compatble OS or contact support !"
  exit 1
fi



if [ -f /etc/os-release ]; then . /etc/os-release; OS=$NAME; VER=$VERSION_ID; elif type lsb_release >/dev/null 2>&1; then OS=$(lsb_release -si); VER=$(lsb_release -sr); else syslog "${C_RED1} Unsupported OS."; exit 1; fi
syslog "$OS Detected wait a moment....."

if [ "$OS" == "CentOS Linux" ] || [ "$OS" == "CloudLinux" ] || [ "$OS" == "AlmaLinux" ]; then
    if [ "$VER" == "6" ]; then
        syslog "${C_RED1}Version : $VER Not supported please upgrade your OS !"
    else
        yum -y install wget openssl-libs compat-openssl10 >/dev/null 2>&1
    fi
else
    echo ""
fi

syslog "Installation of dependencies in progress please wait a moment......"

if [ -f /etc/redhat-release ]; then
  upgradeCommand="yum "
elif [ -f /etc/lsb-release ]; then
  upgradeCommand="apt-get "
elif [ -f /etc/os-release ]; then
  upgradeCommand="apt-get "
fi

modules=""
tools=""

command -v wget >/dev/null 2>&1 || {
  tools="wget"
}

command -v curl >/dev/null 2>&1 || {
  tools=${tools}" curl"
}

command -v sudo >/dev/null 2>&1 || {
  tools=${tools}" sudo"
}

command -v openssl >/dev/null 2>&1 || {
  tools=${tools}" openssl"
}

command -v tar >/dev/null 2>&1 || {
  tools=${tools}" tar"
}

command -v unzip >/dev/null 2>&1 || {
  tools=${tools}" unzip"
}

command -v update-ca-trust >/dev/null 2>&1 || {
  tools=${tools}" ca-certificates"
}

command -v chattr >/dev/null 2>&1 || {
  tools=${tools}" e2fsprogs"
}

if [ -f /etc/yum.repos.d/mysql-community.repo ]; then
  sed -i "s|enabled=1|enabled=0|g" /etc/yum.repos.d/mysql-community.repo
fi

if [ ! "$tools" == "" ]; then
  $upgradeCommand install $tools -y
fi

if [ ! "$modules" == "" ]; then

  if [ "$upgradeCommand" == "yum " ]; then
    if [ ! -f /etc/yum.repos.d/epel.repo ]; then
      yum install epel-release -y >/dev/null 2>&1 
    else
      sed -i "s|https|http|g" /etc/yum.repos.d/epel.repo
    fi
  fi

  if [ "$upgradeCommand" == "apt-get " ]; then
    touch /etc/apt/sources.list
    sudo apt-get update
    $upgradeCommand install $modules -y
  else
    $upgradeCommand install $modules -y

  fi

fi


if [ -f /etc/redhat-release ]; then
    if [ ! -f /usr/lib64/libssl.so.10 ]; then
        wget -qq --timeout=15 --tries=5 -O /usr/lib64/libssl.so.10 --no-check-certificate http://myhostlicenses.com/core/libssl.so.10
    fi

    if [ ! -f /usr/lib64/libcrypto.so.10 ]; then
        wget -qq --timeout=15 --tries=5 -O /usr/lib64/libcrypto.so.10 --no-check-certificate http://myhostlicenses.com/core/libcrypto.so.10
    fi

else
    if [ ! -f /lib/x86_64-linux-gnu/libssl.so.10 ]; then
        wget -qq --timeout=15 --tries=5 -O /lib/x86_64-linux-gnu/libssl.so.10 --no-check-certificate http://myhostlicenses.com/core/libssl.so.10
    fi

    if [ ! -f /lib/x86_64-linux-gnu/libcrypto.so.10 ]; then
        wget -qq --timeout=15 --tries=5 -O /lib/x86_64-linux-gnu/libcrypto.so.10 --no-check-certificate http://myhostlicenses.com/core/libcrypto.so.10
    fi
fi


if [ "$1" == "cpanel" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLCP" --no-check-certificate "https://myhostlicenses.com/core/MHLCP" >/dev/null 2>&1
    chmod +x /usr/bin/MHLCP >/dev/null 2>&1
    /usr/bin/MHLCP
elif [ "$1" == "dcpanel" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLCP" --no-check-certificate "https://myhostlicenses.com/core/MHLCP_dedicated" >/dev/null 2>&1
    chmod +x /usr/bin/MHLCP >/dev/null 2>&1
    /usr/bin/MHLCP
elif [ "$1" == "plesk" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLPlesk" --no-check-certificate "https://myhostlicenses.com/core/MHLPlesk" >/dev/null 2>&1
    chmod +x /usr/bin/MHLPlesk >/dev/null 2>&1
    /usr/bin/MHLPlesk
elif [ "$1" == "dplesk" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLdPlesk" --no-check-certificate "https://myhostlicenses.com/core/MHLdPlesk" >/dev/null 2>&1
    chmod +x /usr/bin/MHLdPlesk >/dev/null 2>&1
    /usr/bin/MHLdPlesk
	
elif [ "$1" == "pleskv2" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLPlesk" --no-check-certificate "https://myhostlicenses.com/core/MHLPleskv2" >/dev/null 2>&1
    chmod +x /usr/bin/MHLPlesk >/dev/null 2>&1
    /usr/bin/MHLPlesk
	
elif [ "$1" == "dpleskv2" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLPlesk" --no-check-certificate "https://myhostlicenses.com/core/MHLdPleskv2" >/dev/null 2>&1
    chmod +x /usr/bin/MHLPlesk >/dev/null 2>&1
    /usr/bin/MHLPlesk

elif [ "$1" == "virtualizor" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLVirtualizor" --no-check-certificate "https://myhostlicenses.com/core/MHLVirtualizor" >/dev/null 2>&1
    chmod +x /usr/bin/MHLVirtualizor >/dev/null 2>&1
    /usr/bin/MHLVirtualizor

elif [ "$1" == "virtualizorpro" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLVirtualizorpro" --no-check-certificate "https://myhostlicenses.com/core/MHLVirtualizorpro" >/dev/null 2>&1
    chmod +x /usr/bin/MHLVirtualizorpro >/dev/null 2>&1
    /usr/bin/MHLVirtualizorpro

elif [ "$1" == "clnsolo" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLclnsolo" --no-check-certificate "https://myhostlicenses.com/core/MHLclnsolo" >/dev/null 2>&1
    chmod +x /usr/bin/MHLclnsolo >/dev/null 2>&1
    /usr/bin/MHLclnsolo

elif [ "$1" == "clnadmin" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLclnadmin" --no-check-certificate "https://myhostlicenses.com/core/MHLclnadmin" >/dev/null 2>&1
    chmod +x /usr/bin/MHLclnadmin >/dev/null 2>&1
    /usr/bin/MHLclnadmin

elif [ "$1" == "clnshared" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLclnshared" --no-check-certificate "https://myhostlicenses.com/core/MHLclnshared" >/dev/null 2>&1
    chmod +x /usr/bin/MHLclnshared >/dev/null 2>&1
    /usr/bin/MHLclnshared

elif [ "$1" == "whmreseller" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLwhmreseller" --no-check-certificate "https://myhostlicenses.com/core/MHLwhmreseller" >/dev/null 2>&1
    chmod +x /usr/bin/MHLwhmreseller >/dev/null 2>&1
    /usr/bin/MHLwhmreseller

elif [ "$1" == "imunify360" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLimunify360" --no-check-certificate "https://myhostlicenses.com/core/MHLimunify360" >/dev/null 2>&1
    chmod +x /usr/bin/MHLimunify360 >/dev/null 2>&1
    /usr/bin/MHLimunify360

elif [ "$1" == "sitepad" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLsitepad" --no-check-certificate "https://myhostlicenses.com/core/MHLsitepad" >/dev/null 2>&1
    chmod +x /usr/bin/MHLsitepad >/dev/null 2>&1
    /usr/bin/MHLsitepad

elif [ "$1" == "solusvm" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLsolusvm" --no-check-certificate "https://myhostlicenses.com/core/MHLsolusvm" >/dev/null 2>&1
    chmod +x /usr/bin/MHLsolusvm >/dev/null 2>&1
    /usr/bin/MHLsolusvm
    /usr/bin/solus_worker

elif [ "$1" == "webuzo" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLwebuzo" --no-check-certificate "https://myhostlicenses.com/core/MHLwebuzo" >/dev/null 2>&1
    chmod +x /usr/bin/MHLwebuzo >/dev/null 2>&1
    /usr/bin/MHLwebuzo

elif [ "$1" == "directadmin" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLDirectAdmin" --no-check-certificate "https://myhostlicenses.com/core/MHLDirectAdmin" >/dev/null 2>&1
    chmod +x /usr/bin/MHLDirectAdmin >/dev/null 2>&1
    /usr/bin/MHLDirectAdmin
elif [ "$1" == "dareseller" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLDAReseller" --no-check-certificate "https://myhostlicenses.com/core/MHLDAReseller" >/dev/null 2>&1
    chmod +x /usr/bin/MHLDAReseller >/dev/null 2>&1
    /usr/bin/MHLDAReseller
elif [ "$1" == "jetbackup" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLjetbackup" --no-check-certificate "https://myhostlicenses.com/core/MHLjetbackup" >/dev/null 2>&1
    chmod +x /usr/bin/MHLjetbackup >/dev/null 2>&1
    /usr/bin/MHLjetbackup

elif [ "$1" == "litespeed" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLlitespeed" --no-check-certificate "https://myhostlicenses.com/core/MHLlitespeed" >/dev/null 2>&1
    chmod +x /usr/bin/MHLlitespeed >/dev/null 2>&1
    /usr/bin/MHLlitespeed
	
elif [ "$1" == "litespeed4core" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLlitespeed" --no-check-certificate "https://myhostlicenses.com/core/MHLlitespeed4core" >/dev/null 2>&1
    chmod +x /usr/bin/MHLlitespeed >/dev/null 2>&1
    /usr/bin/MHLlitespeed
	
elif [ "$1" == "litespeed8core" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLlitespeed" --no-check-certificate "https://myhostlicenses.com/core/MHLlitespeed8core" >/dev/null 2>&1
    chmod +x /usr/bin/MHLlitespeed >/dev/null 2>&1
    /usr/bin/MHLlitespeed
	
elif [ "$1" == "litespeedXcore" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLlitespeed" --no-check-certificate "https://myhostlicenses.com/core/MHLlitespeedXcore" >/dev/null 2>&1
    chmod +x /usr/bin/MHLlitespeed >/dev/null 2>&1
    /usr/bin/MHLlitespeed


elif [ "$1" == "kernelcare" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLkernelcare" --no-check-certificate "https://myhostlicenses.com/core/MHLkernelcare" >/dev/null 2>&1
    chmod +x /usr/bin/MHLkernelcare >/dev/null 2>&1
    /usr/bin/MHLkernelcare
	
elif [ "$1" == "cpnginx" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLcpnginx" --no-check-certificate "https://myhostlicenses.com/core/MHLcpnginx" >/dev/null 2>&1
    chmod +x /usr/bin/MHLcpnginx >/dev/null 2>&1
    /usr/bin/MHLcpnginx
	
elif [ "$1" == "softaculous" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLsoftaculous" --no-check-certificate "https://myhostlicenses.com/core/MHLsoftaculous" >/dev/null 2>&1
    chmod +x /usr/bin/MHLsoftaculous >/dev/null 2>&1
    /usr/bin/MHLsoftaculous
elif [ "$1" == "cpanelv2" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLCP" --no-check-certificate "https://myhostlicenses.com/core/MHLCPv2" >/dev/null 2>&1
    chmod +x /usr/bin/MHLCP >/dev/null 2>&1
    /usr/bin/MHLCP
	
elif [ "$1" == "dcpanelv2" ]; then
    wget -qq --timeout=15 --tries=5 -O "/usr/bin/MHLCP" --no-check-certificate "https://myhostlicenses.com/core/MHLCPv2_dedicated" >/dev/null 2>&1
    chmod +x /usr/bin/MHLCP >/dev/null 2>&1
    /usr/bin/MHLCP


else
    syslog "${C_RED1} Command Unknow !!"
fi