12-06-2014, 09:42 AM
Latest code, some rewording, cosmetic changes:
Would like to see added the removal of any previous system reports in ~/ and ~/Desktop at the start of the script.
Code:
#!/bin/bash
# Linux Lite System Information Report Tool for Ubuntu based systems.
# Dependencies - lshw, dmidecode, hdparm
# Developer - Misko_2083, Jerry Bezencon, Sysdrum
# Creation Date - 30th November, 2013 Revision Date - 6th December 2014
# Website - http://www.freecinema2022.gq
DATE=$(date +"%A-%d-%B-%Y-%T")
rm -rf /tmp/systeminfo*
# Script start
if zenity --question --title="Create System Report" --text="System Report needs to collect information.\n\nClick Create Report to proceed or Cancel to exit." --ok-label="Create Report" --cancel-label="Cancel" --width=400; then
# Create file and insert date
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Report Date: "$(date +"%r, %d - %m - %Y") >> /tmp/systeminfo-"${DATE}".txt
now=$(date +"%r, %d - %m - %Y") >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
# Begin reporting information
(
echo "1"
echo "#This Report may take a while to generate..."
sleep 2
echo "5"
echo "#Collecting Bios & Motherboard Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Bios & Motherboard Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo " BIOS:" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
sudo dmidecode -t 0 >> /tmp/systeminfo-"${DATE}".txt
echo " MOTHERBOARD:" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
sudo dmidecode -t 2 >> /tmp/systeminfo-"${DATE}".txt
sudo dmidecode -t 3 >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "10"
echo "#Collecting CPU Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "CPU Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
grep "model name" /proc/cpuinfo >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
lscpu >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "17"
echo "#Collecting Memory Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Memory Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo " RAM SPEED:" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
sudo dmidecode --type 17 | grep -i speed >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo " PHYSICAL RAM DETAILS (one section per ram slot):" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
sudo dmidecode --type 17 >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "25"
echo "#Collecting Graphics Chip Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Graphics Chip Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
sudo lshw -C display >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "40"
echo "#Collecting Sound Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Sound Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
aplay --list-devices >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "45"
echo "#Collecting Hard Drive/SSD Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Hard Drive/SSD Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
df -T >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo " MOUNT:" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
mount >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo " FDISK:" >> /tmp/systeminfo-"${DATE}".txt
sudo fdisk -l /dev/sda >> /tmp/systeminfo-"${DATE}".txt
sudo fdisk -l /dev/sdb >> /tmp/systeminfo-"${DATE}".txt
sudo fdisk -l /dev/sdc >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo " HDPARM:" >> /tmp/systeminfo-"${DATE}".txt
sudo hdparm -i /dev/sda >> /tmp/systeminfo-"${DATE}".txt
sudo hdparm -i /dev/sdb >> /tmp/systeminfo-"${DATE}".txt
sudo hdparm -i /dev/sdc >> /tmp/systeminfo-"${DATE}".txt
echo "50"
echo "#Collecting Groups Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Groups Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
groups $USER >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "55"
echo "#Collecting PCI Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "PCI Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
lspci >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "60"
echo "#Collecting USB Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "USB Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
lsusb >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "65"
echo "#Collecting Kernel Modules Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Kernel Modules Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
lsmod >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "70"
echo "#Collecting Kernel & OS Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Kernel & Operating System Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
uname -a >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
lsb_release -d >> /tmp/systeminfo-"${DATE}".txt
lsb_release -i >> /tmp/systeminfo-"${DATE}".txt
lsb_release -c >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "Based on:" >> /tmp/systeminfo-"${DATE}".txt
cat /etc/issue.net >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "75"
echo "#Collecting Network Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Network Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
ifconfig >> /tmp/systeminfo-"${DATE}".txt
more /etc/network/interfaces >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
sudo lshw -C network >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "80"
echo "#Collecting Environment Variables..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Environment Variables Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
printenv >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "85"
echo "#Collecting Software Information..."
sleep 1
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "Software Installed Information" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
dpkg --list >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "End of Report" >> /tmp/systeminfo-"${DATE}".txt
echo "===========================================================" >> /tmp/systeminfo-"${DATE}".txt
echo "" >> /tmp/systeminfo-"${DATE}".txt
echo "#Done"
echo "100"
) | zenity --progress --auto-close --title="Collecting System Information" --no-cancel --width=325
else
exit
fi
# Prompt user to open report
if zenity --question --title="View System Report" --text="Create System Report has collected the required system data.\n\nClick View Report to see the report or Cancel to exit." --ok-label="View Report" --cancel-label="Cancel" --width=400; then
zenity --title="System Report" --text-info --width=800 --height=700 --ok-label="Save" --cancel-label="Quit" < /tmp/systeminfo-"${DATE}".txt
if [ $? -ne 0 ]; then
exit
else
#get normal users
# User id MIN and MAX: grep "^UID_MIN" /etc/login.defs; grep "^UID_MAX" /etc/login.defs
# Print users and groups: awk -F':' '$3>=1000 && $3<=60000 {print $1" "$3}' /etc/passwd
#Generate the save list and on the first occurance of "FALSE" change it to "TRUE"
LL_LIST_D=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1}' /etc/passwd |sed '0,/FALSE/s/FALSE/TRUE/'`)
#Add optional save location
LL_LIST_H=(`awk -F':' '$3>=1000 && $3<=60000 {print "FALSE","/home/"$1"/Desktop"}' /etc/passwd`)
save_location=$(zenity --title="Create System Report: Save Location" --list --radiolist --text="Select save location then click on <b>Ok:</b>" --column="Select" --column="Save file location" --width=350 --height 200 "${LL_LIST_D[@]}" "${LL_LIST_H[@]}")
if [ $? -ne 0 ]; then
exit
else
#Extract username
LL_USER=$(echo "$save_location" | cut -d'/' -f3)
# Add filename to the save path
SAVE_PATH=$(echo $save_location| sed 's,.*,&\/systeminfo-'"${DATE}"'.txt,g')
# copy the file from /tmp
cp /tmp/systeminfo-"${DATE}".txt $save_location
#Change owner of the file to LL_USER
sudo chown $LL_USER $SAVE_PATH
fi
fi
else
exit
fi
exit
Would like to see added the removal of any previous system reports in ~/ and ~/Desktop at the start of the script.