5 Website Development Tips To Boost Your Business Growth Exponentially

performance-hacks-tweaks-for-linux.1280x600OK, sooner or later you will get to the point where making changes to all Linux servers in the environment proves difficult and time-consuming.
I have made this script which runs in Cron twice a day to check on services and optimizes the systems. It auto-installs Anti-virus if it isn’t installed and updates it if it is. It also Emails you all the system information, deletes /tmp files, and rotates logs. Soon I will be adding an optimizing SQL to it, and auto-add it to backup system, Nagios monitoring, auto-detect distro, and install based on that, SMTP – Exchange Server relay, add to Active Directory, and much more. My goal is to only make the server, then run this script and all is done. The cron job deletes the script and downloads a fresh UN-cached copy every time it runs.
It Prioritizes every service CPU Utilization the way it should be but that isn’t all. It also prioritizes IO hard drive access. This is useful because let’s say you have an MYSQL Server I’m sure you don’t want your backup service slowing your Database and all Website systems down. Just like QOS our system’s services need to be prioritized as well. Even if you have adequate resources.

Services this software can do

  • Core Services
    • Easy User friendly Control Panel interface
    • 1 Interface can connect and optimize your whole network
    • Prioritize services
    • Create Partitions and Resize LVM groups with a few clicks ( Great for Increasing VM HD)
    • Text Browsing – You can search the web on any command line server
    • IRC Channels –  get free support right from your server
    • Paid Support  – We have an options that allows you to email us,  call us ,  and/or enables us to remote Support your Server ( Our Manage Services Customers  have been using it)
    • System Benchmarking
    • 2 buttons restart any Linux server with check Disk
    • Installs The hardest  software with ease local / remote 1 button (  If your software is not listed we can add it)
    • Automatic updates with Free Memberships
  • Upcoming Features
    • We are always adding more Software to Provision
    • We will be making control panels for basic Functions for these popular ( making changes to 3rd party Programs)
    • Adding automated web submission and web task  (  like auto posting ads on Craigslist everyday at 8 pm)

This software Software grows Everyday and gets more powerful with every update.   Call us (404) 913 1821 and let us make this program work for your needs

BashPanel

(Versions may be different ) Script  can be  {phocadownload view=file|id=3|target=b}

Note:  We decided with the unlimited power of bash we are making a complete Control Panel called “Bash Panel”  This script will be minimized  for only prioritization please download the full version here.  {phocadownload view=file|id=1|target=b}

Also have adon’s To increase functionality:{phocadownload view=file|id=2|target=b}

{phocadownload view=file|id=4|target=b}

{phocadownload view=file|id=5|target=s}

{phocadownload view=file|id=6|target=s}

In order to Download you will need a Free subscription.

I set-up cron to  change directory to /tmp and download the newest file on the web server everyday  so  when I do make big changes which I do daily  it will update on its on too all servers

Script is tested with “Ubuntu, Centos, Openfiler ” Presumed to be working with “Debian and RedHat”  but not 100% sure

This script can now pass a few options at runtime.  And also has a menu with more options

-o  — options

1 )  Displaying System Information   2 )  Prioritize your Services  3) Benchmark Your System 4 ) Clean and rotate  Log Files and deleting  /tmp folders”

Example  :   # bash CPU-Priority.sh -o 1

Adding Cron

crontab -e
youremail @ Compay.com
30 7 * * *  "cd /tmp ;wget --no-cache https://www.cyfordtechnologies.com/scripts/CPU-Priority.sh ;  chmod +x CPU-Priority.sh ; ./CPU-Priority.sh ; rm -rf  CPU-Priority*

#!/bin/bash
# Copyright 2014 |Cyford Technologies LLC
#
# This file comes with NO WARRANTY of any kind
echo “Beta – Release”
clear

#
#
# set -x
# Setting Variables
########################### Getting Parameters #######################”
#Use predefined variables to access passed arguments
#echo arguments to the shell
variable1=$1
variable2=$2
#We can also store arguments form bash command line in special array
args=(“$@”)
if [ -z “$(echo $variable1)” ]
then
echo # “No Arguments Supplied at Run Time” #
else
echo $variable1 $variable2
if [[ $variable1 = -o ]]
then
echo Number of arguments passed: $#
if [ -z “$(echo $variable1 | grep [.0-5])*” ]
then
echo “Wrong Options Only 1-5  for now” #
else
echo “You passed $variable1 $variable2”
if [[ $variable2 = “1” ]]
then
export OPTION1=yes
echo “option 1 selected”
fi
if [[ $variable2 = “2” ]]
then
export OPTION2=yes
echo “option 2 selected”
fi
if [[ $variable2 = “3” ]]
then
export OPTION3=yes
echo “option 3 selected”
fi
if [[ $variable2 = “4” ]]
then
export OPTION4=yes
echo “option 4 selected”
fi
if [[ $variable2 = “5” ]]
then
export OPTION5=yes
echo “option 5 selected”
fi

