#!/bin/sh # This script was written by Makarand Hazarika. # This is the script is the result of joint effort of Makarand Hazarika # and Siddhartha Sarkar. Both of them are students of NIT Durgapur, India. # Copyright (C) 2006 Makarand Hazarika # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # You can contact the author at # THIS IS A INTERACTIVE PROGRAM TO DISPLAY YOUR SYSTEM INFORMATION. # TYPE ./sysinfo --help FOR OPTIONS # THE WHOLE SCRIPT CAN BE BROADLY DIVIDED INTO 3 MODULES - ################################################################################################################### # MODULE 1:- # # THIS IS RESPONSIBLE FOR CLEAN UP JOBS AND ALSO PERFORMS EXCEPTION HANDLING. # ################################################################################################################### # CLEANUP CLEANS THE TEMPORARY FILE(S) CREATED cleanup(){ rm -f "$TEMP" 2>> "$TMPLOG" rm -f "$CHOICE" 2>> "$TMPLOG" if [ `cat "$TMPLOG" | wc -l` -gt 0 ] then printerr 4 1 else rm -f "$TMPLOG" fi if [ -d "$SYSINFODIR" ] && [ `ls -al "$SYSINFODIR" | wc -l` -le 4 ] then rm -fr "$SYSINFODIR" fi } # QUIT FUNCTION IS CALLED IF THE SCRIPT IS KILLED PREMATURELY DURING EXECUTION IT SIMPLY PERFORMS CLEANUP quit(){ cleanup if [ -z $@ ] then clear fi exit 2 } # INIT INITITALIZES THE VARIABLE AND THE ENVIRONMENT init(){ script_name="$0" VERSION=2.3 OLD_PATH=`echo $PATH` PATH=$PATH:/sbin:/usr/sbin SYSINFODIR="$HOME/S&M-Sysinfo" TEMP="${SYSINFODIR}/sysinfo.tmp" ERRLOG="${SYSINFODIR}/sysinfo_err.log" TMPLOG="${SYSINFODIR}/sysinfo.log" CHOICE="${SYSINFODIR}/sysinfo_choice.tmp" DATE=`date '+%Y.%m.%d'` SAVEINFO="${SYSINFODIR}/sysinfo.out.${DATE}" ERRORSTRING="NULL" TRIVIALCODE="1" TITLE="" if [ -z "$*" ] then if [ -f "$SYSINFODIR" ] then cat "$SYSINFODIR" >> "${SYSINFODIR}.old" rm -f "$SYSINFODIR" 2> /dev/null fi if [ -d "$SYSINFODIR" ] then echo > /dev/null else mkdir "$SYSINFODIR" echo -e "This folder $SYSINFODIR was created by the program $0\n\n" >> "${SYSINFODIR}/README" echo -e 'S&M Sysinfo, Sysinfo by Manna & Sid!!' >> "${SYSINFODIR}/README" echo -e "sysinfo Version $VERSION" >> "${SYSINFODIR}/README" echo -e "Author -- Makarand Hazarika, Siddhartha Sarkar" >> "${SYSINFODIR}/README" echo -e "Copyright (C) 2006 Makarand Hazarika" >> "${SYSINFODIR}/README" echo -e "This is free software distributed under the terms of GPL\n\n\n\n\n" >> "${SYSINFODIR}/README" fi if [ -f "$TMPLOG" ] then cat "$TMPLOG" >> "${TMPLOG}.old" rm -f "$TMPLOG" fi if [ -f "$TEMP" ] || [ -f "$CHOICE" ] then rm -f "$TEMP" fi if [ -f "$CHOICE" ] then rm -f "$CHOICE" fi echo -e "\nInitializing Graphical Mode... Successful\n\nPress OK to continue.\n(Press 'Esc' and click 'OK' to enter text mode)" > $TEMP dialog --title "GUI TEST" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 2> /dev/null if [ "$?" -eq 0 ] then gui_support=y else gui_support=n clear echo -e "\nInitializing Graphical Mode... Failed!!\nThis can even happen if you press Esc during initialization of graphical mode.\nThe program will run in text mode\n\n" echo "Press Enter to continue...." read fi fi } # PRINTERR IS FOR TAKING THE NECESSARY ACTION IF AN ERROR OCCURS. IT PRINTS AN ERROR MESSAGE DEPENDING ON # THE FIRST ARGUMENT AND THEN EITHER EXITS AFTER GENERATING A BUG REPORT AFTER GETTING PERMISSION FROM THE # USER RUNNING THE SCRIPT WITHIN THE USER'S HOME DIRECTORY UNDER THE NAME "bug_report_sysinfo" OR SIMPLY # RETURNS TO THE POINT WHERE THE EXCEPTION OCCURED DEPENDING UPON THE SECOND ARGUMENT. printerr(){ case "$1" in "1") if [ "$gui_support" = 'y' ] then dialog --colors --title "\Z1$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\n\Z1Sorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nIt seems that the proc filesystem is not enabled in the kernel - Run script after enabling it.If it is enabled then it may not be mounted - Run script after mounting it. If it is mounted then you do not have enough permissions to retrieve information from it - Run the script as root." 19 72 else echo -e "\nSorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nIt seems that the proc filesystem is not enabled in the kernel - Run script after enabling it.If it is enabled then it may not be mounted - Run script after mounting it. If it is mounted then you do not have enough permissions to retrieve information from it - Run the script as root." echo -e "\nPress Enter to continue..." read fi ;; "2") if [ "$gui_support" = 'y' ] then dialog --colors --title "\Z1$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --colors --msgbox "\n\Z1Sorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nEither your system does not support showing the details you are looking for or you do not have enough permissions to do that. If you are not root try runnig the script with root priviledge." 19 72 else echo -e "\nSorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nEither your system does not support showing the details you are looking for or you do not have enough permissions to do that. If you are not root try runnig the script with root priviledge." echo -e "\nPress Enter to continue..." read fi ;; "3") if [ "$gui_support" = 'y' ] then dialog --colors --title "\Z1$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --colors --msgbox "\Z1Sorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nIt seems you do not have enough permissions. Try runnig the script with root priviledge." 19 72 else echo -e "Sorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nIt seems you do not have enough permissions. Try runnig the script with root priviledge." echo -e "\nPress Enter to continue..." read fi ;; "4") echo -e "\n\n------------------------------------------------------------" >> "$TMPLOG" echo -e "Above Error Report Genenrated on:- " >> "$TMPLOG" date >> "$TMPLOG" echo -e "********************\n\n\n\n" >> "$TMPLOG" if [ "$gui_support" = 'y' ] then dialog --colors --title "\Z1ERROR" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\Z1A log file -- $TMPLOG was created. This happened because I faced some problem during my execution. If you suspect a bug, report it to the author at sending him the log file alongwith." 19 72 else echo -e "A log file -- $TMPLOG was created. This happened because I faced some problem during my execution. If you suspect a bug, report it to the author at sending him the log file alongwith." echo -e "\nPress Enter to continue..." read fi ;; "5") if [ "$gui_support" = 'y' ] then dialog --colors --title "\Z1$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --colors --msgbox "\n\Z1Sorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nYour system does not support showing the details you are looking for." 19 72 else echo -e "\nSorry, I was unable to retrieve the required information from your system.\nPOSSIBLE CAUSE OF ERROR AND SOLUTION :-\nYour system does not support showing the details you are looking for." echo -e "\nPress Enter to continue..." read fi ;; *) if [ "$gui_support" = 'y' ] then dialog --colors --title "\Z1ERROR" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\n\n\Z1It seems someone has modified this script. Please do not report bug to author. Instead try and contact the person/media/website/agency from where you got this script." 19 72 else echo -e "\n\nIt seems someone has modified this script. Please do not report bug to author. Instead try and contact the person/media/website/agency from where you got this script." echo -e "\nPress Enter to continue..." read fi ;; esac if [ "$2" = "0" ] && [ "$ERRORSTRING" != "NULL" ] then if [ "$gui_support" = "y" ] then dialog --colors --title "\Z1BUG REPORT GENERATOR" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --yesno "\Z1If the mentioned steps did not solve your problem then report a bug to the author. Send the bug report that is automatically generated by this script along with your system information. However do not care to report a bug if:- \nyou do not want this script to generate the bug report. Or you are running this script in a non Linux operating system. This script is written for Linux only.\nReport bugs to the author at makarand.hazarika@gmail.com\n\nA bug report will be generated -- $ERRLOG. If it already exists, it will won't get overwritten, it will be appended \nMake sure you have write permission in your home directory before pressing yes\nShould this script generate a bug report? " 19 72 if [ "$?" = "0" ] then create_bug_report=y fi else echo -e "If the mentioned steps did not solve your problem then report a bug to the author. Send the bug report that is automatically generated by this script along with your system information. However do not care to report a bug if:- \nyou do not want this script to generate the bug report. Or you are running this script in a non Linux operating system. This script is written for Linux only.\nReport bugs to the author at makarand.hazarika@gmail.com\n\nA bug report will be generated -- $ERRLOG. If it already exists, it will won't get overwritten, it will be appended \nMake sure you have write permission in your home directory before typing \'y\'\nShould this script generate a bug report? (y/n) ..." read create_bug_report fi if [ "$create_bug_report" = 'y' ] then if [ "$gui_support" = "y" ] then dialog --colors --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "\Z1Generating Bug Report.\nPlease wait...\n(This may take a long time)" 9 45 else echo -e "\n\nGenerating Bug Report.(This may take a long time)\nPlease Wait..." fi echo -e "\n\n------------------------------------------------------------\n" >> $ERRLOG echo -ne "\nError Report Generated on:- " >> $ERRLOG date >> $ERRLOG echo -e "\n\nScript Output:-\n\n" >> $ERRLOG $script_name -a >> $ERRLOG 2>> $ERRLOG echo -e "\n\n------------------------------------------------------------\n\n" >> $ERRLOG echo "Error_code: $1" >> $ERRLOG bug_report_gen=$? if [ "$bug_report_gen" != "0" ] && [ "$gui_support" = "y" ] then dialog --title "ERROR" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nI faced some problem. Bug report was not generated.\n" 15 65 return fi if [ "$bug_report_gen" != "0" ] && [ "$gui_support" = "y" ] then echo -e "\nI faced some problem. Bug report was not generated.\n" echo -e "Press Enter to continue..." read return fi case "$3" in "proc") echo -e "\nRoot Directory:\n " >> $ERRLOG ls -l / >> $ERRLOG 2>> $ERRLOG echo -e "\nProc Directory:\n " >> $ERRLOG ls /proc -lR >> $ERRLOG 2>> $ERRLOG echo -e "\n" >> $ERRLOG ;; "passwd") echo -e "\netc Directory:\n" >> $ERRLOG ls -lR /etc/ >> $ERRLOG 2>> $ERRLOG echo -e "\n\npasswd:\n" >> $ERRLOG cat /etc/passwd >> $ERRLOG 2>> $ERRLOG echo -e "\n" >> $ERRLOG ;; "group") echo -e "\netc Directory:\n" >> $ERRLOG ls -lR /etc/ >> $ERRLOG 2>> $ERRLOG echo -e "\n\ngroup:\n" >> $ERRLOG cat /etc/group >> $ERRLOG 2>> $ERRLOG echo -e "\n" >> $ERRLOG ;; *) echo -e "\n Trying to execute -- $3 \n" >> $ERRLOG $3 >> $ERRLOG 2>> $ERRLOG echo -e "\n" >> $ERRLOG ;; esac if [ "$bug_report_gen" = "0" ] && [ "$gui_support" = "y" ] then dialog --title "BUG REPORT GENERATOR" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nBug report generated: $ERRLOG\n" 15 65 return else echo -e "\nBug report generated: $ERRLOG\n" echo -e "\nPress Enter to continue..." read fi return fi if [ "$create_bug_report" != "y" ] && [ "$gui_support" = "y" ] then dialog --title "BUG REPORT GENERATOR" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nBug report was not generated\nAborted by user.\n" 15 65 return else echo -e "\nBug report was not generated\nAborted by user.\n" echo -e "\nPress Enter to continue..." read fi fi } #FOR SAVING TO DISK save(){ echo -e "---------------------------------------------------------------------------" >> "$SAVEINFO" echo -ne " Following information saved on : " >> "$SAVEINFO" date >> "$SAVEINFO" echo -e "---------------------------------------------------------------------------\n" >> "$SAVEINFO" cat "$TEMP" >> "$SAVEINFO" echo -e "############################################################################\n\n" >> "$SAVEINFO" } #THIS SHOWS THE EXIT MESSAGE. exit_msg(){ if [ "$gui_support" = 'y' ] then dialog --clear --title "THANK YOU FOR USING THIS PROGRAM" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nsysinfo Version $VERSION\nCopyright (C) 2006 Makarand Hazarika\nThis is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\nAuthors:-\nMakarand Hazarika \nSiddhartha Sarkar " 15 62 else clear echo -e "\n\n\t\t THANK YOU FOR USING THIS PROGRAM\n\n" echo -e "\nsysinfo Version $VERSION\nCopyright (C) 2006 Makarand Hazarika\nThis is free software; see the source for copying conditions.\nThere is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE\n\nAuthors:-\nMakarand Hazarika \nSiddhartha Sarkar " echo -e "\nPress Enter to exit...." read fi } # END OF MODULE 1 #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX# #################################################################################################################### # MODULE 2:- # #IT IS THIS PART WHICH IS ACTUALLY RESPONSIBLE FOR DISPLAYING ALL THE INFORMATION. # #################################################################################################################### #***********************************************# # SUBMODULE A:- # # THIS SUBMODULE DISPLAYS THE USER INFORMATION. # #***********************************************# # THIS IS FOR PRINTING THE LIST OF ALL THE USERS IN THE HOST MACHINE usertot(){ if [ ! -r /etc/passwd ] then echo -e "ERROR : username of all the users is not available" TITLE='ERROR - USERNAME NOT RETRIEVABLE' TRIVIALCODE=0 ERRORSTRING="passwd" return 3 fi TITLE="USER INFORMATION" if [ `awk -F: '{ if( $3 >= 500 && $3 <= 9999 ) printf "%s\n", $1 ; }' /etc/passwd | wc -l` -eq 0 ] then echo -e "\n\nNO ORDINARY USERS FOUND!!" return fi echo " ****************************************" echo -e " ==::List of Users in The Local Host::==" echo " ****************************************" echo -e "*********************************************************************" echo -e "\n Username Full Name Home Login Shell" echo -e "*********************************************************************" awk -F: '{ if( $3 >= 500 && $3 <= 9999 ) printf " %-10s %-18s %-16s %-9s \n", $1, $5, $6, $7 }' /etc/passwd echo "*********************************************************************" echo -e "\n" return 0 } # THIS PRINTS OUT INFORMATION OF ALL THE USERS LOGGED IN THE HOST MACHINE userlog(){ type who > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : User information is not available.\nSomething is terribly wrong with your system." TITLE='ERROR - USER INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="who" return 5 else who > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : User information is not available.\nSomething is terribly wrong with your system." TITLE='ERROR - CONFIGURATION INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="who" return 2 fi fi TITLE="USERS LOGGED IN" echo -e " *****************************************" echo -e " ==::List of Users Currently Logged in::==" echo -e " *****************************************" echo " ***************************************************" echo ' USERNAME TERMINAL TIME LOGGED IN' echo " ***************************************************" who | awk '{ printf " %-18s %-9s %s\n", $1, $2, $5 ; }' echo -e " ***************************************************\n" whoami | awk '{ printf " Your Username is : %s\n", $1 ; }' who am i | awk '{printf " You are Working in Terminal : %s \n\n\n", $2 ; }' return 0 } # THIS PRINTS OUT THE DETAIL OF THE USER INTERACTIVELY userdetail(){ TITLE="DETAIL OF USER $1" username="$@" finger -p "$username" > "$TEMP" 2> /dev/null grep Login "$TEMP" > /dev/null 2>&1 if [ $? -eq 0 ] then strln=`echo -e "\nDetails of User $username:-" |wc -m` echo -e "\nDetails of User $username:-" > "$TEMP" while [ "$strln" != "2" ] do echo -n "*" strln=`expr $strln - 1` done >> "$TEMP" echo -e "\n" >> "$TEMP" finger -p "$username" >> "$TEMP" echo >> "$TEMP" return 0 else echo -e "\n\n\n\t\tUser $username could not be found!!" >> "$TEMP" echo -e "\n\n\t\tPlease Enter a valid username." >> "$TEMP" return 1 fi return 0 } groupinfo(){ if [ ! -r /etc/group ] then echo -e "ERROR : groupname not available" TITLE='ERROR - GROUP INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="group" return 3 fi TITLE="GROUP INFORMATION" echo -e " **************************" echo -e " ==::GROUPS INFORMATION::==" echo -e " **************************\n" echo -e " *******************************" echo -e " GROUPS GROUP ID" echo -e " *******************************" cat /etc/group | awk -F: '{ printf " %-15s %7s\n", $1, $3 }' echo -e " *******************************" echo -e "\n" return 0 } #*************************************************# # SUBMODULE B:- # # THIS SUBMODULE DISPLAYS THE SYSTEM INFORMATION. # #*************************************************# # THIS FUNCTION DISPLAYS HARDWARE INFORMATION LIKE CPU INFO AND MEMORY INFO. hwdinfo(){ if [ ! -r /proc/cpuinfo ] && [ ! -r /proc/meminfo ] then echo -e "ERROR : Hardware information is not available. Maybe some problem with proc." TRIVIALCODE=0 ERRORSTRING="proc" TITLE='ERROR - HARDWARE INFORMATION NOT AVAILABLE' return 1 fi TITLE="BASIC HARDWARE INFORMATION" echo -e "**********************************" echo -e "==::BASIC HARDWARE INFORMATION::==" echo -e "**********************************" echo -e "\nCPU INFORMATION:-" echo -e "*****************" cpu_count=`cat /proc/cpuinfo | grep processor | wc -l` count=1 while [ $count -le $cpu_count ] do cat /proc/cpuinfo | sed -n -e '/processor/p' | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/vendor/p' | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/model/p' | head -n $count | tail -n 1 echo -n "cpu MHz :" | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/cpu/p' | sed -n '/Hz/p' | awk -F : '{ printf "%s\n", $2 ; }' | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/cpu family/p' | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/cache/p' | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/step/p' | head -n $count | tail -n 1 cat /proc/cpuinfo | sed -n -e '/flags/p' | head -n $count | tail -n 1 echo -en "cpu architecture: " uname -m echo count=`expr $count + 1` done echo -e "MEMORY:-" echo -e "********" echo -en "Total System Memory :" cat /proc/meminfo | sed -n -e '/MemTotal/p' | awk '{ printf "%s %s\n", $2, $3 ; }' echo -en "Total Swap Memory :" cat /proc/meminfo | sed -n -e '/SwapTotal/p' | awk '{ printf "%s %s\n", $2, $3 ; }' if [ "`cat /etc/X11/* 2> /dev/null | grep -A 3 [mM]onitor | wc -l`" != "0" ] then echo -e "\nMONITOR INFORMATION:-" echo -e "*********************" for fileX11 in /etc/X11/* do if [ ! -L $fileX11 ] && [ -f $fileX11 ] then cat $fileX11 fi done 2> /dev/null | grep -A 5 [mM]onitor | sed '/[sS]ection/d' | grep [I]dentif | tail -n 1 for fileX11 in /etc/X11/* do if [ ! -L $fileX11 ] && [ -f $fileX11 ] then cat $fileX11 fi done 2> /dev/null | grep -A 5 [mM]onitor | sed '/[sS]ection/d' | grep [mM]odel | tail -n 1 for fileX11 in /etc/X11/* do if [ ! -L $fileX11 ] && [ -f $fileX11 ] then cat $fileX11 fi done 2> /dev/null | grep -A 5 [mM]onitor | sed '/[sS]ection/d' | grep [Vv]endor | sed '/Monitor Vendor/d' | tail -n 1 fi echo -e "\nIDE Drives:-" echo -e "************" if [ "`dmesg 2> /dev/null | sed -n -e '/[hs]d[a-z]:/p' | sed -n -e '/drive/p' | sed -e '/[cC]ache/d' -e '/driver/d' -e '/[Ee]rror/d' | wc -l`" != "0" ] then dmesg | sed -n -e '/[hs]d[a-z]:/p' | sed -n -e '/drive/p' | sed -e '/[cC]ache/d' -e '/driver/d' -e '/[Ee]rror/d' else if [ "`cat /var/log/dmesg 2> /dev/null | sed -n -e '/[hs]d[a-z]:/p' | sed -n -e '/drive/p' | sed -e '/[cC]ache/d' -e '/driver/d' -e '/[Ee]rror/d' -e '/disk/d' | wc -l`" != "0" ] then cat /var/log/dmesg | sed -n -e '/[hs]d[a-z]:/p' | sed -n -e '/drive/p' | sed -e '/[cC]ache/d' -e '/driver/d' -e '/[Ee]rror/d' -e '/disk/d' else cat /proc/ide/hd[a-z]/model fi fi if [ "`cat /proc/scsi/scsi 2>> /dev/null | grep -A 1 '[vV]endor'| wc -l`" != "0" ] then echo -e "\nSCSI Devices:-" echo -e "**************" cat /proc/scsi/scsi | grep -A 1 '[vV]endor' fi echo -e "\n" return 0 } # THIS ONE PRINTS THE BASIC CONFIGURATION INFO. LIKE OS, KERNEL VERSION ETC. configinfo(){ type uname > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Configuration information is not available." TITLE='ERROR - CONFIGURATION INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="uname" return 5 else uname > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Configuration information is not available." TITLE='ERROR - CONFIGURATION INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="uname" return 3 fi fi TITLE="CONFIGURATION INFORMATION" echo -e " ***********************************************" echo -e " ==::BASIC SYSTEM CONFIGURATION INFORMATION::== " echo -e " ***********************************************" echo -en " System OS : " uname -s echo -en " Release : " for i in /etc/*[rv]e[lr][es][ai][so][en] do if [ -L "$i" ] then echo > /dev/null else cat "$i" fi done 2> /dev/null | sed '/LSB/d' | head -n 1 echo -en " Kernel Version : " uname -r echo -en " Hostname : " uname -n grep ':initdefault' /etc/inittab 1> /dev/null if [ "$?" -eq 0 ] then echo -en " Default Runlevel : " grep ':initdefault' /etc/inittab | sed 's/:/ /g' | awk '{ printf "%s\n", $2 ; }' fi runlevel > /dev/null 2>> /dev/null if [ "$?" -eq 0 ] then echo -en " Current Runlevel : " runlevel | awk '{ printf "%s\n", $2 ; }' echo -en " Previous Runlevel : " runlevel | awk '{ printf "%s\n", $1 ; }' fi gcc -v 1> /dev/null 2>&1 if [ "$?" = "0" ] && [ `gcc --version | grep 'gcc' | awk '{ printf "%s\n", $3 ; }' | wc -l` -eq 1 ] then echo -ne " GCC Version : " gcc --version | grep 'gcc' | awk '{ printf "%s\n", $3 ; }' else echo -e " GCC : Not Installed" fi echo -n " Boot Loader(s) Installed : " if [ -f /boot/grub/menu.lst ] || [ -f /etc/lilo.conf ] then if [ -f /boot/grub/menu.lst ] then echo -n "GRUB" fi if [ -f /boot/grub/menu.lst ] && [ -f /etc/lilo.conf ] then echo -n ", " fi if [ -f /etc/lilo.conf ] then echo -n "LILO" fi else echo -n "Could not determine" fi echo -e "\n\n" return 0 } # THIS ONE PRINTS THE DISKDRIVE INFORMATION LIKE LISTING OUT PARTITIONS AND FILESYSTEM. hddinfo(){ if [ ! -r /proc/partitions ] then echo -e "ERROR : Disk drive information is not available. Maybe some problem with proc." TITLE='ERROR - DISK DRIVE INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="proc" return 1 fi TITLE="DISK DRIVE INFORMATION" echo -e "******************************" echo -e "==::DISK DRIVE INFORMATION::==" echo -e "******************************" if [ "`cat /proc/partitions 2> /dev/null | wc -l`" != "0" ] then echo -e "\nList of Partitions (includes even unmounted partitions, if any) :-" echo -e "******************************************************************" cat /proc/partitions | grep [a-z]d[a-z][1-9][0-9]* | awk '{ printf "%s\n", $4 }' echo -e "******************************************************************\n" fi echo -e "Mounted Filesystems :-" echo -e "**********************" mount > /dev/null 2>&1 if [ "$?" != 0 ] then echo -e "\nINFORMATION NOT AVAILABLE!!\n" else echo -e "********************************************************************************" printf "%-15s %-20s %-15s %-5s\n" "PARTITION" "MOUNTED ON" "FILESYSTEM" "REMARK" echo -e "********************************************************************************" mount | sed -n '/dev/p' | sed -e '/proc/d' -e '/none/d' -e '/shm/d' -e '/pts/d' | awk '{ printf "%-15s %-20s %-15s %-5s\n", $1,$3,$5,$6 ; } ' echo -e "********************************************************************************\n" fi echo -e "Disk Drive Usage :-" echo -e "******************" df > /dev/null 2>&1 if [ "$?" != 0 ] then echo -e "\nINFORMATION NOT AVAILABLE!!\n" else echo -e "**********************************************************************" printf "%-12s %-20s %5s %5s %5s %5s\n" "PARTITION" "MOUNTED ON" "SIZE" "USED" "AVAIL" "%USED" echo -e "**********************************************************************" df -h | sed -n '/dev/p' | sed -e '/none/d' -e '/shm/d' -e '/pts/d' | awk '{ printf "%-12s %-20s %5s %5s %5s %5s\n",$1,$6,$2,$3,$4,$5 ; }' echo -e "**********************************************************************\n\n" fi return 0 } # THIS LISTS OUT THE PCI DEVICES, CONTROLLERS AND BRIDGES ETC. pciinfo(){ type lspci > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : PCI information is not available." TITLE='ERROR - PCI INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING='find / | grep lspci' return 5 else lspci > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : PCI information is not available." TITLE='ERROR - PCI INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING='lspci' return 3 fi fi TITLE="PCI INFORMATION" echo -e "*******************************" echo -e "==::PCI Buses and Devices ::==" echo -e "*******************************" echo -e "\nGraphics Card :-" echo "****************" lspci | grep VGA | awk -F: '{ print $3 $4 }' echo -e "\nSound Card :-" echo "*************" lspci | grep '[sS]ound' | awk -F: '{ print $3 $4 }' lspci | grep '[aA][uU][dD][iI][oO]' | awk -F: '{ print $3 $4 }' if [ "`lspci | grep 'USB' | awk -F: '{ print $3 $4 }'| wc -l`" != "0" ] then echo -e "\nUSB Controller :-" echo "*****************" lspci | grep 'USB' | awk -F: '{ print $3 $4 }' fi if [ "`lspci | grep 'IDE' | awk -F: '{ print $3 $4 }'| wc -l`" != "0" ] then echo -e "\nIDE Controller :-" echo "*****************" lspci | grep 'IDE' | awk -F: '{ print $3 $4 }' fi if [ "`lspci | grep 'FireWire' | awk -F: '{ print $3 $4 }'| wc -l`" != "0" ] then echo -e "\nFireWire Controller :-" echo "**********************" lspci | grep 'FireWire' | awk -F: '{ print $3 $4 }' fi if [ "`lspci | grep 'I/O' | awk -F: '{ print $3 $4 }'| wc -l`" != "0" ] then echo -e "\nI/O Controller :-" echo "*****************" lspci | grep 'I/O' | awk -F: '{ print $3 $4 }' fi echo -e "\nOther PCI Controller/Bridge/Device :-" echo "*************************************" lspci | sed -e '/[sS]ound/d' -e '/I\/O/d' -e '/VGA/d' -e '/[aA][uU][dD][iI][oO]/d' -e '/USB/d' -e '/IDE/d' -e '/FireWire/d' | awk -F: '{ print $3 $4 }' echo -e "\n" return 0 } # AND THIS ONE PRINTS OUT THE MEMORY INFORMATION meminfo(){ if [ ! -r /proc/meminfo ] then echo -e "ERROR : Memory information is not available. Maybe some problem with proc." TITLE='ERROR - MEMORY INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="proc" return 1 fi TITLE="MEMORY INFORMATION" echo -e " ***************************" echo -e " ==::System Memory Usage::==" echo -e " ***************************" echo -en "\n Total System Memory : " cat /proc/meminfo | sed -n -e '/MemTotal:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Total Swap Memory : " cat /proc/meminfo | sed -n -e '/SwapTotal:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Free System Memory : " cat /proc/meminfo | sed -n -e '/MemFree:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Free Swap Memory : " cat /proc/meminfo | sed -n -e '/SwapFree:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Cached Memory : " cat /proc/meminfo | sed -n -e '/Cached:/p' | sed -e '/[sS]wap[cC]ached:/d'| awk '{ printf "%7s %s", $2, $3 }' echo -en "\n Cached Swap Memory : " cat /proc/meminfo | sed -n -e '/SwapCached:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Active : " cat /proc/meminfo | sed -n -e '/Active:/p' | sed -e '/Inactive:/d' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Inactive : " cat /proc/meminfo | sed -n -e '/Inactive:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n High Total : " cat /proc/meminfo | sed -n -e '/HighTotal:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n High Free : " cat /proc/meminfo | sed -n -e '/HighFree:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Low Total : " cat /proc/meminfo | sed -n -e '/LowTotal:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Low Free : " cat /proc/meminfo | sed -n -e '/LowFree:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Dirty : " cat /proc/meminfo | sed -n -e '/Dirty:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Write Back : " cat /proc/meminfo | sed -n -e '/Writeback:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Mapped : " cat /proc/meminfo | sed -n -e '/Mapped:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Page Tables : " cat /proc/meminfo | sed -n -e '/PageTables:/p' | awk '{ printf "%7s %s", $2, $3 ; }' echo -en "\n Swap Partition : " cat /proc/swaps | sed -n -e '/dev/p' | awk '{ printf " %s ", $1 }' echo -e "\n\n" return 0 } # TO VIEW ALL THE RUNNING PROCESSES IN THE HOST MACHINE, THIS FUNCTION IS USED procinfo(){ type ps > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Processes information is not available." TITLE='ERROR - PROCESSES INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="ps" return 5 else ps > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Processes information is not available." TITLE='ERROR - PROCESSES INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING="ps" return 3 fi fi TITLE="PROCESSES INFORMATION" echo -e " ***********************************" echo -e " ==::CURRENTLY RUNNING PROCESSES::==" echo -e " ***********************************" ps aux echo -e "\n" return 0 } # TO VIEW MOTHERBOARD INFORMATION. YOU NEED ROOT PRIVILEDG FOR THIS. mboardinfo(){ type dmidecode > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Advanced hardware information is not available.\nYour System does not support showing this information." TITLE='ERROR - ADVANCED HARDWARE INFORMATION NOT AVAILABLE' TRIVIALCODE=1 return 5 else dmidecode > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Advanced hardware information is not available.\nRun the script with root priviledge." TITLE='ERROR - ADVANCED HARDWARE INFORMATION NOT AVAILABLE' TRIVIALCODE=1 return 3 fi fi TITLE="ADVANCED HARDWARE INFORMATION" echo -e "\t ***********************************" echo -e "\t ==::ADVANCED SYSTEM INFORMATION::==" echo -e "\t ***********************************\n" echo -e "\t\tBIOS Information :-" echo -e "\t\t*******************" if [ "`dmidecode | grep -A5 -e 'BIOS Information' | sed '/BIOS Information/d' | wc -l`" != "0" ] then dmidecode | grep -A5 -e 'BIOS Information' | sed '/BIOS Information/d' else echo "Not Available" fi echo echo -e "\n\n\t\tBase Board Information :-" echo -e "\t\t*************************" if [ "`dmidecode | grep -A4 -e 'Base Board Information' | sed '/Base Board Information/d' | wc -l`" != "0" ] then dmidecode | grep -A4 -e 'Base Board Information' | sed '/Base Board Information/d' else echo "Not Available" fi echo if [ "`dmidecode | grep -A6 -e 'Chassis Information' | sed '/Chassis Information/d' | wc -l`" != "0" ] then echo -e "\n\n\t\tChassis Information :-" echo -e "\t\t*************************" dmidecode | grep -A8 -e 'Chassis Information' | sed '/Chassis Information/d' fi echo if [ "`dmidecode | grep -A7 -e 'Memory Controller Information' | sed '/Memory Controller Information/d' | wc -l`" != "0" ] then echo -e "\n\n\t\tMemory Controller Information :-" echo -e "\t\t********************************" dmidecode | grep -A7 -e 'Memory Controller Information' | sed '/Memory Controller Information/d' fi echo if [ "`dmidecode | grep -A7 -e 'Memory Module Information' | sed '/Memory Module Information/d' | wc -l`" != "0" ] then echo -e "\n\n\t\tMemory Module Information :-" echo -e "\t\t****************************" dmidecode | grep -A7 -e 'Memory Module Information' | sed '/Memory Module Information/d' fi echo echo -e "\n\n\t\tProcessor Information :-" echo -e "\t\t************************" cpu_count=`dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Family:' | wc -l` count=1 if [ $cpu_count -eq 0 ] then echo "Not Available" fi while [ "$count" -le "$cpu_count" ] do dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Socket Designation:' | head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Type:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Family:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Manufacturer:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'ID:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Signature:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Version:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Voltage:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Externel Clock:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Max Speed:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'Current Speed:'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'L1 Cache'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'L2 Cache'| head -n $count | tail -n 1 dmidecode | grep -A50 -e 'Processor Information' | sed '/Processor Information/d' | grep 'L3 Cache'| head -n $count | tail -n 1 count=`expr $count + 1` if [ "$count" -le "$cpu_count" ] then echo "---" fi done echo echo -e "\n\n\t\tSystem Slot Information :-" echo -e "\t\t**************************" if [ "`dmidecode | grep -A5 -e 'System Slot Information' | sed '/System Slot Information/d' | wc -l`" != "0" ] then dmidecode | grep -A5 -e 'System Slot Information' | sed '/System Slot Information/d' else echo "Not Available" fi echo echo -e "\n\n\t\tCache Information :-" echo -e "\t\t********************" if [ "`dmidecode | grep -A6 -e 'Cache Information' | sed '/Cache Information/d' | wc -l`" != "0" ] then dmidecode | grep -A6 -e 'Cache Information' | sed '/Cache Information/d' else echo "Not Available" fi echo if [ "`dmidecode | grep -A3 -e 'On Board Device Information' | sed '/On Board Device Information/d' | wc -l`" != "0" ] then echo -e "\n\n\t\tOn Board Device Information :-" echo -e "\t\t****************************" dmidecode | grep -A3 -e 'On Board Device Information' | sed '/On Board Device Information/d' fi echo if [ "`dmidecode | grep -A5 -e 'Port Connector Information' | sed '/Port Connector Information/d' | wc -l`" != "0" ] then echo -e "\n\n\t\tPort Connector Information :-" echo -e "\t\t*****************************" dmidecode | grep -A5 -e 'Port Connector Information' | sed '/Port Connector Information/d' echo fi echo return 0 } # THIS DISPLAYS SERVICES INFORMATION serviceinfo(){ type service > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Service information is not available.\nYour System does not support showing this information." TITLE='ERROR - SERVICE INFORMATION NOT AVAILABLE' TRIVIALCODE=1 return 5 fi TITLE="SERVICE INFORMATION" echo -e "*****************************" echo -e "==::SERVICES INFORMATION ::==" echo -e "*****************************\n" echo -e "RUNNING SERVICES :-" echo -e "*******************" echo -ne "NONE\b\b\b\b" service --status-all 2> /dev/null | grep running | sed '/not/d' echo echo -e "\nSTOPPED SERVICES :-" echo -e "*******************" echo -ne "NONE\b\b\b\b" service --status-all 2> /dev/null | grep stopped echo echo -e "\nDISABLED SERVICES :-" echo -e "*******************" echo -ne "NONE\b\b\b\b" service --status-all 2> /dev/null | grep disabled echo -e "\n\n" return 0 } # THIS DISPLAYS NETWORK INFORMATION networkinfo(){ type ifconfig > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Network information is not available.\nYour System does not support showing this information." TITLE='ERROR - NETWORK INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING='ifconfig' return 5 else ifconfig > /dev/null 2>&1 if [ "$?" != "0" ] then echo -e "ERROR : Network information is not available.\nRun the script with root priviledge." TITLE='ERROR - NETWORK INFORMATION NOT AVAILABLE' TRIVIALCODE=0 ERRORSTRING='ifconfig' return 3 fi fi TITLE="NETWORK INFORMATION" echo -e " ****************************" echo -e " ==::NETWORK INFORMATION ::==" echo -e " ****************************\n" if [ `ifconfig -a | grep eth | wc -l` != "0" ] then neth=`ifconfig -a | grep eth | wc -l` counteth=1 while [ $counteth -le $neth ] do count=`expr $counteth \* 4 - 1` echo -ne "Ethernet Card : " ifconfig -a | grep eth[0-9] | awk '{ print $1 }' | head -n $counteth | tail -n 1 | awk '{ printf "%s\n", $1 }' echo -ne "Hardware Address : " ifconfig -a | sed -n -e 's/.*HWaddr.//p' | head -n $counteth | tail -n 1 | awk '{ printf "%s\n", $1 }' echo -ne "Inet Address : " if [ `ifconfig -a | grep -A 2 eth | head -n $count | grep 'inet addr:' | tail -n 1 | sed -n -e 's/.*inet addr.//p' | sed -n -e 's/Bcast.*//p' | awk '{ printf "%s\n", $1 }' | wc -l` -eq 0 ] then echo -n -e "Not Applicable\n" else ifconfig -a | grep -A 2 eth | head -n $count | grep 'inet addr:' | tail -n 1 | sed -n -e 's/.*inet addr.//p' | sed -n -e 's/Bcast.*//p' | awk '{ printf "%s\n", $1 }' fi echo -ne "Broadcast Address : " if [ `ifconfig -a | grep -A 2 eth | head -n $count| grep 'Bcast:' | tail -n 1 | sed -n -e 's/.*Bcast.//p' | sed -n -e 's/Mask.*//p' | awk '{ printf "%s\n", $1 }' | wc -l` -eq 0 ] then echo -n -e "Not Applicable\n" else ifconfig -a | grep -A 2 eth | head -n $count| grep 'Bcast:' | tail -n 1 | sed -n -e 's/.*Bcast.//p' | sed -n -e 's/Mask.*//p' | awk '{ printf "%s\n", $1 }' fi echo -ne "Mask : " if [ `ifconfig -a | grep -A 2 eth | head -n $count | grep 'Mask:' | tail -n 1 | sed -n -e 's/.*Mask.//p' | awk '{ printf "%s\n", $1 }' | wc -l` -eq 0 ] then echo -n -e "Not Applicable\n" else ifconfig -a | grep -A 2 eth | head -n $count | grep 'Mask:' | tail -n 1 | sed -n -e 's/.*Mask.//p' | awk '{ printf "%s\n", $1 }' fi echo -e "\nRX/TX Packets Information :- " echo ifconfig -a | grep eth[0-9] -A 7 | head -n `expr $counteth + 7` | grep [RT]X echo -e "\n\n" counteth=`expr $counteth + 1` done else echo -e "\nIT APPEARS THAT NO NETWORK CARD IS INSTALLED\n\n" fi return 0 } # END OF MODULE 2 #XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX# #################################################################################################################### # MODULE 3:- # # THIS MODULE DISPLAYS THE VARIOUS MENUS AND TAKES INPUTS FROM THE USER # #################################################################################################################### # THIS DISPLAYS THE MENU FOR PRINTING USER INFORMATION userinfo_menu(){ if [ "$gui_support" = 'y' ] then cancel_userinfo_menu=0 while [ "$cancel_userinfo_menu" != "1" ] do dialog --title "USER INFORMATION MENU" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --extra-button --extra-label "Save" --cancel-label "Back" --menu "\nSelect Any Item Below and then Press 'OK' to view information or 'Save' to Save it to disk:\n" 19 40 7 1 "List all users in host machine" 2 "Users currently logged in" 3 "Detail of a user" 4 "Group Information" 5 "Quit" 2> "$CHOICE" cancel_userinfo_menu=$? choice2=`cat $CHOICE` if [ "$cancel_userinfo_menu" = "3" ] then case "$choice2" in 1) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 usertot > $TEMP 2>> $TMPLOG if [ "$?" != "0" ] then printerr "$?" "$TRIVIALCODE" "$ERRORSTRING" else save fi ;; 2) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 userlog > $TEMP 2>> $TMPLOG save ;; 3) type finger > /dev/null 2>&1 if [ "$?" -ne 0 ] then printerr 2 1 else cancel_userdetail=0 while [ "$cancel_userdetail" != "1" ] do dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --cancel-label "Back" --inputbox " `echo "Users :\n"; awk -F: '{ if( $3 >= 500 && $3 <= 9999 ) printf "%s, ", $1 ; }' /etc/passwd` \n\nEnter a username to Save the Details to disk (or press Cancel to go back to previous menu):" 19 70 2> "$CHOICE" cancel_userdetail=$? username=`cat $CHOICE` if [ -n "$username" ] && [ "$cancel_userdetail" = "0" ] then dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 userdetail "$username" if [ "$?" = "1" ] then dialog --title "USER NOT FOUND!!" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 else save fi fi done fi ;; 4) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 groupinfo > $TEMP 2>> $TMPLOG EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save fi ;; 5) exit_msg quit ;; esac dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 continue fi case "$choice2" in 1) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 usertot > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 2) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 userlog > "$TEMP" 2>> "$TMPLOG" dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 62 ;; 3) type finger > /dev/null 2>&1 if [ "$?" -ne 0 ] then printerr 2 1 else cancel_userdetail=0 while [ "$cancel_userdetail" != "1" ] do dialog --title "USER DETAIL" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --cancel-label "Back" --inputbox " `echo "Users :\n"; awk -F: '{ if( $3 >= 500 && $3 <= 9999 ) printf "%s, ", $1 ; }' /etc/passwd` \n\nEnter a username to View Details (or press Cancel to go back to previous menu):" 19 70 2> "$CHOICE" cancel_userdetail=$? username=`cat $CHOICE` if [ -n "$username" ] && [ "$cancel_userdetail" = "0" ] then dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 userdetail "$username" dialog --title "USER DETAIL" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi done fi ;; 4) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 groupinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 20 52 fi ;; 5) exit_msg quit ;; esac done else choice2=1 while [ -z "$choice2" ] || [ "$choice2" != "6" ] do clear echo -e "\nAuthor - Makarand Hazarika, Siddhartha Sarkar\n\n" echo -e "\n*******************************" echo -e "==:: USER INFORMATION MENU ::==" echo "*******************************" echo "1) List all users in host machine" echo "2) Users currently logged in" echo "3) Information about a particular user" echo "4) Group Information" echo "5) Save All User Information to Disk" echo "6) Back to previous menu" echo -en "\nPlease Enter Your Choice (1-6): " read choice2 case "$choice2" in 1) echo -e "\n\nRetrieving Information." echo -n "Please wait..." usertot > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 2) echo -e "\n\nRetrieving Information." echo -n "Please wait..." userlog > "$TEMP" 2>> "$TMPLOG" clear more "$TEMP" echo -en "\nPress Enter to Continue..." read ;; 3) type finger > /dev/null 2>&1 if [ "$?" -ne 0 ] then clear printerr 2 1 else username=n while [ "$username" != q ] do clear echo "Users :" awk -F: '{ if( $3 >= 500 && $3 <= 9999 ) printf "%s, ", $1 ; }' /etc/passwd echo -e "\nEnter a Username to View Details" echo -n " (q to Return to Previous Menu) : " read username if [ -n "$username" ] && [ "$username" != "q" ] then echo -e "\n\nRetrieving Information." echo -n "Please wait..." userdetail "$username" clear more $TEMP echo -en "\nPress Enter to Continue..." read fi done fi ;; 4) echo -e "\n\nRetrieving Information." echo -n "Please wait..." groupinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 5) echo -ne "\n\n\nSaving Information.\nPlease wait..." main -uUg > $TEMP 2> /dev/null save echo -e "\n\nInformation Saved in File: $SAVEINFO" echo -n "Press Enter to continue...." read ;; 6) return ;; esac done fi return 0 } # THIS DISPLAYS THE MENU FOR PRINTING SYSTEM INFORMATION systeminfo_menu(){ if [ "$gui_support" = 'y' ] then cancel_systeminfo_menu=0 while [ "$cancel_systeminfo_menu" != 1 ] do dialog --title "SYSTEM INFORMATION MENU" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --extra-button --extra-label "Save" --cancel-label "Back" --menu "\nSelect Any Item Below and then Press 'OK' to view information or 'Save' to Save it to disk:\n" 19 40 9 1 "Basic Hardware Information" 2 "Basic System Configuration" 3 "Diskdrive Information" 4 "PCI Information" 5 "Memory Usage" 6 "Running Processes" 7 "Advanced System Information" 8 "Services Information" 9 "Quit" 2> "$CHOICE" cancel_systeminfo_menu=$? choice1=`cat $CHOICE` if [ "$cancel_systeminfo_menu" = "3" ] then case "$choice1" in 1) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 hwdinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 2) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 configinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 3) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 hddinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 4) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 pciinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 5) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 meminfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 6) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 procinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 7) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 mboardinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi ;; 8) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 serviceinfo > "$TEMP" 2> /dev/null EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else if [ `cat $TEMP | wc -l` -le 17 ] then printerr 2 1 else save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 fi fi ;; 9) exit_msg quit ;; esac continue fi case "$choice1" in 1) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 hwdinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 2) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 configinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 3) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 hddinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 4) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 pciinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 5) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 meminfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 6) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 procinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 7) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 mboardinfo > "$TEMP" 2>> $TMPLOG EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi ;; 8) dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 serviceinfo > "$TEMP" 2>> $TMPLOG EXIT_STATUS="$?" if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else if [ `cat $TEMP | wc -l` -le 17 ] then printerr 2 1 else dialog --title "$TITLE" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 72 fi fi ;; 9) exit_msg quit ;; esac done else choice1=1 while [ -z "$choice1" ] || [ "$choice1" != "10" ] do clear echo -e "\nAuthor - Makarand Hazarika, Siddhartha Sarkar\n\n" echo -e "\n*********************************" echo -e "==:: SYSTEM INFORMATION MENU ::==" echo "*********************************" echo "1) Basic Hardware Information" echo "2) Basic System Configuration" echo "3) Diskdrive Information" echo "4) PCI Information" echo "5) Memory Usage" echo "6) Running Processes" echo "7) Advanced System Information" echo "8) Services Information" echo "9) Save All System Information to Disk" echo "10) Back to previous menu" echo -en "\nEnter Your Choice (1-10): " read choice1 case "$choice1" in 1) echo -e "\n\nRetrieving Information." echo -n "Please wait..." hwdinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 2) echo -e "\n\nRetrieving Information." echo -n "Please wait..." configinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 3) echo -e "\n\nRetrieving Information." echo -n "Please wait..." hddinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 4) echo -e "\n\nRetrieving Information." echo -n "Please wait..." pciinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 5) echo -e "\n\nRetrieving Information." echo -n "Please wait..." meminfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 6) echo -e "\n\nRetrieving Information." echo -n "Please wait..." procinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 7) echo -e "\n\nRetrieving Information." echo -n "Please wait..." mboardinfo > "$TEMP" 2>> "$TMPLOG" EXIT_STATUS="$?" clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi ;; 8) echo -e "\n\nRetrieving Information." echo -n "Please wait..." serviceinfo > "$TEMP" 2>> $TMPLOG clear if [ "$EXIT_STATUS" != "0" ] then printerr "$EXIT_STATUS" "$TRIVIALCODE" "$ERRORSTRING" else if [ `cat $TEMP | wc -l` -le 17 ] then printerr 2 1 else more "$TEMP" echo -en "\nPress Enter to Continue..." read fi fi ;; 9) echo -ne "\n\n\nSaving Information.\nPlease wait..." main -dsHcmpDS > $TEMP 2>> $TMPLOG save echo -e "\n\nInformation Saved in File: $SAVEINFO" echo -n "Press Enter to continue...." read ;; 10) return ;; esac done fi return 0 } # THERE IS NO MENU FOR DISPLAYING NETWORK INFORMATION TILL NOW, BUT AS A STANDARD FOLLOWED IN THIS SCRIPT, # I HAVE ADDED THIS FUNCTION HERE. nwinfo_menu(){ if [ "$gui_support" = 'y' ] then dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Retrieving Information.\nPlease wait..." 7 40 networkinfo > "$TEMP" 2>> "$TMPLOG" dialog --title "NETWORK INFORMATION" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --exit-label "OK" --textbox "$TEMP" 19 70 else echo -e "\n\nRetrieving Information." echo -n "Please wait..." networkinfo > "$TEMP" 2>> "$TMPLOG" clear more "$TEMP" echo -en "\nPress Enter to Continue..." read fi return 0 } # THIS DISPLAYS THE MAIN MENU. THIS IS WHAT THE USER SEES WHEN HE RUNS THE SCRIPT WITHOUT ANY OPTION # WHEN USED WITH AN OPTION, IT DISPLAYS THE NECESSARY INFO. AND EXITS. main(){ if [ -z "$*" ] then if [ "$gui_support" = "y" ] then cancel_main=0 while [ "$cancel_main" != "1" ] do dialog --title "MAIN MENU" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --extra-button --extra-label "Save" --cancel-label "Exit" --menu "\nSelect Any Item Below and then Press 'OK' to view information or 'Save' to Save it to disk:\n" 19 38 5 1 "User Information" 2 "System Information" 3 "Network Information" 2> $CHOICE cancel_main=$? choice=`cat $CHOICE` if [ "$cancel_main" = "3" ] then dialog --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --infobox "Saving Information.\nPlease wait..." 7 40 case "$choice" in 1) main -uUg > $TEMP 2>> $TMPLOG ;; 2) main -dsHcmpDS > $TEMP 2>> $TMPLOG ;; 3) main -N > $TEMP 2>> $TMPLOG ;; esac save dialog --title "FILE SAVED" --backtitle "Author - Makarand Hazarika, Siddhartha Sarkar" --msgbox "\nInformation Saved in File: $SAVEINFO\n" 12 45 continue fi case "$choice" in 1) userinfo_menu ;; 2) systeminfo_menu ;; 3) nwinfo_menu ;; esac done else choice=1 while [ -z "$choice" ] || [ "$choice" != 5 ] do clear echo -e "\nAuthor - Makarand Hazarika, Siddhartha Sarkar\n" echo -e "\n***************" echo -e "==:: MENU ::==" echo "***************" echo "1) User Information" echo "2) System Information" echo "3) Network Information" echo "4) Save All Information to Disk" echo "5) Exit" echo -en "\nPlease Enter Your Choice (1-4): " read choice case "$choice" in 1) userinfo_menu ;; 2) systeminfo_menu ;; 3) nwinfo_menu ;; 4) echo -ne "\n\n\nSaving Information.\nPlease wait..." main -a > $TEMP 2> /dev/null save echo -e "\n\nInformation Saved in File: $SAVEINFO" echo -n "Press Enter to continue...." read ;; esac done fi exit_msg cleanup clear else #THIS IS FOR TAKING CARE OF OPTIONS for param in "$@" do if [ "$param" = "--help" ] || [ "$param" = "-h" ] then echo -e 'S&M Sysinfo, Sysinfo by Manna & Sid!!' echo -e "sysinfo Version $VERSION" echo -e "Author -- Makarand Hazarika, Siddhartha Sarkar" echo -e "Copyright (C) 2006 Makarand Hazarika" echo -e "This is free software; see the source for copying conditions." echo -e "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE" echo -e "\nUsage: sysinfo [OPTION]..." echo -e "A textmode graphical utility for displaying system information" echo -e "Run without options to enter graphical menu" echo -e "\nOptions:" echo -e "\t-h, --help display this help and exit" echo -e "\t-v, --version display version and exit" echo -e "\t-a, --all display all information in the following order" echo -e "\t-u, --usertot display total users in host" echo -e "\t-U, --userlog display users currently logged in" echo -e "\t-g, --grpinfo display groups along with the GID" echo -e "\t-d, --hardware display hardware information" echo -e "\t-s, --sysconf display system configuration information" echo -e "\t-H, --hdd display disk-drive information" echo -e "\t-c, --pci display PCI information" echo -e "\t-m, --mem display memory usage information" echo -e "\t-p, --proc display currently running processs" echo -e "\t-N, --nwinfo display network information" echo -e "\t-D, --advhdw display advanced hardware information (needs root priviledge)" echo -e "\t-S, --service display services information (may need root priviledge)\n" echo -e "Report Bugs to " exit 0 fi if [ "$param" = "--version" ] || [ "$param" = "-v" ] then echo -e 'S&M Sysinfo, Sysinfo by Manna & Sid!!' echo -e "sysinfo Version $VERSION" echo -e "Author -- Makarand Hazarika, Siddhartha Sarkar" echo -e "Copyright (C) 2006 Makarand Hazarika" echo -e "This is free software; see the source for copying conditions." echo -e "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE" exit 0 fi case "$param" in --*) ;; -*h*) main -h ;; -*v*) main -v ;; [^-]*) echo -e "\nERROR: Does not take any arguments" 1>&2 echo -e "Try \"sysinfo --help\" for more information\n" 1>&2 exit 1 ;; -*[^ahdsuUgHcmpNDS]*) echo -e "\nERROR: Unkown option -- \"$param\" " 1>&2 echo -e "Type \"sysinfo --help\" for more information\n" 1>&2 exit 1 ;; esac done echo for param in "$@" do short=0 case "$param" in "--all") main -a return ;; "--usertot") usertot ;; "--userlog") userlog ;; "--grpinfo") groupinfo ;; "--hardware") hwdinfo ;; "--sysconf") configinfo ;; "--hdd") hddinfo ;; "--pci") pciinfo ;; "--mem") meminfo ;; "--proc") procinfo ;; "--nwinfo") networkinfo ;; "--advhdw") mboardinfo ;; "--service") serviceinfo ;; "--"*) echo -e "ERROR: Unkown option -- \"$param\" " 1>&2 echo -e "Type \"sysinfo --help\" for more information\n" 1>&2 exit 1 ;; "-"*) short=1 ;; esac # THIS PART CHECKS FOR SHORT OPTIONS WHICH CAN EVEN BE COMBINED # BELIEVE ME, THIS PART IS REAL TRICKY!! # I AM STILL NOT SURE WHETHER THIS PART IS TOTALY BUG FREE if [ "$short" -eq 1 ] then while [ "$param" != "-" ] do case "$param" in -*a*) main -uUgdsHcmpNDS return ;; esac case "$param" in -u*) usertot param=`echo "$param" | sed -n -e 's/u//p'` ;; esac case "$param" in -U*) userlog param=`echo "$param" | sed -n -e 's/U//p'` ;; esac case "$param" in -g*) groupinfo param=`echo "$param" | sed -n -e 's/g//p'` ;; esac case "$param" in -d*) hwdinfo param=`echo "$param" | sed -n -e 's/d//p'` ;; esac case "$param" in -s*) configinfo param=`echo "$param" | sed -n -e 's/s//p'` ;; esac case "$param" in -H*) hddinfo param=`echo "$param" | sed -n -e 's/H//p'` ;; esac case "$param" in -c*) pciinfo param=`echo "$param" | sed -n -e 's/c//p'` ;; esac case "$param" in -m*) meminfo param=`echo "$param" | sed -n -e 's/m//p'` ;; esac case "$param" in -p*) procinfo param=`echo "$param" | sed -n -e 's/p//p'` ;; esac case "$param" in -N*) networkinfo param=`echo "$param" | sed -n -e 's/N//p'` ;; esac case "$param" in -D*) mboardinfo param=`echo "$param" | sed -n -e 's/D//p'` ;; esac case "$param" in -S*) serviceinfo param=`echo "$param" | sed -n -e 's/S//p'` ;; esac done fi done fi return "$?" } ###################################################################################################################### ##############******************** EXECUTION OF THE SCRIPT STARTS HERE ********************####################### ###################################################################################################################### # SIMPLY 3 STEPS:- #STEP 1 :- # INITITIALIZING THE ENVIRONMENT trap "quit $1 ; " 1 2 3 7 9 11 15 init "$@" # STEP 2 :- # CALLING MAIN FUNCTIONS PASSING ALL THE ARGUMENTS ALONG WITH trap "quit $1 ; " 1 2 3 7 9 11 15 main "$@" # SETP 3 :- # EXIT exit 0 ###################################################################################################################### ###############******************** EXECUTION OF THE SCRIPT ENDS HERE *********************####################### ######################################################################################################################