#!/bin/bash # all_your_base_ubuntu.sh by Meryll Larkin 7/31/14 # Aug 8, 2014 updated to have nicer formatting on CUSTOM INSTALLS # and to include total hard drive space in Basics.txt # 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` echo 'IP ADDR='`ifconfig |grep "inet addr:" |grep -v '127.0.0'` echo '' echo 'REBOOT NOTIFY=' echo 'FUNCTIONS=' echo "" OS_VERSION=`cat /etc/*release |grep DISTRIB_DESC | awk -F'=' '{print $2 }' |sed 's/"//g'` echo "OS VERSION=$OS_VERSION" echo "ARCH=`uname -p`" echo 'KERNEL RELEASE='`uname -r` echo 'LAST UPDATE='`stat -c %y /var/lib/apt/periodic/update-success-stamp |awk '{ print $1 }'` echo 'LAST REBOOT='`who -b` echo 'MEMORY TOTAL='`grep MemTotal /proc/meminfo` echo 'PROCESSORS='`grep processor /proc/cpuinfo | wc -l` echo 'PROC SPEED='`grep MHz /proc/cpuinfo` echo -n 'TOTAL HD SPACE=' echo `df -h --total |tail -n 1 | awk '{ print "Used:",$3," Remaining:",$4," Total:",$2 }'` echo '' } >>/tmp/$SERVERNAME/Basics.txt echo "UNATTENDED UPGRADES\n /etc/apt/apt.conf.d/50unattended-upgrades" >>/tmp/$SERVERNAME/Basics.txt `cat /etc/apt/apt.conf.d/50unattended-upgrades |grep -v '//'| grep -v '^$'` >>/tmp/$SERVERNAME/Basics.txt echo '' >>/tmp/$SERVERNAME/Basics.txt echo 'CUSTOM INSTALLS=/usr/local' >>/tmp/$SERVERNAME/Basics.txt cd /usr/local for i in `ls *` do if [[ $i == *: ]]; then if [ "$nline" == "no" ]; then echo '' >>/tmp/$SERVERNAME/Basics.txt fi echo $i >>/tmp/$SERVERNAME/Basics.txt nline=yes else echo -n " $i " >>/tmp/$SERVERNAME/Basics.txt nline=no fi done echo '' >>/tmp/$SERVERNAME/Basics.txt echo 'CUSTOM INSTALLS=/opt' >>/tmp/$SERVERNAME/Basics.txt cd /opt for i in `ls *` do if [[ $i == *: ]]; then if [ "$nline" == "no" ]; then echo '' >>/tmp/$SERVERNAME/Basics.txt fi echo $i >>/tmp/$SERVERNAME/Basics.txt nline=yes else echo -n " $i " >>/tmp/$SERVERNAME/Basics.txt nline=no fi done echo '' >>/tmp/$SERVERNAME/Basics.txt cd /tmp/$SERVERNAME echo "Creating additional files of information" # services installed and when running /usr/bin/dpkg --get-selections | grep -v deinstall > /tmp/$SERVERNAME/installed_dpkg.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