fi
else
echo “Wrong Options Only -o  for now” #
fi
fi
#use $# variable to print out
#number of arguments passed to the bash script
########################### Setting Variables ##########################
export Server=$(“hostname”)
export User=$(“whoami”)
export Services=”nice -n 17 service –status-all |  grep running”
export LOG_DIR=”/var/log”
export ROOT_UID=0     # Only users with $UID 0 have root privileges.
export LINES=50       # Default number of lines saved.
export E_XCD=86       # Can’t change directory?
export E_NOTROOT=87   # Non-root exit error.
export LinuxVersion=”nice -n 17 cat /proc/version”
export CPU=”nice -n 17 cat /proc/cpuinfo”
export Mem=”nice -n 17 cat /proc/meminfo”
#    export  Bigfolder=$(nice -n 17 du –max-depth=1 -h / | sort -n -r | head -n 1 | grep /)
#    export  Bigfolder2=$(nice -n 17 du -a $Bigfolder | sort -n -r | head -n 3)
export serial=$(nice -n 17 dmidecode | egrep -i “product name|serial number”)
export sysinfo=”nice -n 17 dmidecode -t system”
export distro=”nice -n 17 cat /etc/*-release”
export ipinfo=”nice -n 17 ip addr show eth0″
export backulas=”bacula start”
export baculad=”ps -e | egrep bacula”
export centos=CentOS
export bashV=$(echo “Bash version ${BASH_VERSION}…”)
export bold=`tput bold`
export normal=`tput sgr0`
export HD=$(lsblk -n | head -n 1 | cut -d ” ” -f 1)
HDTotalSize=$(fdisk -l /dev/$HD |grep “Disk /dev/$HD:” | head -n 2 | tail -n 1 | cut -d ” ” -f 5)
HDFreeSpace=$(vgdisplay |grep “Free” | sed -n 1p | awk ‘{print $7}’)
export totalHDSpace=$( df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’)
export cyfordUser=FFF
export cyfordPass=FFF3
export todaysdate=$(date)
cyfordUser=$(cat “/etc/Cyford/ControlPanel/configs/configs.cfg” | grep “username”  | cut -d ” ” -f 2)
cyfordPass=$(cat “/etc/Cyford/ControlPanel/configs/configs.cfg” | grep “passwword”  | cut -d ” ” -f 2)
# httpd=`print $Services | grep httpd | cut -c7-`
# httpd=$(service –status-all |  grep running|  grep httpd)
# httpd=$(nice -n 17cat “$Services” |  grep httpd)
# httpd=$(nice -n 17 ps $Services | grep httpd)
###################################################################
########################### Getting Install Command ###############
if [ -z “$($distro | grep Cent)” ]
then
echo # “not centos”
else
installv=”yum -y install”
System0=”CentOs”
fi
###################################################################
if [ -z “$($distro | grep RedH)” ]
then
echo #  “not RedHat”
else
installv=”yum -y install”
System0=”Red Hat”
fi
###################################################################
if [ -z “$($distro | grep Openf)” ]
then
echo #  “not OpenFiler”
else
installv=”conary update”
System0=”OpenFiler”
fi
###################################################################
if [ -z “$($distro | grep Ubuntu)” ]
then
echo #  “not Ubuntu”
else
installv=”apt-get install”
System0=”Ubuntu”
fi
###################################################################
if [ -z “$($distro | grep Debian)” ]
then
echo #  “not Debian”
else
installv=”sudo apt-get install”
System0=”Debian”
fi

################################################################################################################################################################################################################################################################################################################################
for (( ; ; ))
do

if [ -z “$(echo $variable1)” ]
then
echo “Cyord Technologies LLC – Bash Panel”
echo “https://www.cyfordtechnologies.com/
bashpanelversion=”Script Version 2.4.6.9″
echo   “$bashpanelversion”
echo “Beta – Release”
export TERM=xterm
hostname
echo
echo
echo
echo “###################################################################”
echo “#########                                              ############”
echo ”              **** Making Your Life Easier ****                    ”
echo “#########                                              ############”
echo “#########                                              ############”
echo “###################################################################”
PS3=”Your choice: ”
echo What would you like to do ?  Choose a number
echo
echo
select choice in “Display System Information” “Terminal Command” “Configure Remote System” “Text Browsing” “IRC Support Channels” “Prioritize your Services”  “Benchmark Your System”  “Clean Log Files and /tmp folders” “Testing Area” “Control Panel” “EXIT”; do
case “$choice” in

“Display System Information”)     clear ; echo “$choice”; # do something;
export OPTION1=yes
break;;
“Configure Remote System”)         clear ; echo “$choice”; # do something;
export OPTION13=yes
break;;
“Terminal Command”)             clear ; echo “$choice”; # do something;
export OPTION16=yes
break;;
“Text Browsing”)             clear ; echo “$choice”; # do something;
export OPTION14=yes
break;;
“IRC Support Channels”)         clear ; echo “$choice”; # do something;
export OPTION15=yes
break;;
“Prioritize your Services”)     clear ; echo “$choice”; # do something;
export OPTION2=yes
break;;
“Benchmark Your System”)         clear ; echo “$choice”; # do something;
export OPTION3=yes
break;;
“Clean Log Files and /tmp folders”) clear ; echo “$choice”; # do something;
export OPTION4=yes
break;;
“Testing Area”)             clear ; echo “$choice”; # do something;
export OPTION10=yes
clear ; echo “This is for testing new scripts,   Can not pass variables during execution for this”
break;;
“EXIT”) echo “$choice”; # do something;
clear ; echo “Hope you liked,  Have a great day :)”
rm -rf  /root/CPU-Priority* ; rm -rf  /tmp/CPU-Priority* ; exit 0
break;;
“Control Panel”)             clear ; echo “$choice”; # do something;

echo “Our Control Panel”
PS3=”Your CP choice: ”
select choice in “Install Software” “Resize LVM Root Drive” “Restart Server with CHKDSK” “Install & Enable Auto-Updates” “Support” “EXIT”  ; do
case “$choice” in
“Install Software”)     echo “$choice”; # do something;
clear ; echo “This is a nice tool  for Popular Servers (Mosted tested with Centos)”

cd /etc/Cyford/ControlPanel/software
echo “We will  be using $cyfordUser as your username”
MODDATE=$(date -r cyford-software-Install.sh “+%Y%m%d %R:%S %z”)
echo “Running Version = $bashpanelversion Last time since change was $MODDATE ”
ionice -c2 -n7 nice -17 curl -s -L –cookie-jar cookies -o /dev/null “http://    www.cyfordtechnologies.com/index.php?user=$cyfordUser&passw=$cyfordPass” ; ionice -c2 -n7 nice -17 curl -s -L –cookie-jar cookies –cookie cookies -z”${MODDATE}”  -o cyford-software-Install.sh   “https://www.cyfordtechnologies.com/category/1-bash-panel?download=2%3Acyford-s-bash-panel-install-software
chmod 644 cyford-software-Install.sh
source cyford-software-Install.sh
break;;

“Resize LVM Root Drive”)     echo “$choice”; # do something;
clear ; echo “This is a nice tool  for adding diskspace to LVM Groups”
export OPTION20=yes
break;;
“Configure Remote Server”)     echo “$choice”; # do something;
clear ; echo “Restart Server with CHKDSK”
export OPTION50=yes
break;;
“Run your Own Command”)     echo “$choice”; # do something;
clear ; echo “Restart Server with CHKDSK”
export OPTION51=yes
break;;
“Restart Server with CHKDSK”)     echo “$choice”; # do something;
clear ; echo “Restart Server with CHKDSK”
shutdown -rF now
break;;
“Support”)     echo “$choice”; # do something;
clear ; echo “This is where we can help You”
export OPTION1001=yes
break;;
“Install & Enable Auto-Updates”)     echo “$choice”; # do something;
echo “Upgrading Bash Panel”
export OPTION63=yes
break;;
“EXIT”) echo “$choice”; # do something;
echo “Going back to first menu”
rm -rf  /root/CPU-Priority* ; rm -rf  /tmp/CPU-Priority* ; exit 1
break;;
esac
done
break;;
*) echo invalid option;;

esac

done
fi

###########################

#  Installing And Enabling Auto Updates
if [[ $OPTION63 = “yes” ]]
then
echo Run updates ?  $OPTION63

if [ -z “$(cat “/etc/Cyford/ControlPanel/configs/configs.cfg” | grep “No such file”)” ]
then
cd /etc/Cyford/
cyfordUser=$(cat “/etc/Cyford/ControlPanel/configs/configs.cfg” | grep “username”  | cut -d ” ” -f 2)
cyfordPass=$(cat “/etc/Cyford/ControlPanel/configs/configs.cfg” | grep “passwword”  | cut -d ” ” -f 2)
echo “We will  be using $cyfordUser as your username”
MODDATE=$(date -r ControlPanel.sh “+%Y%m%d %R:%S %z”)
echo “Running Version = $bashpanelversion Last time since change was $MODDATE ”
ionice -c2 -n7 nice -17 curl -s -L –cookie-jar cookies -o /dev/null “https://www.cyfordtechnologies.com/index.php?user=$cyfordUser&passw=$cyfordPass” ; ionice -c2 -n7 nice -17 curl -s -L –cookie-jar cookies –cookie cookies -z”${MODDATE}”  -o ControlPanel.sh   “https://www.cyfordtechnologies.com/category/1-bash-panel?download=1%3Acyford-s-bash-panel
export OPTION63=no
exec bash ControlPanel.sh
MODDATE=$(date -r ControlPanel.sh “+%Y%m%d %R:%S %z”)
echo “New Version = $bashpanelversion And with modification date $MODDATE ”
echo “Some Changes may not show until you exit and re-run Bash Panel ”
export OPTION63=no
else

echo “Installing”
MODDATE=$(date -r ControlPanel.sh “+%Y%m%d %R:%S %z”)
mkdir /etc/Cyford/ ; mkdir /etc/Cyford/ControlPanel/ ; mkdir /etc/Cyford/ControlPanel/software ; mkdir /etc/Cyford/ControlPanel/configs
chmod -R 644 /etc/Cyford/ ; touch  /etc/Cyford/ControlPanel/configs/configs.cfg
cd /etc/Cyford/
echo $MODDATE
if [ -z “$(cat “/etc/Cyford/ControlPanel/configs/configs.cfg” | grep “username”)” ]
then
echo “Setting up username Password for Cyford Technologies Website”
echo “What is the username you used to register on Cyford Technologies LLC”
read input_variable_Cyford_uname
echo “You entered: $input_variable_Cyford_uname”
echo “What is the Password:  (no spaces)”
read input_variable_Cyford_Password
echo “You entered: $input_variable_Cyford_Password”
echo “# Bash Panel Control Settings
# Username
username= $input_variable_Cyford_uname
passwword= $input_variable_Cyford_Password

” >> /etc/Cyford/ControlPanel/configs/configs.cfg
echo “Using $cyfordUser as your username”
MODDATE=$(date -r ControlPanel.sh “+%Y%m%d %R:%S %z”)
echo $MODDATE
curl -s -L –cookie-jar cookies -o /dev/null “https://www.cyfordtechnologies.com/index.php?user=$cyfordUser&passw=$cyfordPass” ; curl -s -L –cookie-jar cookies –cookie cookies -z “${MODDATE}”  -O “https://www.cyfordtechnologies.com/category/1-bash-panel?download=1%3Acyford-s-bash-panel
export OPTION63=no
fi
OPTION63=no
fi
export OPTION63=no
fi
OPTION63=no
############################

###################################################################

if [[ $OPTION1 = “yes” ]]
then
echo “################# System Information #################”
###################################################################
echo “Looks like your running $System0 !!!!!!!!!!
Setting install command to ( $installv )”

# Greetings
echo  “I am $User
And I live at $Server ”

echo “username: = “$User
echo “computername: =” $Server
echo “system Type”
echo “If this is a VM  Your serial will probably will be blank:”
echo $serial
echo “If this is a VM your system info would probably will be blank:”
eval $sysinfo
echo “Your Linux Distro:”
eval $distro
echo “Your IP Information:”
eval $ipinfo
echo “################# Kernel #################”
eval  $LinuxVersion
echo “################# CPU #################”
eval $CPU
echo “################# Memory #################”
eval $Mem
echo “################# Where is most the data #################”
echo “disabled for now:”
# echo $Bigfolder2
echo “################# running Software ################# ”
eval  “$Services”
echo “################# END #################”
export OPTION1=no
fi
################################################################################################################################################################################################################################################################################################################################

if [[ $OPTION2 = “yes” ]]
then
echo “Lets  Prioritize your services for CPU and IO”
echo “Setting root to 5”
renice  5 -u root
#########################################################################################################################
echo “########################### Apache ###########################”
#  echo “Checking if Apache is running”
if [ -z “$(pgrep httpd)” ]
then
echo “Apache is not running” # foo is not running

else
echo “Apache is on this server and running so i will be optimizing its Priority on the server ############################### :)” # foo is running
echo “Setting IO to highest Priority”
ionice -c2 -n0 -p $(pidof -x httpd)
renice  -10 -p $(pgrep openfiler)

fi

#########################################################################################################################
echo “########################### Openfiler ###########################”
#  echo “Checking if openfiler is running”
if [ -z “$(pgrep openfiler)” ]
then
echo “openfiler is not running” # foo is not running

else
echo “openfiler is on this server and running so i will be optimizing its Priority on the server ###############################:)” # foo is running
echo “Setting IO to Lowest Priority”
ionice -c2 -n7 -p $(pgrep openfiler)
renice  10 -p $(pgrep openfiler)

fi

#########################################################################################################################
echo “########################### Mysql ###########################”
#  echo “Checking if mysql is running”
if [ -z “$(pgrep mysql)” ]
then
echo “mysql is not running” # foo is not running

else
echo “mysql is on this server and running so i will be optimizing its Priority on the server############################### :)” # foo is running
echo “Setting IO to highest Priority”
ionice -c2 -n0 -p $(pgrep mysql)
renice  -13 -p $(pgrep mysql)

fi

#########################################################################################################################
echo “########################### Bacula ###########################”
#  echo “Checking if bacula is running”
if [ -z “$(pgrep bacula)” ]
then
echo “bacula is not running- Going to try starting it” # foo is not running
$installv bacula-fd
echo “$backulas”
/etc/init.d/bacula-fd start
echo “Setting IO to Lowest Priority”
ionice -c2 -n7 -p $(pgrep bacula)
sudo renice  20  -p $(pgrep bacula)
renice  20 -u bacula
# yum install bacula-fd

else
echo “bacula is on this server and running so i will be optimizing its Priority on the server ###############################:)” # foo is running

/etc/init.d/bacula-fd start
echo “not working”
echo $baculad
echo “Setting IO to Lowest Priority”
sudo ionice -c2 -n7 -p $(pgrep bacula)
sudo renice 20  -p $(pgrep bacula)

fi

#########################################################################################################################
echo “########################### Clamav ###########################”
#  echo “Checking if clamav is running”
clamd
if [ -z “$(pgrep clam)” ]
then
echo “clamav (Antivirus) is not running-  But i will fix that” # foo is not running
echo “Installing Antivirus on here”
########################################
if [ -z “$($distro | grep Openf)” ]
then
$installv clamav clamd clamav-daemon
else

echo ” Seems your running Openfiler,  We will be installing from source,   sit back and relax”
eval $installv gcc glibc:devellib glibc:devel zlib:devel bzip2 bzip2:devel
groupadd clamav
useradd -g clamav -s /bin/false -c “Clam AntiVirus” clamav
cd /tmp
wget http://ftp.sunet.se/pub/gnu/gmp/gmp-4.2.4.tar.gz
tar zxvf gmp-4.2.4.tar.gz
cd gmp-4.2.4
./configure && make && make check && make install
cd ..
wget http://kent.dl.sourceforge.net/sourceforge/clamav/clamav-0.94.2.tar.gz
tar zxvf clamav-0.94.2.tar.gz

cd clamav-0.94.2
./configure –sysconfdir=/etc && make && make check && make install
read -p “In most cases before you can start you need to remove or comment the Example line in “/etc/clamd.conf”
Press [Enter] key to start backup…”
fi
########################################

/etc/init.d/clamd on
/etc/init.d/clamd start
* Updating the antivirus
/usr/bin/freshclam
touch /etc/cron.daily/manual_clamscan

match=’fields’
insert=’#!/bin/bash
SCAN_DIR=”/home”
LOG_FILE=”/var/log/clamav/manual_clamscan.log”

/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE’
file=’/etc/cron.daily/manual_clamscan’

sed -i “s/$match/$match\n$insert/” $file

# /usr/share/spamassassin/sa-update.cron 2>&1 | tee -a /var/log/sa-update.log
else
echo “clamav is on this server and running so i will be optimizing its Priority on the server ###############################:)” # foo is running
echo “Setting IO to MID “5” Priority”
ionice -c2 -n5 -p $(pgrep clamd)
echo “Setting CPU to MID “10” Priority”
renice  10  -p $(pgrep clamd)
# renice  11 -u clamd

fi

#########################################################################################################################
echo “########################### puppet ###########################”
#  echo “Checking if puppet is running”
if [ -z “$(pgrep puppet)” ]
then
$installv puppet
echo “puppet is not running” # foo is not running
else
echo “puppet is on this server and running so i will be optimizing its Priority on the server ############################### :)” # foo is running
echo “Setting IO to Lowest Priority”
ionice -c2 -n7 -p $(pgrep puppet)
renice  13 -p $(pgrep puppet)
fi
#########################################################################################################################
echo “########################### nagios ###########################”
#  echo “Checking if nagios-nrpe is running”
if [ -z “$(pgrep nrpe)” ]
then
echo “nrpe is not running” # foo is not running
else
echo “nrpe is on this server and running so i will be optimizing its Priority on the server ############################### :)” # foo is running
echo “Setting IO to Lowest Priority”
ionice -c2 -n7 -p $(pgrep nrpe)
renice  14 -u nagios
fi
#########################################################################################################################
echo “########################### Squid ###########################”
#  echo “Checking if squid is running”
if [ -z “$(pgrep squid)” ]
then
echo “squid is  not running” # foo is not running

else
echo “squid is on this server and running so i will be optimizing its Priority on the server ############################### :)” # foo is running
echo “Setting IO to Highest Priority”
ionice -c2 -n0 -p $(pgrep squid)
renice  -0 -p $(pgrep squid)

fi
#########################################################################################################################
echo “########################### Asterisk ###########################”
#  echo “Checking if asterisk is running”
if [ -z “$(pgrep asterisk)” ]
then
echo “asterisk is not running” # foo is not running

else
echo “asterisk is on this server and running so i will be optimizing its Priority on the server ############################### :)” # foo is running
echo “Setting IO to Highest Priority”
ionice -c2 -n0 -p $(pgrep asterisk)
renice  -14 -p $(pgrep asterisk)

fi

#########################################################################################################################
echo “########################### haproxy ###########################”

#  echo “Checking if haproxy is running”
if [ -z “$(pgrep haproxy)” ]
then
echo “haproxy is not running” # foo is not running

else
echo “haproxy is on this server and running so i will be optimizing its Priority on the server  :)” # foo is running
echo “Setting IO to Highest Priority”
ionice -c2 -n0 -p $(pgrep asterisk)
renice  -13 -u asterisk

fi
export OPTION2=no
fi
################################################################################################################################################################################################################################################################################################################################
if [[ $OPTION3 = “yes” ]]
then

echo “################# Lets Benchmark your system #################”
if [ -z “$($distro | grep -o Openf)” ]
then
echo “not of”
else
echo “ran export”
$(export LD_LIBRARY_PATH=/usr/local/mysql/lib/)
export LD_LIBRARY_PATH=/usr/local/mysql/lib/
fi
###################################################################
echo “checking if Sysbench is installed”
if [ -z “$(sysbench –help | grep -o -E ‘prepare run cleanup help version’)” ]
then

############################# Installing Section   ######################################
echo “need install first”
if [ -z “$($distro | grep Openf)” ]
then
echo “Not Openfiler Great  will  install easy and run next time”
$installv sysbench bc nproc
else
echo ” Seems your running Openfiler,  We will be installing from source,   sit back and relax”
cd /tmp
conary update  mysql:devel bc nproc automake gcc libtool glib glib:devel autoconf pkgconfig
wget http://tcpdiag.dl.sourceforge.net/project/sysbench/sysbench/0.4.12/sysbench-0.4.12.tar.gz
tar xvzf sysbench-0.4.12.tar.gz
cd sysbench-0.4.12
aclocal
libtoolize –force –copy
./autogen.sh
./configure
make
make install
export LD_LIBRARY_PATH=/usr/local/mysql/lib/
echo “Installed on Openfiler,  will run next time”
# read -p “Press [Enter] key to start backup…”

fi
############################# Installing Section END ######################################
else
echo “Sysbench is installed”
nproc=$(grep -c processor /proc/cpuinfo)

if [ -z “$(sudo dmidecode -t processor | grep Manufacturer)” ]
then
echo “You Probably running in a VM and all CPU  are labeled differently.  We will adjust for that”
nproc=$(grep -i “processor” /proc/cpuinfo | sort -u | wc -l)
phycore=$(grep -i “processor” /proc/cpuinfo | sort -u | wc -l)
VM=1
else
nproc=$(grep -i “processor” /proc/cpuinfo | sort -u | wc -l)
phycore=$(cat /proc/cpuinfo | egrep “core id|physical id” | tr -d “\n” | sed s/physical/\\nphysical/g | grep -v ^$ | sort | uniq | wc -l)

VM=0

ht=0
fi

cpuprime=(20000)
# cputime=$(nice -n 20 ionice -c2 -n7 sysbench –num-threads=$nproc –test=cpu –cpu-max-prime=$cpuprime run | grep  “total time:”| grep -o -E ‘[.0-9]…..’)
# threads=$(nice -n 20 ionice -c2 -n7 sysbench –num-threads=64 –test=threads –thread-yields=100 –thread-locks=2 run | grep  “execution time”| grep -o -E ‘[.0-9]…..’)
# mutex=$(nice -n 20 ionice -c2 -n7 sysbench –num-threads=64 –test=mutex –thread-yields=100 –thread-locks=2 run | grep  “execution time”| grep -o -E ‘[.0-9]…..’)
# mem=$(nice -n 20 ionice -c2 -n7 sysbench –test=memory –num-threads=4 run | grep  “execution time”| grep -o -E ‘[.0-9]…..’)
if [ -z “$(sudo dmidecode -t processor | grep HTT)” ]
then

echo “No HT – Processing as normal”
ht=0
else
echo “Adjusting Parameters to account for you having HT Enabled HT = 25% of real Processor”
ht=.50
fi

echo “### CPU Benchmarks (with lowest priority for Live Servers) ###”
echo “Maximum prime number checked in CPU test: 20000”
echo “Total cpu process used” $nproc

echo “Cpu Overall Speed ################################### ”
echo “we ran $cpuprime Cycles”
echo “Your PC processed the data in the time below (Lower is Better)”
echo $cputime
echo “Your Cpu Proficiency Performance is $cpuprime / (Treads $nproc – (Treads $nproc – PhyProcessors $phycore)* HT Proficiency $ht)  ”
cpuscore=$(echo “scale=5; $cpuprime/$cputime/($nproc – ($nproc – $phycore)* $ht) ” | bc)
echo $cpuscore
echo “Your Cpu Proficiency / Power is $cpuprime / $cputime/ $phycore)) ”
cpuscorep=$(echo “scale=5; $cpuprime/$cputime/($phycore) ” | bc)
echo $cpuscorep
echo “threads ################################### ”
echo ”     This test mode was written to benchmark scheduler performance, more
specifically the cases when a scheduler has a large number of
threads competing for some set of mutexes.

SysBench creates a specified number of threads and a specified
number of mutexes. Then each thread starts running the requests
consisting of locking the mutex, yielding the CPU, so the thread is
placed in the run queue by the scheduler, then unlocking the mutex
when the thread is rescheduled back to execution. For each request,
the above actions are run several times in a loop, so the more
iterations is performed, the more concurrency is placed on each
mutex.
10000 / $threads / 100 *2 ”

threadscore=$(echo “scale=5; 1000 / $threads/ 10 *2  ” | bc)
echo $threadscore
echo “mutex ################################### ”
echo ”  mutex This test mode was written to emulate a situation when all threads
run concurrently most of the time, acquiring the mutex lock only
for a short period of time (incrementing a global variable). So the
purpose of this benchmarks is to examine the performance of mutex
implementation. 10000 / $threads / 100 *2 ”
mutexscore=$(echo “scale=5; 1000 / $mutex/ 10 *2  ” | bc)

echo “mutex”   $mutexscore

echo “Total CPU Performance ################################### ”

tcpu=$(echo “scale=5; ($mutexscore+$threads+$cpuscore)/3  ” | bc)
echo “CPU Total”   $tcpu

echo “MEM Performance ################################### ”

tmem=$(echo “scale=5; (100 / $mem)  ” | bc)
echo “Mem Total”   $tmem

fi
export OPTION3=no

fi

if [[ $OPTION10 = “yes” ]]
then

echo “Testing HT ”  ###############################################################################################################################################

echo “Testing Puppet install END ########### ” ##########################################################################

if [ -z “$(echo “$phycore *2″ | bc | grep $nproc)” ]
then
echo “Does not look like you have HT Enabled”
if [ -z “$( dmidecode -t processor | grep HTT)” ]
then

echo “HT is not Possible on this server”
else
echo “This server is HT Capable,  However it is Disabled”
fi
else
echo ” HT Is working and Enabled”
fi

echo “testing ################################### ”
export OPTION10=no
fi
################################################################################################################################################################################################################################################################################################################################

if [[ $OPTION4 = “yes” ]]
then

echo “############################################ Cleaning Log Files ######################################################”
# Cleanup, version 3

#  Warning:
#  ——-
#  This script uses quite a number of features that will be explained
#+ later on.
#  By the time you’ve finished the first half of the book,
#+ there should be nothing mysterious about it.

# Run as root, of course.
if [ “$UID” -ne “$ROOT_UID” ]
then
echo “Must be root to run this script.”
exit $E_NOTROOT
fi

if [ -n “$1” ]
# Test whether command-line argument is present (non-empty).
then
lines=$1
else
lines=$LINES # Default, if not specified on command-line.
fi

#  Stephane Chazelas suggests the following,
#+ as a better way of checking command-line arguments,
#+ but this is still a bit advanced for this stage of the tutorial.
#
#    E_WRONGARGS=85  # Non-numerical argument (bad argument format).
#
#    case “$1” in
#    “”      ) lines=50;;
#    *[!0-9]*) echo “Usage: `basename $0` lines-to-cleanup”;
#     exit $E_WRONGARGS;;
#    *       ) lines=$1;;
#    esac
#
#* Skip ahead to “Loops” chapter to decipher all this.

cd $LOG_DIR

if [ `pwd` != “$LOG_DIR” ]  # or   if [ “$PWD” != “$LOG_DIR” ]
# Not in /var/log?
then
echo “Can’t change to $LOG_DIR.”
exit $E_XCD
fi  # Doublecheck if in right directory before messing with log file.

# Far more efficient is:
#
# cd /var/log || {
#   echo “Cannot change to necessary directory.” >&2
#   exit $E_XCD;
# }

tail -n $lines messages > mesg.temp # Save last section of message log file.
mv mesg.temp messages               # Rename it as system log file.

#  cat /dev/null > messages
#* No longer needed, as the above method is safer.

cat /dev/null > wtmp  #  ‘: > wtmp’ and ‘> wtmp’  have the same effect.
echo “Log files cleaned up.”
#  Note that there are other log files in /var/log not affected
#+ by this script.

################################################################################################################################################################################################################################################################################################################################
echo “############################################### General Maintenance ###################################################”
echo “Temporarily Disabling Selinux”
echo 0 >/selinux/enforce
#      Pausing the script  when testing
# read -p “Press [Enter] key to start backup…”

echo “#### Deleting TMP files ####”
rm -rf /tmp/*

echo “#### Mounting Shares for Scripts ####”

if [ -z “$(ps aux | grep nfs)” ]
then

read -p “Installing NFS Client – Press [Enter] key to start backup…”

$installv nfs-utils nfs-utils-lib
fi
mkdir /mnt/scripts
chmod 777 /mnt/scripts
mount -t nfs 192.168.111.191:/mnt/sata/cyford-software/cyford-software/scripts /mnt/scripts
export OPTION4=no
fi

#################################################################
if [[ $OPTION20 = “yes” ]]
then

if [ -z “$(cat /tmp/booted.txt | grep -o booted)” ]

then
echo “Your HD Is /dev/$HD”
echo “you have $totalHDSpace Free Space”
sleep 5s
echo “But you have $HDFreeSpace Free Space unpartitioned space.”

fdisk -l /dev/$HD |grep “Disk /dev/$HD:” | head -n 2 | tail -n 1 | cut -d ” ” -f 1

echo ${bold}”Use options (‘P’ ‘N’ ‘P’ ‘<ENT>”<ENT>’ ‘t’ ‘3’ ‘8e’ ‘w’)”${normal}
fdisk “/dev/$HD”

read -p “Need to reboot now for changes to take effect. ‘Please hit CTR To stop Reboot if needed’ Otherwise Enter to continue”
echo “booted” > /tmp/booted.txt
chmod 644 /tmp/booted.txt
shutdown -rf now

else

echo “Welcome Back.  Lets finish Resizing your Disk”

PS3=”The Partition we created in fdisk was /dev/$HD”

select choice in “1” “2” “3” “4” “5”  “6” “7” ; do
case “$choice” in

“1”) echo “$choice”; # do something;
echo “$HD1 and $HD2 where already set for  / and /boot,  Please choose the one you used for fdisk to create the partition”
break;;
“2”) echo “$choice”; # do something;
echo “$HD1 and $HD2 where already set for  / and /boot,  Please choose the one you used for fdisk to create the partition”
break;;
“3”) echo “$choice”; # do something;
export partitioner=”/dev/”$HD”3″
break;;
“4”) echo “$choice”; # do something;
export partitioner=”/dev/”$HD”4″
break;;
“5”) echo “$choice”; # do something;
export partitioner=”/dev/”$HD”5″
break;;
“6”) echo “$choice”; # do something;
export partitioner=”/dev/”$HD”6″
break;;
“7”) echo “$choice”; # do something;
export partitioner=”/dev/”$HD”7″
break;;

*) echo invalid option;;
esac
done
VGroup=$(vgdisplay | grep “VG Name” | sed -n 1p | awk ‘{print $3}’)
lvol=$(lvdisplay |grep “LV Name” | sed -n 1p | awk ‘{print $3}’)
HD=$(lsblk | head -n 2 | tail -n 1 | cut -d ” ” -f 1)
HDTotalSize=$(fdisk -l /dev/$HD |grep “Disk /dev/$HD:” | head -n 2 | tail -n 1 | cut -d ” ” -f 5)
HDFreeSpace=$(vgdisplay |grep “Free” | sed -n 1p | awk ‘{print $7}’)
totalHDSpace=$( df -H | grep -vE ‘^Filesystem|tmpfs|cdrom’ | awk ‘{ print $5 ” ” $1 }’)
echo : “You HD = /dev/$HD ”
echo : “$partitioner is now set”
pvcreate $partitioner
vgextend VolGroup $partitioner
echo “Your Logical Drive is /dev/$VGroup/$lvol”
lvextend -L+””$HDFreeSpace”G” /dev/$VGroup/$lvol
resize2fs /dev/$VGroup/$lvol
echo “We are finished”
echo “Now you have more Free Space”
rm -rf /tmp/booted.t*
df -h
export OPTION20=no
fi
fi
##################################   SUPPORT   ###########################################
if [[ $OPTION1000 = “yes” ]]
then

select choice in “Send Email” “Phone Support” “Allow us Remote Access”  ; do
case “$choice” in

“Send Email”) echo “$choice”; # do something;
echo “Lets gather System Specs and send an email to our support engineers”
OPTION1001=yes
break;;
“Phone Support”) echo “$choice”; # do something;
echo “This Feature is in beta and will be available soon”
break;;
“Allow us Remote Access”) echo “$choice”; # do something;
echo “This Feature is in beta and will be available soon”
break;;

*) echo invalid option;;
esac
done

fi
if [[ $OPTION1001 = “yes” ]]
then

echo “what is your Email Address”
read input_email
echo “You entered: $input_email”
echo “Subject For the email”
read input_emailsubject
echo “You entered: $input_emailsubject”
echo “Detailed Discription Of your issue”
read input_emailbody
echo “You entered: $input_emailbody”

(
echo “HELO”;
sleep 2;
echo “MAIL FROM: $input_email”;
sleep 2;
echo “RCPT TO: [email protected]“;
sleep 2;
echo “DATA”;
sleep 2;
echo -e “From: <from email>”;
echo -e “Subject:$input_emailsubject”;
echo -e “${input_emailbody}.”
echo -e “\n\n.”;
sleep 3;
echo “QUIT”;
) | telnet mail.cyfordtechnologies.com 25

fi
export OPTION1000=no
##########################################################################################
if [[ $OPTION15 = “yes” ]]
then
echo “IRC channel you looking for without the #”
read input_irc_channel
echo “You entered: $input_irc_channel”
echo “irc username ”
read input_irc_uname
echo “You entered: $input_irc_uname”
PORT=6667
SERVER=irc.freenode.com
# Main

ionice -c2 -n7 nice -17 $installv BitchX
ionice -c2 -n7 nice -17 BitchX irc.freenode.com:6667 -n ${input_irc_uname} -c \#${input_irc_channel}

# epic5 ” irc.freenode.com -z ${input_irc_uname} -c ${input_irc_channel} -L /etc/Cyford/cyfordirc.irc”
fi
OPTION15=no
##########################################################################################
##########################################################################################
if [[ $OPTION13 = “yes” ]]
then

echo “IP Of the server you would like to connect to”
read input_SSHIP
echo “You entered: $input_SSHIP”
# ionice -c2 -n7 nice -17 ssh-keygen
# ionice -c2 -n7 nice -17 ssh-copy-id -i ~/.ssh/id_rsa.pub “${input_SSHIP}”
ionice -c2 -n7 nice -17 ssh “root@”${input_SSHIP}”” ‘mkdir /etc/Cyford/ ; mkdir /etc/Cyford/ControlPanel/ ; exit’
scp  /etc/Cyford/ControlPanel.sh root@”${input_SSHIP}”:/etc/Cyford/ControlPanel.sh
ionice -c2 -n7 nice -17 ssh “${input_SSHIP}” ‘cd /etc/Cyford/ ; bash ControlPanel.sh’
fi
OPTION13=no
##########################################################################################
##########################################################################################
if [[ $OPTION14 = “yes” ]]
then

echo “Website Would you like to go to”
read input_website
echo “You entered: $input_website”
ionice -c2 -n7 nice -17 $installv lynx
ionice -c2 -n7 nice -17 lynx -accept_all_cookies $input_website
fi
OPTION14=no
##########################################################################################
##########################################################################################
if [[ $OPTION16 = “yes” ]]
then

echo “What Shell Command would you like to run”
read input_CMD
echo “You entered: $input_CMD”
ionice -c2 -n7 nice -17 “${input_CMD}”

fi
OPTION16=no
##########################################################################################
# exit 0
#  A zero return value from the script upon exit indicates success
#+ to the shell.
if [ -z “$(echo $variable1)” ]
then
echo $variable1
# read -p “Script down for maintenance”
else
exit 0
fi
done



Published on: Mar 03, 2021

Categories: Web Development

    No Comments yet! Be the first one to write.


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    user IP : 3.146.34.191 | Server_IP: 192.168.111.161 | IP_Score: