11-30-2014, 07:01 PM
This is what I've done so far.
Added: A question to start the process
Progress bar to display messages as the report continues
A question to display the results
Problem is next:
$HOME environment variable prints out /root when the script is run with 'gksudo'
If we have a script
and run it with gksudo we'll get
So it's saving the report in the '/root' directory
Solution:
Running the script with 'gksudo -k /usr/scripts/systeminfo'
From man gksu
--preserve-env, -k
Preserve the current environments, does not set $HOME nor $PATH,
for example.
Here is the full script:
Added: A question to start the process
Progress bar to display messages as the report continues
A question to display the results
Problem is next:
$HOME environment variable prints out /root when the script is run with 'gksudo'
If we have a script
Code:
#!/bin/bash
# This script is /usr/scripts/some_script
echo $HOME
Code:
$ gksudo /usr/scripts/some_script
/root
So it's saving the report in the '/root' directory
Solution:
Running the script with 'gksudo -k /usr/scripts/systeminfo'
From man gksu
--preserve-env, -k
Preserve the current environments, does not set $HOME nor $PATH,
for example.
Here is the full script:
Code:
#!/bin/bash
# Linux Lite System Information Report Tool for Ubuntu based systems
# Dependencies - lshw, dmidecode, hdparm
# Developer - Jerry Bezencon
# Creation Date - Monday 29th April, 2013
# Website - http://www.freecinema2022.gq
# Credits - Various people at the Linux Distro Community including but not limited to:
# Armageddon, pdq, pingcasts, preecher, setkeh, Shaggytwodope, Stripe, zoose
DATE=$(date +"%A-%d-%B-%Y-%T")
rm -rf $HOME/systeminfo*
# Script start
if zenity --title="Question" --question text="Click Yes to proceed, No to cancel"; then
# Create file and insert date
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Report Date: "$(date +"%r, %d - %m - %Y") >> $HOME/systeminfo-"${DATE}".txt
now=$(date +"%r, %d - %m - %Y") >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/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 "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Bios & Motherboard Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo " BIOS:" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
sudo dmidecode -t 0 >> $HOME/systeminfo-"${DATE}".txt
echo " MOTHERBOARD:" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
sudo dmidecode -t 2 >> $HOME/systeminfo-"${DATE}".txt
sudo dmidecode -t 3 >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "10"
echo "#CPU Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "CPU Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
grep "model name" /proc/cpuinfo >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
lscpu >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "17"
echo "#Collecting Memory Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Memory Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo " RAM SPEED:" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
sudo dmidecode --type 17 | grep -i speed >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo " PHYSICAL RAM DETAILS (one section per ram slot):" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
sudo dmidecode --type 17 >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "25"
echo "#Collecting Graphics Chip Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Graphics Chip Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
sudo lshw -C display >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "40"
echo "#Collecting Sound Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Sound Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
aplay --list-devices >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "45"
echo "#Collecting Hard Drive/SSD Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Hard Drive/SSD Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
df -T >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo " MOUNT:" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
mount >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo " FDISK:" >> $HOME/systeminfo-"${DATE}".txt
sudo fdisk -l /dev/sda >> $HOME/systeminfo-"${DATE}".txt
sudo fdisk -l /dev/sdb >> $HOME/systeminfo-"${DATE}".txt
sudo fdisk -l /dev/sdc >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo " HDPARM:" >> $HOME/systeminfo-"${DATE}".txt
sudo hdparm -i /dev/sda >> $HOME/systeminfo-"${DATE}".txt
sudo hdparm -i /dev/sdb >> $HOME/systeminfo-"${DATE}".txt
sudo hdparm -i /dev/sdc >> $HOME/systeminfo-"${DATE}".txt
echo "50"
echo "#Collecting Groups Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Groups Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
groups $USER >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "55"
echo "#Collecting PCI Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "PCI Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
lspci >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "60"
echo "#Collecting USB Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "USB Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
lsusb >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "65"
echo "#Collecting Kernel Modules Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Kernel Modules Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
lsmod >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "70"
echo "#Collecting Kernel & OS Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Kernel & Operating System Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
uname -a >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
lsb_release -d >> $HOME/systeminfo-"${DATE}".txt
lsb_release -i >> $HOME/systeminfo-"${DATE}".txt
lsb_release -c >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "Based on:" >> $HOME/systeminfo-"${DATE}".txt
cat /etc/issue.net >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "75"
echo "#Collecting Network Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Network Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
ifconfig >> $HOME/systeminfo-"${DATE}".txt
more /etc/network/interfaces >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
sudo lshw -C network >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "80"
echo "#Collecting Environment Variables"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Environment Variables Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
printenv >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "85"
echo "#Collecting Software Information"
sleep 1
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "Software Installed Information" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
dpkg --list >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "End of Report" >> $HOME/systeminfo-"${DATE}".txt
echo "===========================================================" >> $HOME/systeminfo-"${DATE}".txt
echo "" >> $HOME/systeminfo-"${DATE}".txt
echo "#Done"
echo "100"
) | zenity --progress --auto-close --title="system report" --no-cancel
else
exit
fi
# Prompt user to open report
if zenity --title="Question" --question text="Would you like to open the report now?" ; then
xdg-open $HOME/systeminfo-"${DATE}".txt
else
exit 1
fi
exit