#!/bin/bash RED=$(tput setaf 1) GREEN=$(tput setaf 2) YELLOW=$(tput setaf 3) RS=$(tput sgr0) BOLD=$(tput bold) UL=$(tput smul) HEADER=${RS}${YELLOW}${BOLD}${UL} if [[ $UID -ne 0 ]] then printf "Need to be root to run. Ask your mom if it's ok to run this\n" exit 1 elif [[ $(df|grep -E "/dev/vd") ]] then printf "${RED}Virtual server detected! This script is only meant for dedicated server signoffs. Continue?\n${RS}" select yn in "Yes" "No" do case $yn in Yes ) break ;; No ) exit 1 ;; esac done fi clear printf "${HEADER}Post-Setup General Scanner!\n${RS}" printf "${YELLOW}General\n${RS}" printf "${UL}Hostname:${RS} $(hostname)\n" printf "${UL}Cpuspeed:${RS}\n" service cpuspeed stop;chkconfig cpuspeed off;service cpuspeed status printf "${UL}SonarPush:${RS} " if [[ "$(ps faux|awk '/SonarPush/ {print $NF}')" =~ "sleeping" ]] then printf "${GREEN}Running${RS}\n" else printf "${RED}NOT running or something is wrong${RS}\n" fi printf "${UL}OS:${RS} " if [[ -e "/etc/os-release" ]] then awk -F = '/PRETTY_NAME/ {print $2}' /etc/os-release elif [[ -e "/etc/redhat-release" ]] then cat /etc/redhat-release else printf "${RED}Couldn't determine OS\n" fi printf "\n${YELLOW}Hardware${RS}\n" printf "${UL}CPU/Base Build:${RS} $(awk -F : '/model name/ {print $2}' /proc/cpuinfo|uniq)\n" printf "${UL}RAM:${RS}\n $(free -m)\n" printf "${UL}Type:${RS} $(dmidecode -t memory|awk '/^\s+Type:/ {print $2}'|sort|uniq|paste -sd ',')\n" printf "\n${YELLOW}Drives/Partitions${RS}\n" printf "${UL}Drive Sizes:\n${RS}" /sbin/fdisk -l 2>/dev/null|awk '/^Disk \/dev\/[s,v,m]d/ {print $2 " " $3$4}' printf "${UL}Partitioning:${RS}\n" df -h|awk '/^(Filesystem|\/)/ {print}' printf "\n${YELLOW}RAID${RS}\n" if [[ -e "/opt/MegaRAID/MegaCli/MegaCli64" ]] then printf "${BOLD}LSI RAID Detected${RS}\n" raid=1 printf "${UL}Firmware:${RS}: $(/opt/MegaRAID/MegaCli/MegaCli64 -AdpAllInfo -a0 | grep "Package Build")" printf "\n${UL}Info:${RS}\n" /opt/MegaRAID/MegaCli/MegaCli* -CfgDsply -aAll | egrep '(Adapter:|Product Name:|Connected Port|Number [Oo]f|^Size *:|Raw Size:|DISK GROUP|RAID Level|^State|Firmware state|Virtual Drive:|SPAN:|Slot Number|Inquiry|Enclosure|Link Speed|Media Type)' | sed -e 's/^\(Product Name\|^Number\|RAID\|Size\|State\|Type\)/\t\1/g' -e 's/^\(Enclosure\|Slot\)/\t\t\1/g' -e 's/\(Connected Port\|Raw Size\|Inquiry\|Firmware\|Link Speed\|Media Type\)/\t\t\t\1/g' if [[ $(/opt/MegaRAID/MegaCli/MegaCli* -CfgDsply -aAll|grep -E "Solid State Device") && $(/opt/MegaRAID/MegaCli/MegaCli* -CfgDsply -aAll|grep -E "Hard Disk Device") ]] then printf "${BOLD}Mixed media (both SSD and HDD) RAID's detected!${RS} Please see above configuration output for determining Caching policy for target array's\n" elif [[ $(/opt/MegaRAID/MegaCli/MegaCli* -CfgDsply -aAll|grep -E "Solid State Device") ]] then printf "${BOLD}SSD's detected!${RS} Make sure \"Disk Cache\" is ${BOLD}enabled${RS} and \"Read-Ahead Cache\" is ${BOLD}disabled${RS}\n" elif [[ $(/opt/MegaRAID/MegaCli/MegaCli* -CfgDsply -aAll|grep -E "Hard Disk Device") ]] then printf "${BOLD}HDD's detected!${RS} Make sure \"Read-Ahead Cache\" is ${BOLD}enabled${RS}\n" fi elif [[ -e "/usr/StorMan/arcconf" ]] then printf "${BOLD}Adaptec RAID Detected${RS}\n" raid=1 printf "${UL}Firmware:${RS} $(if [ -n "`/usr/StorMan/arcconf getconfig 1 | grep ASR71605E`" ]; then /usr/StorMan/arcconf getconfig 1 | egrep 'Firmware.*7.[0-9]' | awk '{ if ($4 > "(30861)") print "ASR71605E Firmware is up to date: " $4; else print "ASR71605E Build version is < 30862! **Please update!** " }'; fi)\n" printf "${UL}Temp:${RS} $(/usr/StorMan/arcconf getconfig 1 |grep Temperature)\n" else printf " ${RED}No RAID Detected!${RS}\n" if [[ $raid ]] then if [[ -e "/usr/bin/raider" ]] then printf "${UL}Running Raider...no output is good${RS}\n" /usr/bin/raider --run-jobs else printf "${UL}Raider:${RS} ${RED}Not found! Make sure this is ok!${RS}\n" fi printf "${UL}StorMan:${RS}\n" service stor_agent stop; chkconfig stor_agent off fi fi printf "\n${YELLOW}cPanel${RS}\n" if [[ -e "/usr/local/cpanel/cpanel" ]] then printf "Detected!\n" printf "${UL}Checking License:${RS}\n" /usr/local/cpanel/cpkeyclt printf "${UL}License Type:${RS} " curl -s https://verify.cpanel.net/index.cgi?ip=$(ip ad sh eth0|sed -n 's|.*inet \(.*\)/.*|\1|p'|head -n1)|sed -n '/status1/,/\/tr/p'|grep -Eo ">.*-(INTERNAL|EXTERNAL|VPS|VZZO|YEAR|DAY-TEST|ENKOMP)<" printf "${UL}Backup Config:${RS}\n" whmapi1 backup_config_get|grep -E "backup(_daily|_monthly|_weekly|days)" if [[ $(ip link show | grep BROADCAST | sed -n 's/.*: \(.*\):.*/\1/p' | grep -v eth0) ]] then printf "${BOLD}Extra ethernet ports found!${RS} Would you like to set up reserved IP's now?\n" select yn in "Yes" "No" do case $yn in Yes ) interfaces=$(ip link show | grep BROADCAST | sed -n 's/.*: \(.*\):.*/\1/p' | grep -v eth0) for interface in $interfaces; do ipaddresses="$ipaddresses $(ip add show $interface | sed -n 's|.*inet \(.*\)/.*|\1|p')" done echo "IP's found:" for ipaddress in $ipaddresses; do echo " - $ipaddress" done printf "Is this list correct?\n" select ci in "Correct" "Incorrect" do case $ci in Correct ) for ipaddress in $ipaddresses; do [[ $(grep "$ipaddress=" /etc/reservedipreasons 2>/dev/null) ]] && continue echo "$ipaddress=Private IP Address" >> /etc/reservedipreasons echo "$ipaddress" >> /etc/reservedips done break ;; Incorrect ) printf "Skipping. Please set up manually.\n" break ;; esac done break ;; No ) printf "Moving along then...\n" break ;; esac done fi else printf " Not found!\n" fi printf "\n${YELLOW}Networking${RS}\n" printf "${UL}e1000e:${RS}\n" lsb_release -a 2>/dev/null|awk -F: '{ sub(/^[ \t\r\n]+/, "",$NF) ; if($1 ~ /^Dis/) d=$2; if($1 ~ /^Rel/) v=$2; } END { print "Checking OS Version... "; if (tolower(d) ~ "centos|cloudlinux" && v ~ /6[.][0-9]+/) { printf " Found: "d" "v"\nChecking for e1000e Driver...\n"; "dmesg|grep e1000e.*Driver"|getline o; if (o) { printf " Found: "o"\nChecking for kmod-e1000e...\n"; "yum list installed|grep kmod-e1000e"|getline k; if(k) { sub(/[ \t\r\n]+/," ",k); print " Found: "k; } else { print " kmod-e10001 is NOT installed.\n Check the E1000E internal wiki for more information."; }; } else { print " e1000e Driver is not being used\n kmod-e1000e is not needed.."; } ; } else { print " "d,v,"is not CentOS 6x, aborting additional checks." } }' printf "${UL}Interfaces:${RS}\n" for int in $(tail -n+3 /proc/net/dev|awk -F : '!/^\s+?lo/ {print $1}') do printf "${BOLD}$int${RS}: IP: $(ip add show $int | sed -n 's|.*inet \(.*\)/.*|\1|p'|paste -sd ",")" if [[ $(which ethtool 2>/dev/null) ]] then ethinfo=$(ethtool $int) if [[ $(printf "$ethinfo"|grep -E "^\s+?Speed") ]] then printf "$ethinfo"|grep -E "^\s+?(Speed|Duplex)"|paste -sd " " else printf "\n" fi else printf "\n" fi done printf "\nDo Guardian Checks?\n" select yn in "Yes" "No" do case $yn in Yes ) printf "${YELLOW}Guardian${RS}\n" printf "${UL}Agent Status:${RS}" /etc/init.d/cdp-agent status printf "${UL}Port 1167 Rules:${RS} (Listed below. If no results, then no port 1167 rules active)\n" iptables -nvL|grep 1167 printf "${UL}Dedicated MySQL Drive:${RS} " if [[ $(df|grep mysql) ]] then printf "Yes\n" else printf "No\n" fi printf "${UL}Plugin:${RS} " if [[ -e "/usr/local/cpanel/base/frontend/paper_lanten/guardianredirect.php" ]] then printf "Detected!\n" else printf "Not Detected!\n" fi break ;; No ) printf "Moving along then...\n" break ;; esac done printf "\n${YELLOW}Software${RS}\n" printf "${UL}Apache:${RS} " if [[ $(which httpd 2>/dev/null) ]] then printf "$(httpd -v 2>/dev/null|awk '/version/ {print $(NF-1) " " $NF}') ${UL}RemoteIP:${RS} $(httpd -M 2>/dev/null|awk '/(rpaf|remoteip|zeus)/ {print $1}'|paste -sd ",")\n" elif [[ -e "/usr/local/apache/bin/httpd" ]] then printf "$(/usr/local/apache/bin/httpd -v 2>/dev/null|awk '/version/ {print $(NF-1) " " $NF}') RemoteIP: $(httpd -M 2>/dev/null|awk '/(rpaf|remoteip|zeus)/ {print $1}'|paste -sd ",")\n" else printf "${RED}Not found!${RS}\n" fi printf "${UL}MySQL:${RS} " if [[ $(which mysqladmin 2>/dev/null) ]] then mysqladmin version|awk '/Server version/ {print $NF}' else printf "${RED}Not found!${RS}\n" fi printf "${UL}DNS/Nameservers:${RS}\n" if [[ $(which whmapi1 2>/dev/null) ]] then whmapi1 get_nameserver_config|sed -n '/nameservers/,/metadata/p'|grep -v metadata else printf " NOT cPanel, so not checking\n" fi printf "${UL}Root Forwarding:${RS}\n" if [[ $(which whmapi1 2>/dev/null) ]] then whmapi1 get_user_email_forward_destination user=root|sed -n '/forward_to/,/metadata/p'|grep -v metadata elif [[ -e "/root/.forward" ]] then cat /root/.forward elif [[ $(grep -E "^root:" /etc/aliases 2>/dev/null) ]] then grep -E "^root:" /etc/aliases else printf " ${RED}Unable to determine!${RS}\n" fi