#!/bin/sh # Installation script requirements for licensing systems. # Some Perl modules need for Running our licensing systems. if [[ $EUID -ne 0 ]]; then echo "You must be a root user" 2>&1 exit 1 fi RED='\033[0;31m' GREEN='\033[0;32m' NC='\033[0m' upgradeCommand="" 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 || { echo "We require wget but it's not installed." >&2; tools="wget" } command -v curl >/dev/null 2>&1 || { echo "We require curl but it's not installed." >&2; tools=${tools}" curl" } command -v perl >/dev/null 2>&1 || { echo "We require perl but it's not installed." >&2; tools=${tools}" perl" } command -v sudo >/dev/null 2>&1 || { echo "We require sudo but it's not installed." >&2; tools=${tools}" sudo" } command -v openssl >/dev/null 2>&1 || { echo "We require openssl but it's not installed." >&2; tools=${tools}" openssl" } command -v tar >/dev/null 2>&1 || { echo "We require openssl but it's not installed." >&2; tools=${tools}" tar" } command -v netstat >/dev/null 2>&1 || { echo "We require netstat but it's not installed." >&2; tools=${tools}" net-tools" } 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 if [ "$upgradeCommand" == "yum " ]; then repoDefault="" if [ -f /etc/yum.repos.d/CentOS-Base.repo ]; then repoDefault=1 else repoDefault=0 echo '[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 ' >/etc/yum.repos.d/CentOS-Base.repo fi if [ ! -f /etc/yum.repos.d/epel.repo ]; then yum install epel-release -y fi fi $upgradeCommand install $tools -y fi perlChecking=`sudo perl -v` if ! [[ "$perlChecking" =~ "This is perl" ]]; then if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.22 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.22 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.24 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.24 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.26 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.26 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.28 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.28 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi perlChecking=`sudo perl -v` if ! [[ "$perlChecking" =~ "This is perl" ]]; then echo "Perl not working , Please contact sysadmin" exit fi fi if [ "$upgradeCommand" == "apt-get " ]; then if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.20 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.20 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.22 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.22 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.24 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.24 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.26 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.26 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi if [ -e /usr/lib/x86_64-linux-gnu/libperl.so.5.28 ]; then ln -s /usr/lib/x86_64-linux-gnu/libperl.so.5.28 /usr/lib/x86_64-linux-gnu/libperl.so &>/dev/null fi fi if [ ! "$modules" == "" ]; then if [ "$upgradeCommand" == "yum " ]; then if [ ! -f /etc/yum.repos.d/epel.repo ]; then yum install epel-release -y 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 $moduleselse -y else $upgradeCommand install $modules -y fi fi if [ "$repoDefault" == "0" ]; then rm -rf /etc/yum.repos.d/CentOS-Base.repo fi if [ -e /usr/local/bin/curl ]; then ln -s /usr/local/bin/curl /usr/bin/curl fi output=`/usr/bin/curl -s https://license.noor.host/detectos.pl | perl `; output="${output%\\n}" if [ "$output" == "864" ]; then yum install libnsl -y fi if [ "$output" == "debian8" ]; then ln -s /usr/local/lib/libcurl.so.4 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4 fi if [ "$output" == "ubuntu18" ]; then wgetOptions="--no-check-certificate" fi wgetOptions="" if [ "$output" == "664" ]; then wgetOptions="--no-check-certificate" update-ca-trust enable fi if [ "$output" == "632" ]; then wgetOptions="--no-check-certificate" update-ca-trust enable fi echo -e "OS Type: ${GREEN}$output detected!${NC}"; echo -n "Start downloading primary system...Depending on the speed of your server network, it may take some time" wget -q -O /usr/bin/CSPUpdate $wgetOptions https://license.noor.host/cspupdate/$output/CSPUpdate if [ $? -eq 0 ]; then echo -e "... ${GREEN}Completed!${NC}" if [ -f /usr/bin/CSPUpdate ]; then chmod +x /usr/bin/CSPUpdate if [ $? -ne 0 ]; then echo -e "${RED}Exit code: $? - Failed to execute 'chmod +x /usr/bin/CSPUpdate'. Contact support ${NC}"; fi else echo -e "${RED}File /usr/bin/CSPUpdate not found. Contact support ${NC}" fi fi echo -n "Start downloading sub system...Depending on the speed of your server network, it may take some time" /usr/bin/CSPUpdate -i CSPPerlUpdator &>/dev/null if [ $? -ne 0 ]; then echo -e "${RED}Exit code: $? Failed to execute CSPPerlUpdator installer. Contact support${NC}" exit 1 fi if [ -f /usr/bin/CSPPerlUpdator ]; then /usr/bin/CSPPerlUpdator &>/dev/null if [ -f /usr/local/csp/3rdparty/perl/5.24.0csp1/bin/perl ]; then echo -e "... ${GREEN}Completed!${NC}" /usr/local/csp/3rdparty/perl/5.24.0csp1/bin/perl -v &>/dev/null if [ $? -eq 0 ]; then echo -e "${GREEN}All prepared successfully.${NC}" if [ "$1" != '' ]; then /usr/bin/CSPUpdate -i $1 fi else echo -e "${RED}Failed to execute CSPPerl binary. Contact support.${NC}" exit 1 fi else echo -e "${RED}File CSPPerl not found. Contact support${NC}" exit 1 fi else echo -e "${RED}File /usr/bin/CSPPerlUpdator not found. Contact support${NC}" exit 1 fi