organzing for portfolio

This commit is contained in:
2024-12-13 17:32:49 -06:00
parent 299f95e2fb
commit 1b0612b005
30 changed files with 910 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
#!/bin/bash
for did in $(docker ps -a |grep -v IMAGE|awk '{print $1}'); do docker rm -f $did;done
for did in $(docker image ls |grep -v IMAGE|awk '{print $3}'); do docker image rm -f $did;done

View File

@@ -0,0 +1,29 @@
#!/bin/bash
#Wrapper for various items which play traffic.
#tcpreplay,tomahawk,isic suite
#Check for presence of eth0 in passed arguments and abort/alert
OPTIONS="$@"
function ABORT()
{
#red bg 0;41
#white text 1;37
chmod 400 $0.real
chmod 400 $0
MESSAGE="You have attempted to execute an action which will result in harm to the system. The system is now terminating all shell sessions on this host and alerting support personnel. You will lose any unsaved work."
echo -e "\e[0;41m$MESSAGE\e[1;37"
mailsend -q -smtp RELAYHOST -t PAGEREMAIL -f ALERTFROMEMAIL -sub "$0 using eth0 activity on $(hostname)" -M "$(hostname) attempted to play traffic using $0 out of eth0 at $(date)."
killall -g -9 bash
}
ETH0_CHECK=$(echo $OPTIONS | grep eth0 -c)
if [ $ETH0_CHECK -gt 0 ];
then
ABORT
fi
#If all checks pass, go ahead and execute the invoking program
$0.real $OPTIONS

View File

@@ -0,0 +1,10 @@
function custom_ssh()
{
CUSTOMSSH_USER=$1
CUSTOMSSH_HOST=$2
CUSTOMSSH_COMMAND=$3
SSH_TARGET="$CUSTOMSSH_USER@$CUSTOMSSH_HOST"
ssh -q -t -o StrictHostKeyChecking=no -i $SSH_KEY $SSH_TARGET "$CUSTOMSSH_COMMAND"
}

View File

@@ -0,0 +1,17 @@
function obtain_centos_mac()
{
DISTRO_TYPE="$(distro |awk '{print $1}'|tr '[:upper:]' '[:lower:]')"
DISTRO_VERSION=$(distro |awk '{print $2}'|awk -F '.' '{print $1}')
if [ $DISTRO_TYPE == "centos" ] && [ $DISTRO_VERSION == 6 ] ;
then
/sbin/ifconfig eth0|grep HWadd| awk '{print $NF}'|tr '[:upper:]' '[:lower:]'|sed 's/\:/-'/g
fi
if [ $DISTRO_TYPE == "centos" ] && [ $DISTRO_VERSION == 7 ] ;
then
/sbin/ifconfig eth0|grep ether| awk '{print $2}'|tr '[:upper:]' '[:lower:]'|sed 's/\:/-'/g
fi
}

View File

@@ -0,0 +1,21 @@
#!/bin/bash
echo "setting bmc for pxe boot..."
export ISHP="$(dmidecode -t System|grep Manufacturer|grep HP -c)"
export ISDELL="$(dmidecode -t System|grep Manufacturer|grep Dell -c)"
#Set BMC to PXE
if [ $ISHP -eq 1 ]; then
hpbootcfg -P
fi
if [ $ISDELL -eq 1 ]; then
ipmitool chassis bootparam set bootflag force_pxe
fi
#Reboot the system
echo "re-booting..."
/sbin/reboot

View File

@@ -0,0 +1,20 @@
#!/bin/bash
#A script to produce a current situation report for a server
echo -e "\e[1;34;47mSystem uptime/load:\e[0m" ; uptime;
echo -e "\e[1;34;47mSystem hostname and IP address:\e[0m"; hostname && hostname -i;
echo -e "\e[1;34;47mDisk usage:\e[0m"; df -i; df -h;
echo -e "\e[1;34;47mPHP process count:\e[0m" ;ps faux |grep php | wc -l;
echo -e "\e[1;34;47mMemory:\e[0m"; free -m; cat /proc/meminfo | egrep 'MemTotal|MemFree';
echo -e "\e[1;34;47mNumber of and model ofCPU:\e[0m"; cat /proc/cpuinfo | grep processor | wc -l; cat /proc/cpuinfo | grep "model name";
echo -e "\e[1;34;47mSoftware Versions:\e[0m"; php -v; mysql --version; httpd -v;
echo -e "\e[1;34;47mExim Message Count:\e[0m"; exim -bpc;
echo -e "\e[1;34;47mFTP Connection Count:\e[0m"; netstat -pan |grep :21|wc -l;
echo -e "\e[1;34;47mApache Connection Count:\e[0m";netstat -pan|grep :80|wc -l;
echo -e "\e[1;34;47mSSH Connection Count:\e[0m"; netstat -pan|grep :22|wc -l;
for i in $(ls /var/log/sa/sa[0-31]*);do echo "Average System load for $(date +%B) $i" ; sar -f $i -q|tail -n 1 ; done;for i in $(ls /var/log/sa/sa[0-31]*);do echo "Average System load for $(date +%B) $i" ; sar -f $i -r|tail -n 1 ; done;
if [ -e /proc/user_beancounters ]; then echo -e "\e[1;34;47mUser Beancounters:\e[0m" && cat /proc/user_beancounters | awk '{if ($NF>0){print$0}}';fi;
echo -e "\e[1;34;47mrunning processes:\e[0m" ; ps faux|egrep -v 'init|watchdog|iscsi|cqueue|kmpath|iscsid|syslogd|kpsmoused|auditd|irqbalance|rpc.idmapd|hcid|kmpathd|ib_cm|rpciod|migration|kjournald|scsi_eh_0|scsi_eh_1|khubd|kswapd0|kedac|kauditd|udevd|named|mingetty|agetty|dbus|kacpid|kblockd|pdflush|ksoftirqd|khelper|kthread|kseriod|klogd|acpid|spamd|cpsrvd|pure-authd|/usr/sbin/courierlogger|/usr/lib/courier-imap';blockcount=$(ip ro |grep blackhole | wc -l); if [ $blockcount -gt 0 ]; then echo -e "\e[1;34;47mBlocked IP Addresses:\e[0m"; ip ro |grep blackhole; fi

View File

@@ -0,0 +1,7 @@
apt-get -y --purge autoremove
apt-get update
apt-get -y upgrade
apt-get -y dist-upgrade
apt-get -y full-upgrade
apt-get -y --purge autoremove
apt-get clean