#!/bin/bash # AllYourBase.sh by Meryll Larkin 2/29/08 # 12/1/08 updated to have a dynamic servername $SERVERNAME # Script to take possession of server # This script customized for RHE3, RHE4, RHE5 with standard architecture # Parts of this script may need to be rewritten for different distros and architectures # To use this script, login to the server as root and run it there # Okay to run from the /root or /tmp directory. #SERVERNAME = $HOSTNAME SERVERNAME=`hostname -s` if [ "$SERVERNAME" = '' ] then echo "Quitting, SERVERNAME not set." echo "" exit fi export SERVERNAME echo "SERVERNAME = $SERVERNAME" echo "Taking possession of server $SERVERNAME" mkdir /tmp/$SERVERNAME cd /tmp/$SERVERNAME echo 'HOSTNAME='`hostname`>>/tmp/$SERVERNAME/Basics.txt echo 'IP ADDR='`ifconfig |grep "inet addr:6"`>>/tmp/$SERVERNAME/Basics.txt echo '' >>/tmp/$SERVERNAME/Basics.txt echo 'REBOOT NOTIFY='>>/tmp/$SERVERNAME/Basics.txt echo 'FUNCTIONS='>>/tmp/$SERVERNAME/Basics.txt echo "">>/tmp/$SERVERNAME/Basics.txt RH_VERSION=`cat /etc/redhat-release | tr -dc '[0-9.]'` export RH_VERSION echo "RH VERSION=$RH_VERSION">>/tmp/$SERVERNAME/Basics.txt # echo 'RH VERSION='`cat /etc/redhat-release`>>/tmp/$SERVERNAME/Basics.txt echo 'KERNEL RELEASE='`uname -r`>>/tmp/$SERVERNAME/Basics.txt echo 'LAST UPDATE='`ls -l /var/log/rpmpkgs` >>/tmp/$SERVERNAME/Basics.txt echo 'LAST REBOOT='`who -b` >>/tmp/$SERVERNAME/Basics.txt echo 'MEMORY TOTAL='`grep MemTotal /proc/meminfo`>>/tmp/$SERVERNAME/Basics.txt echo 'PROCESSORS='`grep processor /proc/cpuinfo | wc -l`>>/tmp/$SERVERNAME/Basics.txt echo 'PROC SPEED='`grep MHz /proc/cpuinfo`>>/tmp/$SERVERNAME/Basics.txt VERSION=`echo $RH_VERSION | cut -c -1` export VERSION if [ $VERSION -lt 5 ] then echo 'PACKAGE SKIP RHE3 RHE4='`grep pkgSkipList= /etc/sysconfig/rhn/up2date`>>/tmp/$SERVERNAME/Basics.txt echo "" elif [ "$VERSION" = '5' ] then echo 'PACKAGE EXCLUDE RHE5='`grep exclude= /etc/yum.conf`>>/tmp/$SERVERNAME/Basics.txt fi echo '' echo 'CUSTOM INSTALLS='`ls -l /usr/local/*` >>/tmp/$SERVERNAME/Basics.txt echo "Creating additional files of information" # services installed and when running chkconfig --list > /tmp/$SERVERNAME/chkconfig.txt cp /root/.bash_history /tmp/$SERVERNAME/root_history.txt cp /var/spool/mail/root /tmp/$SERVERNAME/root_email.txt cp /etc/fstab /tmp/$SERVERNAME/fstab.txt cp /etc/nsswitch.conf /tmp/$SERVERNAME/nsswitch.txt grep -R -v '^#' /var/spool/cron/ >/tmp/$SERVERNAME/Cronjobs.txt ls /home >/tmp/$SERVERNAME/Home.txt df -hl >/tmp/$SERVERNAME/df.txt tar -cvf $SERVERNAME.tar * echo "Done. Results in /tmp/$SERVERNAME" echo