#!/bin/bash # # cupsconftest.sh # (c)Kurt Pfeifle, Danka Deutschland GmbH # # This little script takes no argument. If run by root, it # tests the CUPS configuration, creates a quite verbose # report and writes it to a file... # # Plans: -- test it on various systems # -- adapt it to other platforms # -- give it some commandline options (like --verbose, --display,...) # -- # # in case you are not root, you're not allowed to read the 'cupsd.conf' # nor other files.... if [ `id -u` -ne 0 ]; then echo "" echo " You need to be root to run '$0' and" echo " collect information about the local CUPS server!" echo "" exit 1 fi VERBOSE=1 HOSTNAME=`hostname` DATE=`date` CONFIGLOGTEMPFILE=~/tmp.$$ CONFIGLOGFILE=~/current-cupsconfig CONFIGLOGFILECOMPRESSED=~/current-cupsconfig.tar.gz SERVERROOT=`cups-config --serverroot` CUPSDCONF_FILE=$SERVERROT/cupsd.conf # which additional tools do we have at our disposal? if [ -x `which lynx` ]; then TEXTBROWSER=`which lynx` NOTEXTBROWSERMESSAGE="Using `which lynx` as text browser..." elif [ -x `which links` ]; then TEXTBROWSER=`which links` NOTEXTBROWSERMESSAGE="Using `which links` as text browser..." elif [ -x `which w3m` ]; then TEXTBROWSER=`which w3m` NOTEXTBROWSERMESSAGE="Using `which w3m` as text browser..." else TEXTBROWSER= NOTEXTBROWSERMESSAGE="No text browser available on this system." fi # which pager do we use? if [ -x `which less` ]; then MORECOMMAND="`which less`" else MORECOMMAND="`which more`" fi echo "" echo "Please stand by while your CUPS system is evaluated...." echo "" echo "" sleep 2 echo $NOTEXTBROWSERMESSAGE # where is the system's error_log ? ERRORLOGDEFINITION=`cat /etc/cups/cupsd.conf |grep ErrorLog |grep -v ^#| awk '{ print $2 }'` if [ -z $ERRORLOGDEFINITION ]; then ERRORLOGFILE="/var/log/cups/error_log" else ERRORLOGFILE=$ERRORLOGDEFINITION fi #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF -------------------------------------------------------------------- CUPS configuration as determined by the $0 script -------------------------------------------------------------------- (Running on `hostname` at `date`) ==================================================================== EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ---------------------------------- Output of command "lpstat -t" is: ---------------------------------- `lpstat -t` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ----------------------------------- Output of command "lpinfo -v" is: ----------------------------------- `lpinfo -v` EOF__EOF__EOF #################################################################### :1 cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF --------------------------- Output of "lpinfo -m" is: --------------------------- `lpinfo -m` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------ Enabled directives in "cupsd.conf" ------------------------------------ `head $SERVERROOT/cupsd.conf 2> /dev/null` `cat $SERVERROOT/cupsd.conf|grep -v ^#|grep [:alnum:]` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ----------------------------------- Contents of "printers.conf" are: ----------------------------------- `cat $SERVERROOT/printers.conf` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ----------------------------------- The files in "$SERVERROOT/ppd/" are: ----------------------------------- `ls -ltra $SERVERROOT/ppd/` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------- Contents of "/etc/cups/client.conf" are: ------------------------------------------- `head $SERVERROOT/client.conf &> /dev/null` `cat $SERVERROOT/client.conf|grep -v ^#|grep [:alnum:] &> /dev/null` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF -------------------------------------- Contents of "~/.lpoptions" file is: -------------------------------------- `cat ~/.lpoptions 2> /dev/null` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF --------------------------------------------- Contents of "$SERVERROOT/lpoptions" file is: --------------------------------------------- `cat $SERVERROOT/lpoptions` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ----------------------------------------------------------- The following CUPS filters have been found on your system: ----------------------------------------------------------- `ls -ltra /usr/lib/cups/filter` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF -------------------------------------- The 'cups-config' command tells this: -------------------------------------- cups-config --api-version: `cups-config --api-version` cups-config --cflags: `cups-config --cflags` cups-config --datadir: `cups-config --datadir` cups-config --ldflags: `cups-config --ldflags` cups-config --image --static --libs: `cups-config --image --static --libs` cups-config --serverbin: `cups-config --serverbin` cups-config --serverroot: `cups-config --serverroot` cups-config --version: `cups-config --version` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF --------------------------------------------------- This is the situation with the overall disk space: --------------------------------------------------- `df -h` EOF__EOF__EOF #################################################################### # collect tha statistics.... PENDINGJOBS=`lpstat -o | wc -l` PPDFILESINREPOSITORY=`lpinfo -m | wc -l` =`lpstat -p | grep printer | wc -l` PRINTERSTOTAL=`lpstat -p | grep printer | wc -l` PRINTERSLOCALLYINSTALLED=`cat /etc/cups/printers.conf|grep "> $CONFIGLOGTEMPFILE << EOF__EOF__EOF --------------------------------------------------- This is the summary report for your CUPS system: --------------------------------------------------- * You seem to have $PPDFILESINREPOSITORY PPD files in your local repository (usually "/usr/shar/cups/model/" and sub directories). * You have $PRINTERSLOCALLYINSTALLED local printers installed (printers whose jobs are processed on this print server, and sent from here to the printer). $LOCALRAWPRINTERMESSAGE * You currently have $PENDINGJOBS pending jobs (waiting to be printed). * You currently have a total of $PRINTERSTOTAL printers (locally and remotely installed) at your disposal. EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------------------------- This is an extract of your 'error_log' file, with uniq lines containing the character 'E' at the beginning of a line; this extract might indicate potential problems with your setup (figure at the beginning of line indicates number of counts): ------------------------------------------------------------- `cat $ERRORLOGFILE | grep ^E| sed s#E\ .*"]"#E:\ \ #g |uniq -c` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------------------------- This is an extract of your 'error_log' file, with uniq lines containing the word 'error'; this might indicate potential problems (figure at the beginning of line indicates number of counts): ------------------------------------------------------------- `cat $ERRORLOGFILE | grep -i error | sed s#D\ .*"]"#error:\ \ #g |uniq -c` EOF__EOF__EOF #################################################################### # more statistics about the error_log... TOTALerror_logLINES=`cat $ERRORLOGFILE | wc -l` error_logSIZE=`ls -ld $ERRORLOGFILE | awk '{ print $5 }'` NUMBERerrorLINES=`cat $ERRORLOGFILE | grep -i error | wc -l` NUMBER_E_LINES=`cat $ERRORLOGFILE | grep ^E | wc -l` NUMBER_I_LINES=`cat $ERRORLOGFILE | grep ^I | wc -l` NUMBER_D_LINES=`cat $ERRORLOGFILE | grep ^D | wc -l` NUMBER_d_LINES=`cat $ERRORLOGFILE | grep ^d | wc -l` TIME_BEGIN_ERRORLOG=`head -1 $ERRORLOGFILE | gawk '{ ORS = " "; print $2; print $3 }'` TIME_END_ERRORLOG=`tail -1 $ERRORLOGFILE | gawk '{ ORS = " "; print $2; print $3 }'` CURRENT_LOGLEVEL= BROWSE_ADDRESS=`cat $ERRORLOGFILE | grep -i brows | tail -n 20` LISTEN_ADDRESS=`cat $ERRORLOGFILE | grep -i listen | tail -n 20` JOBHISTORYNUMBER=`ls -lart /var/spool/cups/ |grep " c" | wc -l` JOBFILENUMBER=`ls -lart /var/spool/cups/ |grep " d" | wc -l` PRESERVEJOBHISTORY=`cat $SERVERROOT/cupsd.conf | grep -i PreserveJobHistory` PRESERVEJOBFILES=`cat $SERVERROOT/cupsd.conf | grep -i PreserveJobFiles` cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------------------------- $TIME_BEGIN_ERRORLOG: First entry into the error_log. $TIME_END_ERRORLOG: Last entry into the error_log. ------------------------------------------------------------- Here are some statistics about your error_log: ---------------------------------------------- $TOTALerror_logLINES number of lines in the error_log. $error_logSIZE Bytes is the size of the error_log. $NUMBERerrorLINES number of times is the word 'error' in the error_log. $NUMBER_E_LINES number of errors in error_log (lines with 'E' in front). $NUMBER_I_LINES lines mapping to 'LogLevel info' (lines with 'I' in front). $NUMBER_D_LINES lines mapping to 'LogLevel debug' (lines with 'D' in front). $NUMBER_d_LINES lines mapping to 'LogLevel debug2' (lines with 'd' in front). $CURRENT_LOGLEVEL The last used 'Browse' configuration settings were: --------------------------------------------------- $BROWSE_ADDRESS The last used 'Listen' configuration settings were: --------------------------------------------------- $LISTEN_ADDRESS Facts about your 'JobHistory' Settings: --------------------------------------- $JOBHISTORYNUMBER number of jobs have facts saved in 'JobHistory'. $JOBFILENUMBER number of actual printfiles currently saved on CUPS server. Here is what 'cupsd.conf' is set to (regarding old jobs): --------------------------------------------------------- $PRESERVEJOBHISTORY $PRESERVEJOBFILES (a '#' at beginning of line indicates a comment.) EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------------------------- This is the current setting of the server's network interfaces: ------------------------------------------------------------- `ifconfig` EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------------------------- These are Samba-related settings on the CUPS server: ------------------------------------------------------------- Is Samba running? ("ps aux |grep mbd") `ps aux | grep mbd | grep -v grep` What are the print-related settings for Samba? `testparm -s |grep print| grep -v "\[print"` `testparm -s |grep -v -i processing | grep -A8 -i "\[print"` (This will not have catched Printer Shares which have been created manually...) EOF__EOF__EOF #################################################################### GHOSTSCRIPTDEVICENUMBER=`gs -h | grep "^ " | grep -v embed | grep -v / | wc -w` GHOSTSCRIPTSEARCHPATH=`gs -h | grep "/" | grep ":"` IJSEXIST=`gs -h | grep " ijs " | wc -l | gawk '{ print $1 }'` HPIJSEXIST=`gs -h | grep " hpijs " | wc -l | gawk '{ print $1 }'` OMNIEXIST=`gs -h | grep " omni " | wc -l | gawk '{ print $1 }'` CUPSEXIST=`gs -h | grep " cups " | wc -l | gawk '{ print $1 }'` if [ "$CUPSEXIST" = "1" ]; then CUPSMESSAGE=" 'cups' is enabled. ------------------ This means, you have CUPS support enabled in your Ghostscript and you can run CUPS 1.1.15 or newer on this system without a requirement for update." else CUPSMESSAGE=" ===================================================================== 'cups' is not enabled. ---------------------- This means you can only run CUPS up to version 1.1.14 on your system or you need to upgrade your Ghostscript to a newer version (or patch it accordingly). Recommended is ESP Ghostscript 7.05-4 or newer. You can get it from 'http://www.cups.org/software.html'. [CUPS versions 1.1.14 and prior included their own 'pstoraster' filter which was based off GNU Ghostscript 5.50. The tasks of 'pstoraster' are now 'outsourced' to the 'cups' device of Ghostscript...] =====================================================================" fi if [ "$IJSEXIST" = "1" ]; then IJSMESSAGE=" 'ijs' is enabled. ----------------- This means you can use all new-generation, modular Ghostscript drivers with this version of Ghostscript, like the new 'Gimp-Print', 'HPIJS' (from HP) or the 'Omni' (from IBM) families ." else IJSMESSAGE=" 'ijs' is not enabled. --------------------- This means you need a re-compilation (or update by download) of the whole Ghostscript package for every small change and improvement in any one driver you want to use.'" fi if [ "$HPIJSEXIST" = "1" ]; then HPIJSMESSAGE=" 'hpijs' is enabled. ------------------- This means you are using an older version of the 'ijs' interface, which is not working with other than the older 'HPIJS' drivers. It is recommended to update your Ghostscript version." else HPIJSMESSAGE=" 'hpijs' is not enabled. ----------------------- As long as you have 'ijs' you are OK: you can use nearly the whole spectrum of HP printers (nearly 130 models)." fi if [ "$OMNIEXIST" = "1" ]; then OMNIMESSAGE=" 'omni' is enabled. ------------------ This means you can use the whole family of Omni drivers, which include support for more than 400 printer models." else OMNIMESSAGE="'omni' is not enabled." fi cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ------------------------------------------------------- These are Ghostscript-related infos about your system: ------------------------------------------------------- Output of 'gs -h': ------------------ `gs -h` ----------------------------------------- This means, you have $GHOSTSCRIPTDEVICENUMBER "devices" compiled into your Ghostscript. ----------------------------------------- 'Search path': -------------- This means, Ghostscript is looking for fonts in these directories: $GHOSTSCRIPTSEARCHPATH ---------------------------------------- If you install additional fonts, do make sure that they go into one of those directories. You can not configure Ghostscript to look somewhere else. Additional search paths require a re-comilation of Ghostscript. ---------------------------------------- A few details about your built-in or supported drivers: ======================================================= $CUPSMESSAGE $HPIJSMESSAGE $IJSMESSAGE $OMNIMESSAGE EOF__EOF__EOF #################################################################### # # #Is Samba running? ("ps aux |grep mbd") #`ps aux | grep mbd | grep -v grep` # #What are the print-related settings for Samba? # #`testparm -s |grep print| grep -v "\[print"` #`testparm -s |grep -v -i processing | grep -A8 -i "\[print"` # #(This will not have catched Printer Shares which have been #created manually...) # # #EOF__EOF__EOF #################################################################### if [ -x `which esplicense` ]; then cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF --------------------------------------------------------- These are licensing informations concerning ESP PrintPro: --------------------------------------------------------- You have an ESP PrintPro license installed on this system. `esplicense list` EOF__EOF__EOF fi #################################################################### PSTORASTER="/usr/lib/cups/filter/pstoraster" YOURGHOSTSCRIPTVERSION=`gs -h | head -1` if [ -x $PSTORASTER ]; then if [ `file $PSTORASTER | grep -i exec | wc -l | gawk '{ print $1 }'` = "1" ]; then PSTORASTERMESSAGE=" Your 'pstoraster' is a compiled Program, as was shipped with CUPS 1.1.14 and prior versions. This will not work with CUPS 1.1.15 and later." elif [ `file $PSTORASTER |grep -i shell | wc -l | gawk '{ print $1 }'` = "1" ]; then PSTORASTERGHOSTSCRIPTPARAM=`cat $PSTORASTER | grep -i gsopts` PSTORASTERMESSAGE=" Your 'pstoraster' CUPS filter is a shell script; it calls your installed '$YOURGHOSTSCRIPTVERSION' to do the job of converting most files into a printable format for your printers. This seems to be capable of usage in conjunction with CUPS 1.1.15 or later. It is using these parameters when calling Ghostscript: $PSTORASTERGHOSTSCRIPTPARAM" fi else PSTORASTERMESSAGE=" I was unable to detect an exectable 'pstoraster' filter in the standard location '/usr/lib/cups/filter/'. Did you compile CUPS on your own and set a different Path? " fi cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF --------------------------------------- Your installed version of Ghostscript: --------------------------------------- $YOURGHOSTSCRIPTVERSION EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ----------------------------------------------------------- The following CUPS-related MIME type recognition and filter configuration files have been discovered on the system: ----------------------------------------------------------- `ls -l $SERVERROOT/*types*` `ls -l $SERVERROOT/*convs*` 'pstoraster' settings: ---------------------- $PSTORASTERMESSAGE EOF__EOF__EOF #################################################################### cat >> $CONFIGLOGTEMPFILE << EOF__EOF__EOF ############################################################# # # Your configuration has been written to # # $CONFIGLOGFILE. # # For your convenience, this has been also written as a # compressed file to # # $CONFIGLOGFILECOMPRESSED, # # to be mailed to other people for investigation, in case # you need to provide essential information for # troubleshooting purposes.... # ############################################################# (c)Kurt Pfeifle, Danka Deutschland GmbH EOF__EOF__EOF cp $CONFIGLOGTEMPFILE $CONFIGLOGFILE tar czf $CONFIGLOGFILE.tar.gz $CONFIGLOGFILE 2> /dev/null cat $CONFIGLOGFILE | $MORECOMMAND if [ -x `which a2ps` ]; then export DISPLAY=:0 a2ps -P display -1 $CONFIGLOGFILE fi rm $CONFIGLOGTEMPFILE echo " " echo " " exit 0