#!/bin/bash

SVER=2.25-104
SDATE="2009 04 27"

##############################################################################
#  supportconfig - Gathers system troubleshooting information for NTS.
#  Copyright (C) 2001, 2007, 2008, 2009 Novell, Inc.
#
#  Creates a tar ball to attach to the SR or send to support. Basic info is 
#  collected for SLES8. More comprehensive information is collected for 
#  SLES9/SLE10/SLE11/OES1 Linux/OES2 Linux.
#
#  Please submit bug fixes or comments via:
#    http://en.opensuse.org/Supportutils#Reporting_Bugs
#
#  Disclaimer:
#  Detailed system information and logs are collected and organized in a
#  manner that helps reduce service request resolution times. Private system
#  information can be disclosed when using this tool. If this is a concern,
#  please prune private data from the log files. Several startup options 
#  are available to exclude more sensitive information. Use supportconfig -h 
#  to see these options.
##############################################################################
#
#  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; version 2 of the License.
#
#  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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#  Authors/Contributors:
#     Jason Record (jrecord@novell.com)
#
##############################################################################
# Default Options
##############################################################################
OPTION_AFP=1
OPTION_APPARMOR=1
OPTION_AUTOFS=1
OPTION_BOOT=1
OPTION_CHKCONFIG=1
OPTION_CIFS=1
OPTION_CIMOM=1
OPTION_CRASH=1
OPTION_CRON=1
OPTION_DISK=1
OPTION_DNS=1
OPTION_EDIR=1
OPTION_ENV=1
OPTION_ETC=1
OPTION_EVMS=1
OPTION_HA=1
OPTION_HCREPORT=1
OPTION_IB=1
OPTION_ISCSI=1
OPTION_LDAP=1
OPTION_LUM=1
OPTION_LVM=1
OPTION_MEM=1
OPTION_MOD=1
OPTION_MPIO=1
OPTION_NCP=1
OPTION_NCS=1
OPTION_NET=1
OPTION_NFS=1
OPTION_NSS=1
OPTION_NTP=1
OPTION_OCFS2=1
OPTION_OFILES=1
OPTION_PAM=1
OPTION_PRINT=1
OPTION_PROC=1
OPTION_SAM=1
OPTION_SAR=1
OPTION_SLERT=1
OPTION_SLP=1
OPTION_SMT=1
OPTION_SMART=0
OPTION_SMB=1
OPTION_SRAID=1
OPTION_SSH=1
OPTION_SYSCONFIG=1
OPTION_UDEV=1
OPTION_UP=1
OPTION_UPD=1
OPTION_WEB=1
OPTION_X=1
OPTION_XEN=1

ADD_OPTION_EDIR=0
ADD_OPTION_FSLIST=0
ADD_OPTION_LOGS=0
ADD_OPTION_MINDISK=0
ADD_OPTION_MINYAST=0
ADD_OPTION_RPMV=0
ADD_OPTION_SLP=0
 
VAR_OPTION_BIN_TIMEOUT_SEC=300
VAR_OPTION_CONTACT_COMPANY=""
VAR_OPTION_CONTACT_EMAIL=""
VAR_OPTION_CONTACT_NAME=""
VAR_OPTION_CONTACT_PHONE=""
VAR_OPTION_CONTACT_STOREID=""
VAR_OPTION_CONTACT_TERMINALID=""
VAR_OPTION_GPG_UID=""
VAR_OPTION_LOG_DIRS="/var/log /tmp"
VAR_OPTION_LINE_COUNT=500
VAR_OPTION_MSG_MAXSIZE=500000
VAR_OPTION_PENGINE_FILES_LIMIT=250
VAR_OPTION_SAR_FILES_LIMIT=30
VAR_OPTION_SILENT=0
VAR_OPTION_SBM=0
VAR_OPTION_UNIQUE_FILE=0
VAR_OPTION_UPLOAD_TARGET='https://secure-www.novell.com/upload?appname=supportconfig&file={tarball}'

PATH="/sbin:/usr/sbin:/bin:/usr/bin:$PATH"
PATH_ORIG=$PATH
export PATH
CURRENT_SCRIPT=$(basename $0)
unset CONTACT_SRNUM
UPLOAD_TARBALL=0
SRLEN=11
CSFILE=${CURRENT_SCRIPT}.txt
RPMFILE=rpm.txt
FSLIST_FILE=fs-files.txt
RPM_QA_FILE=rpm_qa.txt
RPM_DIST_FILE=rpm_dist.txt
BASIC_ENVF=basic-environment.txt
COMPRESS="tbz"
COMPRESS_OPT="jcf"
SC_SRV=$(hostname)
test "$SC_SRV" = "" && SC_SRV=novell
SC_TIME=$(date +"%y%m%d_%H%M")
BASE="nts_${SC_SRV}_${SC_TIME}"
ARCH=$(uname -i)
XPLUGIN_DIR=/opt/supportconfig/plugins
SAVE_LOGS_ONLY=0
USE_SAVED_LOGS_ONLY=0
ENCRYPTED_TARBALL=0

# These are minimum options and should never be unset.
MIN_OPTION_RPM=1
MIN_OPTION_ENV=1
MIN_OPTION_HC=1
MIN_OPTION_HARDWARE=1
MIN_OPTION_YAST=1
MIN_OPTION_SYSLOGS=1
MIN_OPTION_AUTOMOD=1

test -r ${SC_CONF:="/etc/${CURRENT_SCRIPT}.conf"} && . $SC_CONF

trap "{ echolog TERMINATED BY USER; echo; exit 5; }" SIGINT
trap "{ echolog SKIPPED BY USER; return 4; }" SIGQUIT

unalias -a &>/dev/null

##############################################################################
# General Function Definitions
##############################################################################

title() {
	echo "============================================================================="
	echo "                     Support Utilities - Supportconfig"
	echo "                          Script Version: $SVER"
	echo "                          Script Date: $SDATE"
	echo "============================================================================="
	echo
}

show_help() {
	echo " Usage: $CURRENT_SCRIPT [OPTION [OPTION ...]]"
	echo
	echo "  -h This screen"
	echo "  -A Activates all supportconfig functions with additional logging and full"
	echo "     rpm verification."
	echo "  -C Creates a new default $SC_CONF"
	echo "  -D Use defaults; ignore  $SC_CONF"
	echo "  -E <string> Contact email address"
	echo "  -F Display available supportconfig feature keywords (case-sensitive) used"
	echo "     with -i and -x"
	echo "  -G <gpg_uid> The GPG recipient's user ID used to encrypt the supportconfig tarball"
	echo "  -H <number> Limit number of included HA Policy engine files"
	echo "  -I <number> Default log file line count"
	echo "  -L Create a full file listing from '/'"
	echo "  -M <string> Contact terminal ID"
	echo "  -N <string> Contact name"
	echo "  -O <string> Contact company name"
	echo "  -P <string> Contact phone number"
	echo "  -Q Run in silent mode"
	echo "  -R <path> Log output directory"
	echo "  -S <number> Limit number of included SAR files"
	echo "  -T <seconds> Binary execution timeout"
	echo "  -U <URI string> Sets upload target URL and initiates an upload, supported"
	echo "                  services include: ftp, scp, http, https"
	echo "  -M <string> Contact store ID"
	echo "  -X <number> Max system logs line count"
	echo "  -b Screen buffer mode"
	echo "  -d Exclude detailed disk info and scans"
	echo "  -e Search root file system for eDirectory instances; -L implied. Be patient."
	echo "  -f From directory. Don't collect report files, just use files in that"
	echo "     directory."
	echo "  -g Use gzip instead of the default bzip2 compression."
	echo "  -i <keyword list>"
	echo "     Include keywords. A comma separated list of feature keywords that specify"
	echo "     which features to include. Use -F to see a list of valid keywords."
	echo "  -l Gathers additional rotated logs"
	echo "  -m Only gather a minimum amount of info: basic env, basic health, hardware,"
	echo "     rpm, messages, y2logs"
	echo "  -o Toggle listed features on or off"
	echo "  -p Disable all plugins"
	echo "  -q Add a uuid to the tar ball filename to ensure uniqueness"
	echo "  -r <srnum>"
	echo "     Includes the Novell $SRLEN digit service request number when uploading"
	echo "     the tar ball to Novell"
	echo "  -s Include full SLP service lists"
	echo "  -t Target directory. Just save log files here, do not create tarball."
	echo "  -u Upload the tar ball to the specified VAR_OPTION_UPLOAD_TARGET."
	echo "  -v Performs an rpm -V for each installed rpm  NOTE: This takes a long time"
	echo "     to complete"
	echo "  -x <keyword list>"
	echo "     Exclude keywords. A comma separated list of feature keywords that specify"
	echo "     which features to exclude. Use -F to see a list of valid keywords."
	echo "  -y Only gather the minimum y2log files."
	echo 
	echo "  Use Ctrl-\ to try and skip a function that is hanging."
	echo
	echo "-----------------------------------------------------------------------------"
	echo "  NOTE:"
	echo "  This tool will create a tar ball in the /var/log directory. Please attach"
	echo "  the log file tar ball to your open Service.  Request at the following URL:"
	echo "  https://secure-support.novell.com/eService_enu"
	echo 
	echo "  If you cannot attach the tar ball to the SR, then email it to the engineer."
	echo
	echo "  Please submit bug fixes or comments via:"
	echo "  http://en.opensuse.org/Supportutils#Reporting_Bugs"
	echo
	title
}

# Input: logfilename logfiles...
conf_text_files() {
	LOGFILE=$LOG/$1
	shift
	for CONF in $@
	do
		echo "#==[ Configuration File ]===========================#" >> $LOGFILE
		if [ -f $CONF ]; then
			echo "# $CONF" >> $LOGFILE
			TEXTFILE=$(file -L $CONF | egrep "text|empty|XML")
			if [ -z "$TEXTFILE" ]; then
				echo "file $(file -L $CONF)" >> $LOGFILE
				echo "ERROR: Not a normal text file, excluding it." >> $LOGFILE
			else
				if (( ADD_OPTION_LOGS )); then
					sed -e 's/
//g' $CONF >> $LOGFILE 2>> $LOG/$CSFILE
				else
					sed -e '/^[[:space:]]*#/d' -e '/^[[:space:]]*;/d' -e '/^[[:space:]]*\/\//d' -e 's/
//g' -e '/^$/d' $CONF >> $LOGFILE 2>> $LOG/$CSFILE
				fi
			fi
			echo >> $LOGFILE
		else
			echo "# $CONF - File not found" >> $LOGFILE
		fi
		echo >> $LOGFILE
	done
}

# Input: logfilename logfiles...
conf_files() {
	LOGFILE=$LOG/$1
	shift
	for CONF in $@
	do
		echo "#==[ Configuration File ]===========================#" >> $LOGFILE
		if [ -f $CONF ]; then
			echo "# $CONF" >> $LOGFILE
			if (( ADD_OPTION_LOGS )); then
				sed -e 's/
//g' $CONF >> $LOGFILE 2>> $LOG/$CSFILE
			else
				sed -e '/^[[:space:]]*#/d' -e '/^[[:space:]]*;/d' -e '/^[[:space:]]*\/\//d' -e 's/
//g' -e '/^$/d' $CONF >> $LOGFILE 2>> $LOG/$CSFILE
			fi
			echo >> $LOGFILE
		else
			echo "# $CONF - File not found" >> $LOGFILE
		fi
		echo >> $LOGFILE
	done
}

# Input: logfilename lines logfiles...
# If lines = 0, includes the entire log file
log_files() {
	LOGFILE=$LOG/$1
	shift
	LOGLINES=$1
	shift
	for CONF in $@
	do
		BAD_FILE=$(echo $CONF | egrep "tbz$|bz2$|gz$|zip$")
		if [ -n "$BAD_FILE" ]; then
			continue
		fi
		echo "#==[ Log File ]=====================================#" >> $LOGFILE
		if [ -f $CONF ]; then
			if [ $LOGLINES -eq 0 ]; then
				echo "# $CONF" >> $LOGFILE
				sed -e 's/
//g' $CONF >> $LOGFILE
			else
				echo "# $CONF - Last $LOGLINES Lines" >> $LOGFILE
				tail -$LOGLINES $CONF | sed -e 's/
//g' >> $LOGFILE
			fi
			echo >> $LOGFILE
		else
			echo "# $CONF - File not found" >> $LOGFILE
		fi
		echo >> $LOGFILE
	done
}

grep_log_files() {
	SKEY=$1
	shift
	LOGFILE=$LOG/$1
	shift
	LOGLINES=$1
	shift
	for CONF in $@
	do
		echo "#==[ Log File ]=====================================#" >> $LOGFILE
		if [ -f $CONF ]; then
			if [ $LOGLINES -eq 0 ]; then
				echo "# grep -i $SKEY $CONF" >> $LOGFILE
				grep -i $SKEY $CONF | sed -e 's/
//g' >> $LOGFILE
			else
				echo "# grep -i $SKEY $CONF - Last $LOGLINES Lines" >> $LOGFILE
				grep -i $SKEY $CONF | tail -$LOGLINES | sed -e 's/
//g' >> $LOGFILE
			fi
			echo >> $LOGFILE
		else
			echo "# $CONF - File not found" >> $LOGFILE
		fi
		echo >> $LOGFILE
	done
}

# Input: logfilename "text"
log_write() {
	LOGFILE=$LOG/$1
	shift
	echo "$@" >> $LOGFILE
}

echolog() {
	CSLOGFILE=$LOG/${CSFILE}
	if (( $VAR_OPTION_SILENT )); then
		echo "$@" >> $CSLOGFILE
	else
		if (( $VAR_OPTION_SBM )); then
			echo "$@" >> $CSLOGFILE
		else
			echo "$@" | tee -a $CSLOGFILE
		fi
	fi
}

echonlog() {
	CSLOGFILE=$LOG/${CSFILE}
	if (( $VAR_OPTION_SILENT )); then
		printf "%s " "$@" >> $CSLOGFILE
	else
		if (( $VAR_OPTION_SBM )); then
			printf "%s " "$@" >> $CSLOGFILE
		else
			printf "%s " "$@" | tee -a $CSLOGFILE
		fi
	fi
}

timed_progress() {
	CSLOGFILE=$LOG/${CSFILE}
	if (( $VAR_OPTION_SILENT )); then
		printf "." >> $CSLOGFILE
	else
		if (( $VAR_OPTION_SBM )); then
			printf "." >> $CSLOGFILE
		else
			printf "." | tee -a $CSLOGFILE
		fi
	fi
}

printlog() {
	CSLOGFILE=$LOG/${CSFILE}
	SMB_OVERIDE=0
	if [ "$1" = "-b" ]; then
		SMB_OVERIDE=1
		shift
	fi
	if (( $VAR_OPTION_SILENT )); then
		printf "  %-45s" "$@" >> $CSLOGFILE
	else
		if (( $VAR_OPTION_SBM )) || (( $SMB_OVERIDE )); then
			echo "$@"
			printf "  %-45s" "$@" >> $CSLOGFILE
		else
			printf "  %-45s" "$@" | tee -a $CSLOGFILE
		fi
	fi
}

printvrpmlog() {
	CSLOGFILE=$LOG/${CSFILE}
	test $VAR_OPTION_SILENT -gt 0 && printf "  %-40s %12s ... " "$1" "$2" >> $CSLOGFILE || printf "  %-40s %12s ... " "$1" "$2" | tee -a $CSLOGFILE
}

# Input: logfilename command
log_cmd() {
	EXIT_STATUS=0
	LOGFILE=$LOG/$1
	shift
	CMDLINE_ORIG="$@"
	CMDBIN=$(echo $CMDLINE_ORIG | awk '{print $1}')
	CMD=$(\which $CMDBIN 2>/dev/null | awk '{print $1}')
	echo "#==[ Command ]======================================#" >> $LOGFILE
	if [ -x "$CMD" ]; then
		CMDLINE=$(echo $CMDLINE_ORIG | sed -e "s!${CMDBIN}!${CMD}!")
		echo "# $CMDLINE" >> $LOGFILE
		echo "$CMDLINE" | bash  >> $LOGFILE 2>&1
		EXIT_STATUS=$?
	else
		echo "# $CMDLINE_ORIG" >> $LOGFILE
		echo "ERROR: Command not found or not executible" >> $LOGFILE
		EXIT_STATUS=1
	fi
	echo >> $LOGFILE
	return $EXIT_STATUS
}

# Input: logfilename command
timed_log_cmd() {
	EXIT_STATUS=0
	TIMEOUT_PROGRESS=30
	LOGFILE=$LOG/$1
	shift
	CMDLINE_ORIG="$@"
	CMDBIN=$(echo $CMDLINE_ORIG | awk '{print $1}')
	SEMAPHORE_FILE="${LOGFILE}.$(basename ${CMDBIN}).$(date --utc +%s).SEMAPHORE"
	SEMAPHORE_BIN=${SEMAPHORE_FILE}.sh
	SEMAPHORE_LOG=${SEMAPHORE_FILE}.out
	SEMAPHORE_ERR=${SEMAPHORE_FILE}.returncode
	SEMAPHORE_PID=${SEMAPHORE_FILE}.pid
	CMD=$(\which $CMDBIN 2>/dev/null | awk '{print $1}')
	echo "#==[ Command ]======================================#" >> $LOGFILE
	if [ -x "$CMD" ]; then
		export CMDLINE=$(echo $CMDLINE_ORIG | sed -e "s!${CMDBIN}!${CMD}!")
		echo "# $CMDLINE" >> $LOGFILE
		echo "$SEMAPHORE_LOG" >> $LOGFILE
		LNUM=$(wc -l $LOGFILE | cut -d' ' -f1)
		# Create the temporary script that runs the app
cat << TEOF > $SEMAPHORE_BIN
echo \$\$ > $SEMAPHORE_PID
$CMDLINE >> $SEMAPHORE_LOG 2>&1
echo \$? > $SEMAPHORE_ERR
if [ -e $LOGFILE ]; then
 sed -i -e "\$(grep -n $SEMAPHORE_LOG $LOGFILE | cut -d: -f1)r $SEMAPHORE_LOG" $LOGFILE 2>/dev/null
 sed -i -e "/\$(basename $SEMAPHORE_LOG)/d" $LOGFILE 2>/dev/null
 rm -f $SEMAPHORE_LOG
fi
rm -f $SEMAPHORE_FILE 
TEOF
		TIME_CURRENT=0
		TIME_RCODE=0
		TIME_OUT=1
		touch $SEMAPHORE_FILE
		# Background the temporary script, it will delete the semaphore file when complete
		bash $SEMAPHORE_BIN &>/dev/null &
		while [ $TIME_CURRENT -lt $VAR_OPTION_BIN_TIMEOUT_SEC ]
		do
			if [ -e $SEMAPHORE_FILE ]; then
				# Still waiting on backgrounded binary
				sleep 1
				((TIME_CURRENT++))
				if [ $(( TIME_CURRENT % TIMEOUT_PROGRESS )) -eq 0 ]; then
					timed_progress
				fi
			else
				# Backgrounded binary completed
				TIME_CURRENT=$(( VAR_OPTION_BIN_TIMEOUT_SEC + 1 ))
				TIME_OUT=0
				rm -f $SEMAPHORE_BIN
				rm -f $SEMAPHORE_PID
				if [ -e $SEMAPHORE_ERR ]; then
					TIME_RCODE=$(< $SEMAPHORE_ERR)
					rm -f $SEMAPHORE_ERR
				fi
			fi
		done
		if (( TIME_OUT )); then
			echonlog "$CMDLINE_ORIG - Timed Out,"
			echo >> $LOGFILE
			echo "# ERROR: Command did not complete within the timeout period." >> $LOGFILE
			ps -eaf | grep $(cat $SEMAPHORE_PID) | grep -v grep >> $LOGFILE
			echo >> $LOGFILE
		fi
	else
		echo "# $CMDLINE_ORIG" >> $LOGFILE
		echo "ERROR: Command not found or not executible" >> $LOGFILE
		EXIT_STATUS=1
	fi
	echo >> $LOGFILE
	EXIT_STATUS=$(( EXIT_STATUS + TIME_OUT + TIME_RCODE ))
	return $EXIT_STATUS
}

# Input: logfilename command
log_icmd() {
	LOGFILE=$LOG/$1
	shift
	CMDLINE="$@"
	echo "#==[ Command ]======================================#" >> $LOGFILE
	echo "# $CMDLINE" >> $LOGFILE
	$CMDLINE >> $LOGFILE 2>&1
	echo >> $LOGFILE
}

# Input: logfilename rpm
# Assumes the rpm is installed and $LOG/$RPMFILE has been created
rpm_verify() {
	RPMPATH=$LOG/$RPMFILE
	LOGFILE=$LOG/$1
	INPUT_RPM=$2
	echo "#==[ Verification ]=================================#" >> $LOGFILE
	if rpm -q $INPUT_RPM &>/dev/null
	then
		for RPM in $(rpm -q $INPUT_RPM)
		do
			echo "# rpm -V $RPM" >> $LOGFILE
			rpm -V $RPM >> $LOGFILE 2>&1
			ERR=$?
			if [ $ERR -gt 0 ]; then
				echo "# Verification Status: Differences Found" >> $LOGFILE
			else
				echo "# Verification Status: Passed" >> $LOGFILE
			fi
			echo >> $LOGFILE
		done
		#cat $RPMPATH | grep "^$INPUT_RPM " >> $LOGFILE
		#echo >> $LOGFILE
		return 0
	else
		echo "# RPM Not Installed: $INPUT_RPM" >> $LOGFILE
		echo >> $LOGFILE
		return 1
	fi
}

gen_sysconfig() {
	echo "####################################" > $SC_CONF
	echo "# Default Options" >> $SC_CONF
	echo "####################################" >> $SC_CONF
	for i in OPTION ADD_OPTION VAR_OPTION
	do
		grep "^${i}_" $0 | sort >> $SC_CONF
		echo >> $SC_CONF
	done
	echo
	return 0
}

log_options() {
	LOGFILE=$LOG/${CSFILE}
	conf_files ${CSFILE} $SC_CONF
	echo >> $LOGFILE
	echo "####################################" >> $LOGFILE
	echo "# Options Used" >> $LOGFILE
	echo "####################################" >> $LOGFILE
	for SRCH in OPTION_ ADD_OPTION_
	do
		for i in $(grep ^$SRCH $0 | cut -d= -f1 | sort)
		do
			printf "%-25s = %s\n" "$i" "$((i))" >> $LOGFILE
			continue

			if [ $((i)) -eq 0 ]; then
				printf "%-25s = \n" "$i" >> $LOGFILE
			else
				printf "%-25s = %s\n" "$i" "$((i))" >> $LOGFILE
			fi
		done
		echo >> $LOGFILE
	done
	# TODO
	# add VAR_OPTION_ parameters
}

check_service() {
	LOGFILE=$LOG/$1
	BASEFILE=$1
	SERVICE_NAME=$2
	log_cmd $BASEFILE "chkconfig $SERVICE_NAME --list"
	log_cmd $BASEFILE "/etc/init.d/$SERVICE_NAME status"
	return $?
}

get_customer_info() {
	INFOLOG=$1
	LINE_ADDED=0
	test -n "$VAR_OPTION_CONTACT_COMPANY" && 		{ log_write $INFOLOG "Company:     $VAR_OPTION_CONTACT_COMPANY"; ((LINE_ADDED++)); }
	test -n "$VAR_OPTION_CONTACT_STOREID" && 		{ log_write $INFOLOG "Store ID:    $VAR_OPTION_CONTACT_STOREID"; ((LINE_ADDED++)); }
	test -n "$VAR_OPTION_CONTACT_TERMINALID" && 	{ log_write $INFOLOG "Terminal ID: $VAR_OPTION_CONTACT_TERMINALID"; ((LINE_ADDED++)); }
	test -n "$VAR_OPTION_CONTACT_NAME" && 			{ log_write $INFOLOG "Name:        $VAR_OPTION_CONTACT_NAME"; ((LINE_ADDED++)); }
	test -n "$VAR_OPTION_CONTACT_PHONE" && 		{ log_write $INFOLOG "Phone:       $VAR_OPTION_CONTACT_PHONE"; ((LINE_ADDED++)); }
	test -n "$VAR_OPTION_CONTACT_EMAIL" && 		{ log_write $INFOLOG "Email:       $VAR_OPTION_CONTACT_EMAIL"; ((LINE_ADDED++)); }
	test -n "$CONTACT_SRNUM" && 						{ log_write $INFOLOG "SR#:         $CONTACT_SRNUM"; ((LINE_ADDED++)); }
	if ((LINE_ADDED)); then log_write $INFOLOG; fi
}

basic_environment() {
	# This is a minimum required function, do not exclude
	printlog "Basic Environment..."
	test $MIN_OPTION_ENV -eq 0 && { echolog EXCLUDED; return 1; }
	get_customer_info $BASIC_ENVF
	log_cmd $BASIC_ENVF 'date'
	log_cmd $BASIC_ENVF 'uname -a'
	RELEASE=$(ls -1 /etc/*-release)
	conf_files $BASIC_ENVF $RELEASE
	if ! ((NSA_CHECK)); then
		if [ $SLES_VER -ge 110 ]; then
			if rpm -q suse-sam &>/dev/null; then
				log_cmd $BASIC_ENVF 'sam --no-header-sig-check --no-rpm-verify'
			fi
		else
			if rpm_verify $BASIC_ENVF SPident; then
				log_cmd $BASIC_ENVF 'SPident -vv'
			fi
		fi
		cat $LOG/$RPM_DIST_FILE >> $LOG/$BASIC_ENVF
		if rpm_verify $BASIC_ENVF SuSEfirewall2
		then
			log_write $BASIC_ENVF "#==[ Firewall Services ]============================#"
			for i in $(rpm -ql SuSEfirewall2 | grep init.d)
			do
				FSRV=$(basename $i)
				log_write $BASIC_ENVF "$(chkconfig $FSRV --list)"
			done
			IPBIN="/usr/sbin/iptables"
			if [ -x $IPBIN ]; then
				TOTAL_FIREWALL_RULES=0
				for TABLE in filter nat mangle raw
				do
					if grep iptable_$TABLE /proc/modules &>/dev/null
					then
						FIREWALL_RULES=$($IPBIN -t $TABLE -nL | sed -e '/^$/d' -e '/^Chain/d' -e '/^target/d' | wc -l)
						TOTAL_FIREWALL_RULES=$(( TOTAL_FIREWALL_RULES + FIREWALL_RULES ))
					fi
				done
				log_write $BASIC_ENVF
				log_write $BASIC_ENVF "$TOTAL_FIREWALL_RULES Active Firewall Rules"
				log_write $BASIC_ENVF
			fi
		fi
	fi
	echolog Done
}

basic_healthcheck() {
	# This is a minimum required function, do not exclude
	printlog "Basic Server Health Check..."
	test $MIN_OPTION_HC -eq 0 && { echolog EXCLUDED; return 1; }
	OF=basic-health-check.txt
	log_cmd $OF 'uptime'
	log_cmd $OF 'vmstat 1 4'
	test -x /usr/bin/mpstat && log_cmd $OF 'mpstat -P ALL 1 3'
	log_cmd $OF 'free -k'
	log_cmd $OF 'df -h'
	log_cmd $OF 'df -i'
	conf_files $OF '/proc/sys/kernel/tainted'
	TAINT=$(cat /proc/sys/kernel/tainted)
	TAINTED=0
	if [ ${#TAINT} -gt 1 ]; then
		TAINTED=1
	elif [ ${TAINT} -gt 0 ]; then
		TAINTED=1
	fi
	if (( TAINTED )); then
		# TAINT=$(( 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 + 256 ))
		# Refer to /usr/src/linux/include/linux/kernel.h and /usr/src/linux/kernel/panic.c (print_tainted function)
		TAINT_STRING=""
		case $SLES_VER in
		80|90)
		test $((TAINT & 1))   -ne 0 && TAINT_STRING="${TAINT_STRING}P" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 2))   -ne 0 && TAINT_STRING="${TAINT_STRING}F" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 4))   -ne 0 && TAINT_STRING="${TAINT_STRING}S" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 8))   -ne 0 && TAINT_STRING="${TAINT_STRING}R" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 16))  -ne 0 && TAINT_STRING="${TAINT_STRING}U" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 32))  -ne 0 && TAINT_STRING="${TAINT_STRING}X" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 64))  -ne 0 && TAINT_STRING="${TAINT_STRING}M" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 128)) -ne 0 && TAINT_STRING="${TAINT_STRING}B" || TAINT_STRING="${TAINT_STRING} "
		;;
		100)
		test $((TAINT & 1))   -ne 0 && TAINT_STRING="${TAINT_STRING}P" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 2))   -ne 0 && TAINT_STRING="${TAINT_STRING}F" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 4))   -ne 0 && TAINT_STRING="${TAINT_STRING}S" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 8))   -ne 0 && TAINT_STRING="${TAINT_STRING}R" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 16))  -ne 0 && TAINT_STRING="${TAINT_STRING}M" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 32))  -ne 0 && TAINT_STRING="${TAINT_STRING}B" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 64))  -ne 0 && TAINT_STRING="${TAINT_STRING}U" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 128)) -ne 0 && TAINT_STRING="${TAINT_STRING}X" || TAINT_STRING="${TAINT_STRING} "
		;;
		101)
		test $((TAINT & 1))   -ne 0 && TAINT_STRING="${TAINT_STRING}P" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 2))   -ne 0 && TAINT_STRING="${TAINT_STRING}F" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 4))   -ne 0 && TAINT_STRING="${TAINT_STRING}S" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 8))   -ne 0 && TAINT_STRING="${TAINT_STRING}R" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 16))  -ne 0 && TAINT_STRING="${TAINT_STRING}M" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 32))  -ne 0 && TAINT_STRING="${TAINT_STRING}B" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 64))  -ne 0 && TAINT_STRING="${TAINT_STRING}U" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 128)) -ne 0 && TAINT_STRING="${TAINT_STRING}N" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 256)) -ne 0 && TAINT_STRING="${TAINT_STRING}X" || TAINT_STRING="${TAINT_STRING} "
		;;
		110)
		test $((TAINT & 1))          -ne 0 && TAINT_STRING="${TAINT_STRING}P" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 2))          -ne 0 && TAINT_STRING="${TAINT_STRING}F" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 4))          -ne 0 && TAINT_STRING="${TAINT_STRING}S" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 8))          -ne 0 && TAINT_STRING="${TAINT_STRING}R" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 16))         -ne 0 && TAINT_STRING="${TAINT_STRING}M" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 32))         -ne 0 && TAINT_STRING="${TAINT_STRING}B" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 64))         -ne 0 && TAINT_STRING="${TAINT_STRING}U" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 128))        -ne 0 && TAINT_STRING="${TAINT_STRING}D" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 256))        -ne 0 && TAINT_STRING="${TAINT_STRING}A" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 512))        -ne 0 && TAINT_STRING="${TAINT_STRING}W" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 1024))       -ne 0 && TAINT_STRING="${TAINT_STRING}C" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 1073741824)) -ne 0 && TAINT_STRING="${TAINT_STRING}N" || TAINT_STRING="${TAINT_STRING} "
		test $((TAINT & 2147483648)) -ne 0 && TAINT_STRING="${TAINT_STRING}X" || TAINT_STRING="${TAINT_STRING} "
		;;
		esac
	
		log_write $OF "Kernel Status -- Tainted: $TAINT_STRING"
		case $SLES_VER in
		80|90)
		test $((TAINT & 1))   -ne 0 && log_write $OF "  TAINT: (P) Proprietary module has been loaded"
		test $((TAINT & 2))   -ne 0 && log_write $OF "  TAINT: (F) Module was forcibly loaded"
		test $((TAINT & 4))   -ne 0 && log_write $OF "  TAINT: (S) SMP with CPUs not designed for SMP"
		test $((TAINT & 8))   -ne 0 && log_write $OF "  TAINT: (R) Module was forcibly unloaded"
		test $((TAINT & 16))  -ne 0 && log_write $OF "  TAINT: (U) Unsupported modules loaded"
		test $((TAINT & 32))  -ne 0 && log_write $OF "  TAINT: (X) Modules with external support loaded"
		test $((TAINT & 64))  -ne 0 && log_write $OF "  TAINT: (M) Machine check event"
		test $((TAINT & 128)) -ne 0 && log_write $OF "  TAINT: (B) System has hit bad_page"
		;;
		100)
		test $((TAINT & 1))   -ne 0 && log_write $OF "  TAINT: (P) Proprietary module has been loaded"
		test $((TAINT & 2))   -ne 0 && log_write $OF "  TAINT: (F) Module was forcibly loaded"
		test $((TAINT & 4))   -ne 0 && log_write $OF "  TAINT: (S) SMP with CPUs not designed for SMP"
		test $((TAINT & 8))   -ne 0 && log_write $OF "  TAINT: (R) Module was forcibly unloaded"
		test $((TAINT & 16))  -ne 0 && log_write $OF "  TAINT: (M) Machine check event"
		test $((TAINT & 32))  -ne 0 && log_write $OF "  TAINT: (B) System has hit bad_page"
		test $((TAINT & 64))  -ne 0 && log_write $OF "  TAINT: (U) Unsupported modules loaded"
		test $((TAINT & 128)) -ne 0 && log_write $OF "  TAINT: (X) Modules with external support loaded"
		;;
		101)
		test $((TAINT & 1))   -ne 0 && log_write $OF "  TAINT: (P) Proprietary module has been loaded"
		test $((TAINT & 2))   -ne 0 && log_write $OF "  TAINT: (F) Module was forcibly loaded"
		test $((TAINT & 4))   -ne 0 && log_write $OF "  TAINT: (S) SMP with CPUs not designed for SMP"
		test $((TAINT & 8))   -ne 0 && log_write $OF "  TAINT: (R) Module was forcibly unloaded"
		test $((TAINT & 16))  -ne 0 && log_write $OF "  TAINT: (M) Machine check event"
		test $((TAINT & 32))  -ne 0 && log_write $OF "  TAINT: (B) System has hit bad_page"
		test $((TAINT & 64))  -ne 0 && log_write $OF "  TAINT: (U) Userspace-defined problems"
		test $((TAINT & 128)) -ne 0 && log_write $OF "  TAINT: (N) Unsupported modules loaded"
		test $((TAINT & 256)) -ne 0 && log_write $OF "  TAINT: (X) Modules with external support loaded"
		;;
		110)
		test $((TAINT & 1))          -ne 0 && log_write $OF "  TAINT: (P) Proprietary module has been loaded"
		test $((TAINT & 2))          -ne 0 && log_write $OF "  TAINT: (F) Module was forcibly loaded"
		test $((TAINT & 4))          -ne 0 && log_write $OF "  TAINT: (S) SMP with CPUs not designed for SMP"
		test $((TAINT & 8))          -ne 0 && log_write $OF "  TAINT: (R) Module was forcibly unloaded"
		test $((TAINT & 16))         -ne 0 && log_write $OF "  TAINT: (M) Machine check event"
		test $((TAINT & 32))         -ne 0 && log_write $OF "  TAINT: (B) System has hit bad_page"
		test $((TAINT & 64))         -ne 0 && log_write $OF "  TAINT: (U) Userspace-defined problems"
		test $((TAINT & 128))        -ne 0 && log_write $OF "  TAINT: (D) Imminent kernel function termination"
		test $((TAINT & 256))        -ne 0 && log_write $OF "  TAINT: (A) ACPI table overridden"
		test $((TAINT & 512))        -ne 0 && log_write $OF "  TAINT: (W) Taint on warning"
		test $((TAINT & 1024))       -ne 0 && log_write $OF "  TAINT: (C) Modules from drivers/staging are loaded"
		test $((TAINT & 1073741824)) -ne 0 && log_write $OF "  TAINT: (N) Unsupported modules loaded"
		test $((TAINT & 2147483648)) -ne 0 && log_write $OF "  TAINT: (X) Modules with external support loaded"
		;;
		esac

		log_write $OF
		for MODULE in $(cat /proc/modules | awk '{print $1}')
		do
			LIST_MODULE=0
			modinfo -l $MODULE &>/dev/null
			if [ $? -gt 0 ]; then
				log_write $OF "$(printf "%-25s %-25s %-25s" module=$MODULE ERROR "Module info unavailable")"
			else
				LIC=$(modinfo -l $MODULE | head -1)
				SUP=$(modinfo -F supported $MODULE | head -1)
				test -z "$LIC" && LIC=None
				test -z "$SUP" && SUP=no
				GPLTEST=$(echo $LIC | grep GPL)
				test -z "$GPLTEST" && ((LIST_MODULE++))
				test "$LIC" != "GPL" && ((LIST_MODULE++))
				test "$SUP" != "yes" && ((LIST_MODULE++))
				test $LIST_MODULE -gt 0 && log_write $OF "$(printf "%-25s %-25s %-25s" module=$MODULE license=$LIC supported=$SUP)"
			fi
		done
	else
		log_write $OF "Kernel Status -- Not Tainted"
	fi
	log_write $OF

	PSPTMP=$(mktemp $LOG/psout.XXXXXXXX)
	AARPTMP=$(mktemp $LOG/security-aareject.XXXXXXXX)
	PSTMP=$(basename $PSPTMP)
	AARTMP=$(basename $AARPTMP)

	log_cmd $PSTMP 'ps axwwo user,pid,ppid,%cpu,%mem,vsz,rss,stat,time,cmd'

	log_write $OF "#==[ Checking Health of Processes ]=================#"
	log_write $OF "# egrep \" D| Z\" $PSPTMP"
	log_write $OF "$(grep -v ^# "$PSPTMP" | egrep " D| Z")"

	TOPTMP=$(mktemp $LOG/top.XXXXXXXX)
	log_write $OF
	log_write $OF "#==[ Top 10 CPU Processes ]=========================#"
	ps axwwo %cpu,pid,user,cmd | sort -k 1 -r | head -11 | sed -e '/^%/d' > $TOPTMP
	log_write $OF "%CPU   PID USER     CMD"
	log_write $OF "$(< $TOPTMP)"
	log_write $OF

	log_write $OF "#==[ Top 10 Memory Processes ]======================#"
	ps axwwo %mem,pid,user,cmd | sort -k 1 -r | head -11 | sed -e '/^%/d' > $TOPTMP
	log_write $OF "%MEM   PID USER     CMD"
	log_write $OF "$(< $TOPTMP)"
	log_write $OF
	rm -f $TOPTMP

	if rpm -q subdomain-parser &>/dev/null; then
		# apparmor for SLES9
		log_write $AARTMP "#==[ AppArmor REJECT Messages ]=====================#"
		log_write $AARTMP "$(chkconfig boot.subdomain)"
		AAREJECT=$(grep 'SubDomain: REJECTING' /var/log/messages | wc -l)
		test -z "$AAREJECT" && AAREJECT=0
		if lsmod | grep subdomain &>/dev/null; then
			AALOADED="Loaded"
		else
			AALOADED="Not Loaded"
		fi
		log_write $AARTMP
		log_write $AARTMP "${AAREJECT} Reject Messages, AppArmor Module: $AALOADED"
		log_write $AARTMP
	elif rpm -q apparmor-parser &>/dev/null; then
		# apparmor for SLES10
		log_write $AARTMP "#==[ AppArmor REJECT Messages ]=====================#"
		log_write $AARTMP "$(chkconfig -l boot.apparmor)"
		APP_AUDIT_LOG="/var/log/audit/audit.log"
		test -f $APP_AUDIT_LOG && AAREJECT=$(grep 'REJECTING' $APP_AUDIT_LOG | wc -l) || AAREJECT=0
		test -z "$AAREJECT" && AAREJECT=0
		if lsmod | grep apparmor &>/dev/null; then
			AALOADED="Loaded"
		else
			AALOADED="Not Loaded"
		fi
		log_write $AARTMP
		log_write $AARTMP "${AAREJECT} Reject Messages, AppArmor Module: $AALOADED"
		log_write $AARTMP
	fi
	test -f $AARPTMP && cat $AARPTMP >> $LOG/$OF

	cat $PSPTMP >> $LOG/$OF
	rm $PSPTMP

	echolog Done
}

rpm_info() {
	# This is a minimum required function, do not exclude
	printlog "RPM Database..."
	test $MIN_OPTION_RPM -eq 0 && { echolog EXCLUDED; return 1; }
	if ((NSA_CHECK)); then
		log_write $RPMFILE "#==[ NSA Check ]====================================#"
		log_write $RPMFILE '# rpm -qa --queryformat "%-35{NAME} %-35{DISTRIBUTION} %{VERSION}-%{RELEASE}\n"'
		rpm -qa --queryformat "%-35{NAME} %-35{DISTRIBUTION} %{VERSION}-%{RELEASE}\n" >> $LOGFILE 2>&1
	else
		# rpm list of all files
		LOGFILE=$LOG/$RPM_DIST_FILE
		log_cmd $RPM_DIST_FILE 'rpm -qa --queryformat "%{DISTRIBUTION}\n" | sort | uniq'
		rpm -qa 2>/dev/null | sort > $LOG/$RPM_QA_FILE
		cat $LOG/$RPM_DIST_FILE >> $LOG/$RPMFILE
		log_write $RPMFILE "#==[ Command ]======================================#"
		log_write $RPMFILE '# rpm -qa --queryformat "%-35{NAME} %-35{DISTRIBUTION} %{VERSION}-%{RELEASE}\n" | sort -k 1,2 -t " " -i'
		printf "%-35s %-35s %s\n" NAME DISTRIBUTION VERSION >> $LOGFILE
		rpm -qa --queryformat "%-35{NAME} %-35{DISTRIBUTION} %{VERSION}-%{RELEASE}\n" | sort -k 1,2 -t " " -i >> $LOGFILE 2>&1
		log_write $RPMFILE
		log_cmd $RPMFILE "rpm -qa --last"
	fi
	echolog Done
}

basic_report() {
	printlog "Basic Health Report..."
	test $OPTION_HCREPORT -eq 0 && { echolog Excluded; return 1; }
	OF=basic-health-report.txt
	cd $LOG
	log_cmd $OF 'schealth -q'
	echolog Done
}

	
# Run basic_healthcheck first TAINT & TAINT_STRING must be defined first
module_info() {
	printlog "System Modules..."
	test $OPTION_MOD -eq 0 && { echolog Excluded; return 1; }
	OF=modules.txt
	LOGFILE=$LOG/$OF
	log_cmd $OF 'lsmod'
	for MODULE in $(cat /proc/modules | awk '{print $1}')
	do
		log_cmd $OF "modinfo $MODULE"
	done
	conf_files $OF /lib/modules/$(uname -r)/modules.dep
	FILES=$(grep ^include /etc/modprobe.conf | awk '{print $2}')
	conf_files $OF /etc/modprobe.conf $FILES
	echolog Done
}

messages_file() {
	# This is a minimum required function, do not exclude
	printlog "System Logs..."
	test $MIN_OPTION_SYSLOGS -eq 0 && { echolog EXCLUDED; return 1; }
	OF=messages.txt
	if [ $ADD_OPTION_LOGS -eq 1 ]; then
		log_files $OF 0 /var/log/warn /var/log/messages /var/log/localmessages
	else
		log_files $OF $VAR_OPTION_LINE_COUNT /var/log/warn
		for LOGFILE in /var/log/localmessages /var/log/messages
		do
			if [ -e $LOGFILE ]; then
				MSGSIZE=$(stat -c%s $LOGFILE)
				if [ $MSGSIZE -gt $VAR_OPTION_MSG_MAXSIZE ]; then
					log_files $OF 5000 $LOGFILE
				else
					log_files $OF 0 $LOGFILE
				fi
			fi
		done
	fi
	echolog Done
}

yast_files() {
	# This is a minimum required function, do not exclude
	printlog "YaST Files..."
	test $MIN_OPTION_YAST -eq 0 && { echolog EXCLUDED; return 1; }
	hppsp_info
	# YaST files
	OF=y2log.txt
	rpm_verify $OF yast2-packager
	rpm_verify $OF yast2-packagemanager
	test -d /var/log/YaST2 && FILES=$(find /var/log/YaST2/ -type f) || unset FILES
	conf_files $OF /etc/youservers /etc/sysconfig/onlineupdate /etc/wgetrc
	test $ADD_OPTION_MINYAST -eq 0 && conf_files $OF $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	conf_files $OF /root/autoinst.xml /var/adm/autoinstall/cache/installedSystem.xml
	echolog Done
}

boot_info() {
	printlog "Boot Files..."
	test $OPTION_BOOT -eq 0 && { echolog Excluded; return 1; }
	OF=boot.txt
	log_cmd $OF "uname -a"
	KERNELS=$(cat $LOG/$RPMFILE | grep 'kernel-' | awk '{print $1}')
	for KERNEL in $KERNELS
	do
		rpm_verify $OF $KERNEL
	done
	if rpm -q grub &> /dev/null; then
		rpm_verify $OF grub
		conf_files $OF /etc/grub.conf /boot/grub/menu.lst /boot/grub/device.map
	fi
	if rpm -q lilo &> /dev/null; then
		rpm_verify $OF lilo
		conf_files $OF /etc/lilo.conf /etc/yaboot.conf
	fi
	if rpm -q elilo &> /dev/null; then
		rpm_verify $OF elilo
		log_cmd $OF 'ls -l /usr/lib/elilo'
		FILES="$(find /boot/ -type f | grep elilo.conf) $(find /etc/ -type f | grep elilo.conf)"
		conf_files $OF $FILES
		log_cmd $OF "cksum /usr/lib/elilo/elilo.efi $(find /boot/ -type f | grep elilo.efi)"
	fi
	if rpm -q z390-tools &> /dev/null; then
		conf_files $OF /etc/zipl.conf
	fi

	test -e /usr/sbin/mcelog && log_cmd $OF "/usr/sbin/mcelog --ignorenodev --filter --dmi"
	test -s /var/log/mcelog && conf_files $OF /var/log/mcelog
	log_cmd $OF 'last -xF | egrep "reboot|shutdown|runlevel|system"'

	conf_files $OF /proc/cmdline /etc/sysconfig/kernel /etc/inittab /etc/init.d/boot.local /etc/init.d/before.local /etc/init.d/after.local

	log_cmd $OF 'ls -lR /boot'
	conf_files $OF /var/log/boot.msg /var/log/boot.omsg
	log_cmd $OF 'dmesg'
	echolog Done
}

smt_info() {
	printlog "SMT..."
	test $OPTION_SMT -eq 0 && { echolog Excluded; return 1; }
	OF=smt.txt
	if rpm_verify $OF smt; then
		check_service $OF smt
		CONF=/etc/smt.conf
		conf_files $OF /etc/smt.conf
		sed -i -e 's/^NUPass=[[:alnum:]]*/NUPass=*REMOVED*/;s/^pass=[[:alnum:]]*/pass=*REMOVED*/;s/^ProxyUser=[[:alnum:]]*/ProxyUser=*REMOVED*/;s/^mailServerPassword=[[:alnum:]]*/mailServerPassword=*REMOVED*/;s/^credentials=[[:alnum:]]*/credentials=*REMOVED*/' $LOG/$OF
		FILES=$(find /etc/smt.d/ -type f)
		conf_files $OF $FILES
		log_cmd $OF 'smt-catalogs -o'
		log_cmd $OF 'smt-list-registrations'
		log_cmd $OF 'smt-list-products'
		FILES=$(find /var/log/ -type f | grep smt- | grep log$)
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

update_info() {
	printlog "Updates..."
	test $OPTION_UP -eq 0 && { echolog Excluded; return 1; }
	OF=updates.txt
	SKIP=0
	if [ $SLES_VER -lt 101 ] && rpm_verify $OF rug
	then
		rpm_verify $OF lsb
		RUG_VER=$(rpm -q rug | tail -1 | cut -d- -f2 | cut -d\. -f1)
		log_cmd $OF 'date'
		if [ $RUG_VER -gt 6 ]; then
			if timed_log_cmd $OF 'rug prefs'; then
				timed_log_cmd $OF 'rug --no-abbrev sl'
				timed_log_cmd $OF 'rug ca'
				log_cmd $OF 'installation_sources -s'
				timed_log_cmd $OF 'rug lu'
				timed_log_cmd $OF 'rug pch'
			fi
		elif [ $RUG_VER -gt 1 ]; then
			if timed_log_cmd $OF 'rug prefs'; then
				timed_log_cmd $OF 'rug --no-abbrev sl'
				timed_log_cmd $OF 'rug ch'
				timed_log_cmd $OF 'rug pl'
			fi
		fi
		FILES="/var/log/zmd-backend.log"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	else
		((SKIP++))
	fi
	if [ $SLES_VER -ge 101 ] && rpm_verify $OF zypper; then
		log_cmd $OF 'date'
		if timed_log_cmd $OF 'zypper --non-interactive --no-gpg-checks service-list'; then
			log_cmd $OF 'installation_sources -s'
			timed_log_cmd $OF 'zypper --non-interactive --no-gpg-checks patch-check'
			timed_log_cmd $OF 'zypper --non-interactive --no-gpg-checks patches'
		fi
		rpm_verify $OF lsb
		conf_files $OF /etc/zypp/zypp.conf
		FILES=$(find /var/log/ -type f | grep zypp)
		if [ $ADD_OPTION_LOGS -eq 1 ]; then
			log_files $OF 0 $FILES
		else
			log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		fi
	else
		((SKIP++))
	fi
	if rpm_verify $OF suseRegister; then
		[ $SLES_VER -lt 101 ] && log_cmd $OF 'chkconfig suseRegister --list'
		FILES='/etc/suseRegister.conf /etc/sysconfig/suse_register'
		conf_files $OF $FILES
		log_files $OF 0 '/root/.suse_register.log'
	fi
	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

update_d_info() {
	printlog "Updates Daemon..."
	test $OPTION_UPD -eq 0 && { echolog Excluded; return 1; }
	OF=updates-daemon.txt
	SKIP=0
	if rpm_verify $OF rcd
	then
		RCD_HISTORY="/var/log/rcd/rcd-package-history"
		check_service $OF rcd
		log_cmd $OF "grep |upgrade| $RCD_HISTORY"

		FILES="/var/log/rcd/rcd-messages $RCD_HISTORY"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	else
		((SKIP++))
	fi

	if rpm_verify $OF zmd
	then
		check_service $OF novell-zmd
		conf_files $OF /etc/zmd/zmd.conf /etc/zmd/deviceid /etc/zmd/secret /etc/sysconfig/zmd
		for i in libzypp libzypp-zmd-backend
		do
			if rpm -q $i &> /dev/null; then
				QPBIN=$(rpm -ql $i | grep query-pool)
				test -n "$QPBIN" && log_cmd $OF "$QPBIN products @system"
			fi
		done
		if [ $ADD_OPTION_LOGS -eq 1 ]; then
			FILES="/var/log/zmd-messages.log.*"
			log_files $OF 0 $FILES
		else
			FILES="/var/log/zmd-messages.log"
			log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		fi
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	else
		((SKIP++))
	fi

	if rpm -q curl &>/dev/null; then
		log_cmd $OF 'curl --verbose --digest --remote-time --fail -u $(cat /etc/zmd/deviceid):$(cat /etc/zmd/secret) -O "https://nu.novell.com/repo/repoindex.xml" 2>curl.log'
		conf_files $OF repoindex.xml curl.log
		rm -f repoindex.xml curl.log
	else
		((SKIP++))
	fi
	test $SKIP -lt 3 && echolog Done || echolog Skipped
}

novell_edir_info() {
	# Call fslist_info first in case -e was selected
	printlog "Novell eDirectory..."
	test $OPTION_EDIR -eq 0 && { echolog Excluded; return 1; }
	echonlog "Please Wait..."
	OF=novell-edir.txt
	SKIP=0
	RPM_NAME=NDSserv
	if rpm_verify $OF $RPM_NAME
	then
		NDSDIR=/var/nds
		DIBDIR=$NDSDIR/dib
		if [ -f /opt/novell/eDirectory/sbin/ndsd ]; then
			log_cmd $OF 'file /opt/novell/eDirectory/sbin/ndsd'
		else
			log_cmd $OF 'file /usr/sbin/ndsd'
		fi
		log_cmd $OF '/usr/sbin/ndsd --version'
		log_cmd $OF 'ndsstat'
		log_cmd $OF 'ndsstat -s'
		log_cmd $OF 'ndsstat -r'
		log_cmd $OF 'ndsrepair -T'
		sleep 1
		log_cmd $OF 'ndsrepair -E'
		log_cmd $OF 'ndstrace -c modules'
		log_cmd $OF 'ndstrace -c threads'
		log_cmd $OF 'ndsconfig get'
		log_cmd $OF "ls -l $DIBDIR"
		conf_files $OF $DIBDIR/_ndsdb.ini /etc/hosts.nds
		test -d $NDSDIR && FILES=$(find ${NDSDIR}/ -type f -maxdepth 1 -name \*log) || FILES=""
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	else
		((SKIP++))
	fi

	# Search for eDirectory instances
	NDS_INSTANCES=0
	NDS_CONFILES=""
	NDSPATH_BIN=/opt/novell/eDirectory/bin/ndspath
	SRCH_FILE=$LOG/$FSLIST_FILE
	rpm_verify $OF novell-NDSserv

	INST_DIR='/etc/opt/novell/eDirectory/conf/.edir'
	test -d $INST_DIR && NDS_DEF_INST="$(find ${INST_DIR}/ -type f)" || NDS_DEF_INST=""
	if [ -f $SRCH_FILE ]; then
		echonlog Searching
		NDS_INST_FILES="$(grep instances $SRCH_FILE | grep eDirectory)"
		test -e $NDSPATH_BIN || NDSPATH_BIN="$(grep /ndspath$ $SRCH_FILE | tail -1)"
	else
		if [ -x /usr/bin/locate ]; then
			NDS_INST_FILES=$(locate instances 2>/dev/null | grep eDirectory)
			test -e $NDSPATH_BIN || NDSPATH_BIN="$(locate /ndspath$ 2>/dev/null | tail -1)"
		else
			if [ -n "$NDS_DEF_INST" ]; then
				NDS_INST_FILES=$NDS_DEF_INST
			fi
		fi
	fi

	for INST_FILE in $NDS_INST_FILES
	do
		NDS_CONFILES="$NDS_CONFILES $(cat $INST_FILE)"
	done

	NDS_INSTANCES=$(echo $NDS_CONFILES | wc -w)
	test -n "$NDSPATH_BIN" -a -e "$NDSPATH_BIN" && . $NDSPATH_BIN


	if [ $NDS_INSTANCES -gt 0 ]; then
		conf_files $OF $NDS_INST_FILES /etc/init.d/pre_ndsd* /etc/init.d/post_ndsd*
		PATH_WITH_EDIR=$PATH
		export PATH_WITH_EDIR
		CUR_INST=0
		INST_FOUND=$NDS_INSTANCES
		for NDS_CONFILE in $NDS_CONFILES
		do
			log_write $OF "#####################################################################"
			log_write $OF "# eDirectory Instance $((++CUR_INST)) of $NDS_INSTANCES: $NDS_CONFILE"
			log_write $OF "#####################################################################"
			log_write $OF
			echonlog $((INST_FOUND--))
			conf_files $OF $NDS_CONFILE
			NDSDIR=$(grep n4u.server.log-file $NDS_CONFILE | cut -d= -f2)
			NDSDIR=$(dirname $NDSDIR)
			DIBDIR=$(grep n4u.nds.dibdir $NDS_CONFILE | cut -d= -f2)
			log_cmd $OF "ndsd --version --config-file $NDS_CONFILE"
			log_cmd $OF "ndsstat --config-file $NDS_CONFILE"
			log_cmd $OF "ndsstat -s --config-file $NDS_CONFILE"
			log_cmd $OF "ndsstat -r --config-file $NDS_CONFILE"
			log_cmd $OF "ndsrepair -T --config-file $NDS_CONFILE"
			sleep 1
			log_cmd $OF "ndsrepair -E --config-file $NDS_CONFILE"
			log_cmd $OF "ndstrace -c modules --config-file $NDS_CONFILE"
			log_cmd $OF "ndstrace -c threads --config-file $NDS_CONFILE"
			log_cmd $OF "ndsconfig get --config-file $NDS_CONFILE"
			log_cmd $OF "ls -l $DIBDIR"
			conf_files $OF $DIBDIR/_ndsdb.ini /etc/hosts.nds
			test -d $NDSDIR && FILES=$(find ${NDSDIR}/ -maxdepth 1 -type f -name \*log) || FILES=""
			test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		done
	else
		((SKIP++))
	fi

	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

novell_ncp_info() {
	printlog "Novell NCP..."
	test $OPTION_NCP -eq 0 && { echolog Excluded; return 1; }
	OF=novell-ncp.txt
	if rpm_verify $OF novell-ncpserv
	then
		log_cmd $OF '/etc/init.d/ncp2nss status'
		conf_files $OF /etc/opt/novell/ncpserv.conf
		log_cmd $OF 'ncpcon version'
		log_cmd $OF 'ncpcon stats'
		log_cmd $OF 'ncpcon config'
		log_cmd $OF 'ncpcon connection'
		log_cmd $OF 'ncpcon volume'
		VOLUMES=$(ncpcon volume 2>/dev/null | sed -e '/^$/d' -e '/Mounted Volumes/d' -e '/volumes mounted/d' -e 's/^[[:space:]]*//')
		for VOLUME in $VOLUMES
		do
			log_cmd $OF "ncpcon volume $VOLUME"
		done
		test -d /var/opt/novell/log && FILES=$(find /var/opt/novell/log/ -type f | grep log) || FILES=""
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

novell_nss_info() {
	printlog "Novell NSS..."
	test $OPTION_NSS -eq 0 && { echolog Excluded; return 1; }
	OF=novell-nss.txt
	PATH=$PATH_ORIG
	export PATH
	if rpm_verify $OF novell-nss
	then
		LOGFILE=$LOG/$OF
		log_cmd $OF 'nss /pools'
		echo "# mount | grep -i nss" >> $LOGFILE
		mount | grep -i nss >> $LOGFILE
		echo >> $LOGFILE
		log_cmd $OF "echo -e \"nss /volumes\nexit\n\" | nsscon | sed -e 's/\x1b\[[^m]*m//g;s/\[[^c]//g;s/\x1b\J//g'"
		for i in /etc/opt/novell/nss/nssstart.cfg /opt/novell/nss/conf/nssstart.cfg
		do
			test -e $i && conf_files $OF $i
		done
		if [ -d /_admin/Manage_NSS ]; then
			NSS_DIR="/_admin/Manage_NSS"
		else
			NSS_DIR="/admin/Manage_NSS"
		fi
		FILES="$NSS_DIR/BufferCache.xml $NSS_DIR/FileStats.xml $NSS_DIR/NameCache.xml $NSS_DIR/ObjectCache.xml $NSS_DIR/GeneralStats.xml"
		conf_files $OF $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

novell_afp_info() {
	printlog "Novell AFP..."
	test $OPTION_AFP -eq 0 && { echolog Excluded; return 1; }
	OF=novell-afp.txt
	if rpm_verify $OF novell-afptcpd
	then
		check_service $OF novell-afptcpd
		RPMPATH=$LOG/$RPMFILE
		log_cmd $OF "egrep \"afp\" $RPMPATH"
		FILES="/etc/sysconfig/novell/afp /etc/ld.so.conf.d/novell-afptcpd.conf"
		conf_files $OF $FILES /etc/opt/novell/afptcpd/*conf
		test -d /var/opt/novell/log && FILES=$(find /var/log/afptcpd -type f | grep 'log$') || FILES=""
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		timed_log_cmd $OF 'ldapsearch -x -b cn=security objectclass=nspmPasswordPolicy'
		echolog Done
	else
		echolog Skipped
	fi
}

novell_cifs_info() {
	printlog "Novell CIFS..."
	test $OPTION_CIFS -eq 0 && { echolog Excluded; return 1; }
	OF=novell-cifs.txt
	if rpm_verify $OF novell-cifs
	then
		check_service $OF novell-cifs
		RPMPATH=$LOG/$RPMFILE
		log_cmd $OF "egrep \"cifs\" $RPMPATH"
		FILES="/etc/sysconfig/novell/NvlCifs /etc/ld.so.conf.d/novell-cifs.conf"
		conf_files $OF $FILES /etc/opt/novell/cifs/*conf
		test -d /var/opt/novell/log && FILES=$(find /var/log/cifs -type f | grep 'log$') || FILES=""
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		timed_log_cmd $OF 'ldapsearch -x -b cn=security objectclass=nspmPasswordPolicy'
		echolog Done
	else
		echolog Skipped
	fi
}

cluster_file() {
	LOGFILE=$LOG/$1
	shift
	for CONF in $@
	do
		echo "#==[ Configuration File ]===========================#" >> $LOGFILE
		if [ -f $CONF ]; then
			echo "# $CONF" >> $LOGFILE
			CLINE=$(grep -nA2 adminPw $CONF | tail -1 | cut -d- -f1)
			sed -e "${CLINE}d" $CONF | sed -e "${CLINE}i*REMOVED BY NTS FOR SECURITY*" >> $LOGFILE
		else
			echo "# $CONF - File not found" >> $LOGFILE
		fi
		echo >> $LOGFILE
	done
	echo >> $LOGFILE
}

novell_ncs_info() {
	printlog "Novell NCS..."
	test $OPTION_NCS -eq 0 && { echolog Excluded; return 1; }
	OF=novell-ncs.txt
	if rpm_verify $OF novell-cluster-services
	then
		NCSE_DIR="/etc/opt/novell/ncs"
		NCSV_DIR="/var/opt/novell/ncs"
		unset LOADSCRIPT_DIR
		for NCS_CHK_DIR in /var/run/ncs $NCSE_DIR $NCSV_DIR
		do
			if [ -d $NCS_CHK_DIR ]; then
				SCRIPTS="$SCRIPTS $(find ${NCS_CHK_DIR}/ -type f -name \*load | sort)"
				NCSCONFS="$NCSCONFS $(find ${NCS_CHK_DIR}/ -type f -name \*conf | sort)"
				NCSXML="$NCSXML $(find ${NCS_CHK_DIR}/ -type f -name \*xml | sort)"
				RESOURCELOGS="$RESOURCELOGS $(find ${NCS_CHK_DIR}/ -type f -name \*out | sort)"
			fi
		done
	
		check_service $OF novell-ncs
		NCSTESTBIN=${LOG}/ncsldapCheck.py
cat << NCSTEST > $NCSTESTBIN
#!/usr/bin/python

import commands
import os
import sys
import ldap
import struct
import re
import string
sys.path.append( "/opt/novell/ncs/bin" )
import clstrlibss

def objectNameFromLdapDn(ldapDn):

    cn = string.split(ldapDn, ",")[0]
    return string.split(cn, "=")[1]


ss = clstrlibss.load()
print "ClusterDN: " + ss.clusterDn
cluster_dn = ss.clusterDn

ld = ldap.initialize( ss.ldapUrl )
print "LDAP initialized"

try: 
    ld.simple_bind_s( ss.adminDn, ss.adminPw )
except ldap.LDAPError, e:
    print e
    sys.exit( 1 )

print "bound to LDAP."

try: 
    res = ld.search_s( cluster_dn, ldap.SCOPE_BASE )
    print "Returned Cluster DN: " + res[0][0]
except ldap.LDAPError, e:
    print e
    ld.unbind_s()
    sys.exit( 2 )

try:
    guid = ld.search_s( cluster_dn, ldap.SCOPE_BASE, "cn=" + objectNameFromLdapDn( cluster_dn ), ["GUID"] )
except ldap.LDAPError, e:
    print e
    ld.ubind_s()
    sys.exit( 2 )

print "Cluster GUID found."
print guid

if res[0][1].has_key("nCSGIPCConfig"):
    nwGipcConfig = res[0][1]["nCSGIPCConfig"][0]
    left = nwGipcConfig.find("panning")
    right = nwGipcConfig[left:].find("\n")
    print(nwGipcConfig[left:][:right].strip())
else:
    cid = struct.unpack("I", guid[0][1]["GUID"][0][0:4])
    print("panning clusterid " + str(cid[0]))

print("heartbeat rate_usecs " + str(int(res[0][1]["nCSGIPCHeartbeat"][0]) * 1000000))
print("censustaker tolerance " + str(int(res[0][1]["nCSGIPCTolerance"][0]) * 1000000))
print("sequencer master_watchdog " + str(int(res[0][1]["nCSGIPCMasterWatchdog"][0]) * 1000000))
print("sequencer slave_watchdog " + str(int(res[0][1]["nCSGIPCSlaveWatchdog"][0]) * 1000000))
print("sequencer retrans_max " + res[0][1]["nCSGIPCMaxRetransmits"][0])

res = ld.search_s(cluster_dn, ldap.SCOPE_ONELEVEL, "objectClass=nCSNCPServer", ["nCSGIPCNodeNumber", "nCSNetworkAddress" ] )
for node in res:
    nodeNumber = node[1]["nCSGIPCNodeNumber"][0]
    ipBytes = struct.unpack("BBBB", node[1]["nCSNetworkAddress"][0][2:])
    ipAddress = str(ipBytes[0]) + "." + str(ipBytes[1]) + "." + str(ipBytes[2]) + "." + str(ipBytes[3])
    print("nodeid " + ipAddress + " " + nodeNumber )

ldapRes = ld.search_s(cluster_dn, ldap.SCOPE_ONELEVEL, "(|(objectClass=nCSClusterResource)(objectClass=nCSVolumeResource)(objectClass=nCSResourceTemplate))", ["cn", "objectClass", "nCSRevision" ] )
for object in ldapRes:
    print "Resource/template name: " + object[1]["cn"][0]
    print "\ttype: " + object[1]["objectClass"][0]
    print "\trevision: " + str( object[1]["nCSRevision"][0])

ld.unbind_s()
print "Connection closed."
NCSTEST
		chmod 500 $NCSTESTBIN
		timed_log_cmd $OF $NCSTESTBIN
		rm -f $NCSTESTBIN

		log_cmd $OF 'sfdisk -l'
		log_cmd $OF 'ndsstat -s'
		log_cmd $OF 'cluster stats display'
		log_cmd $OF 'cluster view'
		log_cmd $OF 'cluster resources'
		log_cmd $OF 'cluster pools'
		log_cmd $OF 'cluster info all'
		if timed_log_cmd $OF 'sbdutil -f'; then
			timed_log_cmd $OF 'sbdutil -v'
		fi
		unset NCS_FILE
		test -f /etc/sysconfig/NCS && NCS_FILE="/etc/sysconfig/NCS"
		test -f /etc/sysconfig/novell/ncs && NCS_FILE="/etc/sysconfig/novell/ncs"
		conf_files $OF $NCS_FILE /var/opt/novell/install/ncslog $NCSE_DIR/nodename
		for i in $NCSCONFS
		do
			FILE_NAME=$(basename $i)
			case $FILE_NAME in
			clstrlib.conf*) cluster_file $OF $i ;;
			*) conf_files $OF $i ;;
			esac
		done
		test -s /_admin/Novell/Cluster/EventLog.xml && EVENTLOG="/_admin/Novell/Cluster/EventLog.xml" || EVENTLOG=""
		test -s /admin/Novell/Cluster/EventLog.xml && EVENTLOG="$EVENTLOG /admin/Novell/Cluster/EventLog.xml"
		FILES="$RESOURCELOGS $EVENTLOG $NCSXML $SCRIPTS"
		conf_files $OF $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

pam_info() {
	printlog "PAM..."
	test $OPTION_PAM -eq 0 && { echolog Excluded; return 1; }
	OF=pam.txt
	rpm_verify $OF pam
	rpm_verify $OF pam-modules
	conf_files $OF /etc/nsswitch.conf
	conf_files $OF /etc/passwd
	log_cmd $OF 'getent passwd'
	conf_files $OF /etc/group
	log_cmd $OF 'getent group'
	log_write $OF "#==[ Files in /etc/security ]=======================#"
	test -d /etc/security && FILES="$(find /etc/security/ -type f -name \*conf)" || FILES=""
	conf_files $OF $FILES
	log_write $OF "#==[ Files in /etc/pam.d ]==========================#"
	test -d /etc/pam.d && FILES="$(find /etc/pam.d/ -type f)" || FILES=""
	conf_files $OF $FILES
	echolog Done
}

novell_lum_info() {
	printlog "Novell LUM..."
	test $OPTION_LUM -eq 0 && { echolog Excluded; return 1; }
	OF=novell-lum.txt
	if rpm_verify $OF novell-lum
	then
		if [ -x /usr/ldaptools/bin/ldapsearch ]; then
			LDAP_BIN=/usr/ldaptools/bin/ldapsearch
		elif [ -x /opt/novell/eDirectory/bin/ldapsearch ]; then
			LDAP_BIN=/opt/novell/eDirectory/bin/ldapsearch
		elif [ -x /usr/bin/ldapsearch ]; then
			LDAP_BIN=/usr/bin/ldapsearch
		else
			LDAP_BIN=""
		fi
		check_service $OF namcd
		conf_files $OF '/etc/nsswitch.conf'
		log_cmd $OF 'ndsconfig get n4u.nds.server-name'
		log_cmd $OF 'namconfig get preferred-server'
		PREFERRED_SERVER=$(namconfig get preferred-server | cut -d= -f2)
		if [ -n "$PREFERRED_SERVER" ]; then
			if log_cmd $OF "ping -n -c1 -W1 $PREFERRED_SERVER"; then
				log_write $OF "# LUM Preferred Server Status: Success"
			else
				log_write $OF "# LUM Preferred Server Status: Failure"
			fi
		else
			log_write $OF "# LUM Preferred Server Status: Unknown"
		fi
		log_write $OF

		# Find .der files for LDAPS authentication
		if [ -d /var/nam ]; then
			NAM_DIR="/var/nam"
			DER_LIST=$(find ${NAM_DIR}/ -type f | grep der$)
		elif [ -d /var/lib/novell-lum ]; then
			NAM_DIR="/var/lib/novell-lum"
			DER_LIST=$(find ${NAM_DIR}/ -type f | grep der$)
		else
			NAM_DIR=""
			DER_LIST=""
		fi
		log_cmd $OF "ls -alF ${NAM_DIR}/.*der"

		LDAP_OK=0
		if [ -n "$LDAP_BIN" ]; then
			if [ -x /usr/bin/ndsconfig ]; then
				EDIR_HOST=$(ndsconfig get n4u.nds.server-name | cut -d= -f2)
			else
				EDIR_HOST=$(hostname)
			fi
			if [ -n "$PREFERRED_SERVER" ]; then
				PREFERRED_OPTIONS="-h $PREFERRED_SERVER "
				log_write $OF "#===[ Checking for the LDAP's root DSE on Preferred Server: $PREFERRED_SERVER ]===#"
				if log_cmd $OF "$LDAP_BIN -x ${PREFERRED_OPTIONS}-b \"\" -s base \"objectclass=*\""; then
					log_write $OF "LDAP  Connection: Success"
					LDAP_OK=1
				else
					log_write $OF "LDAP  Connection: FAILED"
				fi
				log_write $OF

				# Attempt LDAPS authentication for each .der file found
				for PREFERRED_DER in $DER_LIST
				do
					if log_cmd $OF "$LDAP_BIN -e ${NAM_DIR}/.${PREFERRED_SERVER}.der ${PREFERRED_OPTIONS}-b \"\" -s base \"objectclass=*\""
					then
						log_write $OF "LDAPS Connection: Success"
					else
						log_write $OF "LDAPS Connection: FAILED"
					fi
					log_write $OF
				done
			else
				PREFERRED_OPTIONS=" "
				if log_cmd $OF "$LDAP_BIN -x ${PREFERRED_OPTIONS}-b \"\" -s base \"objectclass=*\""; then
					log_write $OF "LDAP  Connection: Success"
					LDAP_OK=1
				else
					log_write $OF "LDAP  Connection: FAILED"
				fi
				log_write $OF
				log_write $OF "LDAPS Connection: Unknown"
				log_write $OF
			fi
		fi
		if [ $LDAP_OK -eq 1 ]; then
			log_cmd $OF "$LDAP_BIN -x ${PREFERRED_OPTIONS}\"(cn=UNIX Config)\""
			log_cmd $OF "$LDAP_BIN -x ${PREFERRED_OPTIONS}\"(cn=UNIX Workstation - $EDIR_HOST)\""
		else
			log_write $OF "ERROR: Cannot use LDAP connection"
		fi
		log_write $OF
		log_cmd $OF 'ndsconfig get'
		log_cmd $OF 'namconfig get'
		if [ $OPTION_PAM -eq 0 ]; then
			log_write $OF "WARNING: PAM info excluded by user"
		else
			log_cmd $OF 'cat /etc/passwd'
			log_cmd $OF 'getent passwd'
		fi
		FILES="/var/log/messages"
		test $ADD_OPTION_LOGS -eq 1 && grep_log_files namcd $OF 0 $FILES || grep_log_files namcd $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

environment_info() {
	printlog "Environment..."
	test $OPTION_ENV -eq 0 && { echolog Excluded; return 1; }
	OF=env.txt
	log_icmd $OF 'ulimit -a'
	log_cmd $OF 'chkconfig boot.sysctl'
	conf_files $OF /etc/sysconfig/sysctl /etc/sysctl.conf
	log_cmd $OF 'sysctl -a'
	log_cmd $OF 'getconf -a'
	log_cmd $OF 'ipcs -l'
	log_cmd $OF 'ipcs -a'
	test -d /etc/default && FILES=$(find /etc/default/ -type f) || FILES=""
	conf_files $OF $FILES
	log_cmd $OF 'env'
	# s390 specific
	if grep vmcp /proc/modules &>/dev/null; then
		log_cmd $OF 'vmcp query virtual all'
		log_cmd $OF 'vmcp query privclass'
		log_cmd $OF 'vmcp query cplevel'
		log_cmd $OF 'vmcp query mdc'
		log_cmd $OF 'vmcp query qioassist'
		log_cmd $OF 'vmcp query files'
		log_cmd $OF 'vmcp query userid'
	else
		case $(uname -i) in
		s390x) 
			log_write $OF "#==[ s390x Hardware Detected ]======================#"
			log_write $OF "# Consider loading vmcp for more info: modprobe vmcp"
			log_write $OF
			;;
		esac
	fi
	echolog Done
}

chkconfig_info() {
	printlog "System Daemons..."
	test $OPTION_CHKCONFIG -eq 0 && { echolog Excluded; return 1; }
	OF=chkconfig.txt
	log_cmd $OF 'chkconfig --list'
	LOGFILE=$LOG/$OF
	echo "# individual boot services:" >> $LOGFILE
	for BOOTSERVICE in $(find /etc/init.d/ -type f -name boot\* | grep -v rpmsave$)
	do
		NAME=$(basename $BOOTSERVICE)
		STATUS=$(chkconfig $NAME 2>>$LOGFILE)
		printf "%25s:  %-4s\n" $(echo $STATUS | awk '{print $1}') $(echo $STATUS | awk '{print $2}') >> $LOGFILE
	done
	echolog Done
}

cron_info() {
	printlog "CRON..."
	test $OPTION_CRON -eq 0 && { echolog Excluded; return 1; }
	OF=cron.txt
	if rpm_verify $OF cron
	then
		check_service $OF cron
		conf_files $OF /var/spool/cron/allow /var/spool/cron/deny
		log_write $OF "### Individual User Cron Jobs ###"
		test -d /var/spool/cron/tabs && FILES=$(find /var/spool/cron/tabs/ -type f) || FILES=""
		conf_files $OF $FILES
		CRONS="cron.d cron.hourly cron.daily cron.weekly cron.monthly"
		log_write $OF "### System Cron Job File List ###"
		for CRONDIR in $CRONS
		do
			log_cmd $OF "find /etc/${CRONDIR}/ -type f"
		done
		log_write $OF "### System Cron Job File Content ###"
		conf_files $OF /etc/crontab
		for CRONDIR in $CRONS
		do
			FILES=$(find /etc/${CRONDIR}/ -type f)
			conf_files $OF $FILES
		done
		echolog Done
	else
		echolog Skipped
	fi
	printlog "AT..."
	log_write $OF "#----------------------------------------------------------------#"
	if rpm_verify $OF at
	then
		check_service $OF atd
		log_write $OF "### System at Job File List ###"
		log_cmd $OF "find /var/spool/atjobs/ -type f"
		log_write $OF "### System at Job File Content ###"
		FILES=$(find /var/spool/atjobs/ -type f)
		conf_files $OF $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

soft_raid_info() {
	printlog "Software Raid..."
	test $OPTION_SRAID -eq 0 && { echolog Excluded; return 1; }
	OF=fs-softraid.txt
	conf_files $OF /proc/mdstat
	if rpm_verify $OF mdadm
	then
		log_cmd $OF 'mdadm --detail --scan'
	fi
	if rpm_verify $OF raidtools
	then
		LOGFILE=$LOG/$OF
		for MDEVICE in $(cat /proc/mdstat | grep ^md | awk '{print $1}')
		do
			echo "# lsraid -a /dev/$MDEVICE" >> $LOGFILE
			lsraid -a /dev/$MDEVICE >> $LOGFILE 2>&1
			echo >> $LOGFILE
		done
	fi
	conf_files $OF /etc/mdadm.conf /etc/raidtab
	echolog Done
}

lvm_info() {
	printlog "LVM..."
	test $OPTION_LVM -eq 0 && { echolog Excluded; return 1; }
	echonlog "Please Wait..."
	OF=lvm.txt
	if rpm_verify $OF lvm || rpm_verify $OF lvm2
	then
		echonlog Base
		rpm -q lvm &>/dev/null
		if [ $? -gt 0 ]; then
			rpm -q lvm2 &>/dev/null
			if [ $? -eq 0 ]; then
				VGBIN="vgs"
				LVBIN="lvs"
			fi
		else
			VGBIN="vgscan"
			LVBIN="lvscan"
		fi
		log_cmd $OF 'chkconfig boot.device-mapper'
		log_cmd $OF 'chkconfig boot.lvm'
		log_cmd $OF 'chkconfig boot.md'
		log_cmd $OF 'chkconfig boot.evms'
		log_cmd $OF 'pvscan'
		log_cmd $OF "$VGBIN"
		log_cmd $OF "$LVBIN"
		log_cmd $OF 'dmsetup table'
		log_cmd $OF 'dmsetup info'
		conf_files $OF /etc/sysconfig/lvm
		conf_files $OF /etc/lvm/lvm.conf
		conf_files $OF /etc/lvm/.cache
		log_cmd $OF 'ls -l /etc/lvm/backup'
		conf_files $OF /etc/lvm/backup/*
		log_cmd $OF 'ls -l /etc/lvm/archive'
		conf_files $OF /etc/lvm/archive/*
		echonlog Detail
		log_write $OF
		log_write $OF "###[ Detail Scans ]###########################################################################"
		log_write $OF
		log_cmd $OF 'pvdisplay -vv'
		log_cmd $OF 'vgdisplay -vv'
		log_cmd $OF 'lvdisplay -vv'
		log_cmd $OF 'pvs -vvvv'
		log_cmd $OF 'pvscan -vvv'
		log_cmd $OF "$VGBIN -vvvv"
		log_cmd $OF "$LVBIN -vvvv"
		echolog Done
	else
		echolog Skipped
	fi
}

mpio_info() {
	printlog "Multipathing..."
	test $OPTION_MPIO -eq 0 && { echolog Excluded; return 1; }
	OF=mpio.txt
	SKIP=0
	MPIO_RPM=$(rpm -qf `which multipath 2>/dev/null` 2>/dev/null)
	if [ -z "$MPIO_RPM" ]; then
		MPIO_RPM=multipath-tools
	fi
	if rpm_verify $OF $MPIO_RPM
	then
		case $SLES_VER in
		80|90) UDEVOPT="-d" ;;
		10*|11*) UDEVOPT="-e" ;;
		esac 
		log_cmd $OF 'chkconfig boot.device-mapper'
		log_cmd $OF 'chkconfig boot.multipath'
		check_service $OF multipathd
		log_cmd $OF 'lspci -b'
		log_cmd $OF 'multipath -ll'
		log_cmd $OF 'ls -lR /dev/disk'
		conf_files $OF /etc/multipath.conf /etc/modprobe.conf.local /etc/sysconfig/hotplug /etc/sysconfig/kernel /etc/fstab
		log_cmd $OF 'lsscsi -g'
		log_cmd $OF 'dmsetup table'
		log_cmd $OF 'dmsetup info'
		log_cmd $OF "udevinfo $UDEVOPT"
		test -d /proc/scsi && SCSI_DIRS=$(find /proc/scsi/ -type d) || SCSI_DIRS=""
		for SDIR in $SCSI_DIRS
		do
			# Skip unwanted scsi directories
			test "$SDIR" = "/proc/scsi" -o "$SDIR" = "/proc/scsi/sg" -o "$SDIR" = "/proc/scsi/mptspi" && continue
			FILES=$(find ${SDIR}/ -maxdepth 1 -type f 2>/dev/null)
			conf_files $OF $FILES
		done
		log_cmd $OF 'multipath -v3 -d'
	else
		((SKIP++))
	fi
	if rpm_verify $OF EMCpower.LINUX
	then
		test -x /sbin/powermt && log_cmd $OF 'powermt display dev=all'
	else
		((SKIP++))
	fi
	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

evms_info() {
	printlog "EVMS..."
	test $OPTION_EVMS -eq 0 && { echolog Excluded; return 1; }
	OF=evms.txt
	if rpm_verify $OF evms
	then
		log_cmd $OF 'chkconfig boot.evms'
		log_cmd $OF 'chkconfig boot.device-mapper'
		log_cmd $OF 'chkconfig boot.lvm'
		log_cmd $OF 'chkconfig boot.md'
		log_cmd $OF 'dmsetup table'
		log_cmd $OF 'dmsetup info'
		conf_files $OF '/etc/evms.conf'
		if [ -d /dev/evms ]; then
			log_cmd $OF 'ls -alR /dev/evms'
		else
			log_write $OF "# Missing Directory: /dev/evms"
		fi
		conf_files $OF /etc/init.d/boot.evms
		if [ $MIN_OPTION_AUTOMOD -eq 0 ]; then
			log_write $OF "#==[ Warning ]======================================#"
			log_write $OF "# Autoloading kernel modules disabled. Don't use -k."
			log_write $OF "# Excluding evms_gather_info"
			log_write $OF
		else
			timed_log_cmd $OF 'evms_gather_info'
		fi
		if [ $ADD_OPTION_LOGS -eq 1 ]; then
			log_write $OF "#  >Additional Logs Activated"
			FILES=$(find /var/log/ -type f -name 'evms-engine*')
		else
			FILES="/var/log/evms-engine.log"
		fi
		log_files $OF 0 $FILES
		test -f gather_info.qry && rm -f gather_info.qry
		echolog Done
	else
		echolog Skipped
	fi
}

hardware_info() {
	# This is a minimum required function, do not exclude
	printlog "Hardware..."
	test $MIN_OPTION_HARDWARE -eq 0 && { echolog EXCLUDED; return 1; }
	echonlog "Please Wait..."
	OF=hardware.txt
	log_cmd $OF 'procinfo'
	conf_files $OF /proc/cpuinfo /proc/cmdline /proc/ioports /proc/dma /proc/devices /proc/bus/usb/devices
	log_cmd $OF 'lspci -b'
	if [ $MIN_OPTION_AUTOMOD -eq 0 ]; then
		log_write $OF "#==[ Warning ]======================================#"
		log_write $OF "# Autoloading kernel modules disabled. Don't use -k."
		log_write $OF "# Excluding hwinfo"
		log_write $OF
		log_cmd $OF 'biosdecode'
		log_cmd $OF 'dmidecode'
	else
		timed_log_cmd $OF 'hwinfo -braille'
	fi
	log_cmd $OF 'lspci -n'
	log_cmd $OF 'lspci -vvv'
	log_cmd $OF 'lsusb -v'
	log_cmd $OF 'ls -al /dev | egrep "fd.*|dvd.*|cdr.*"'
	echolog Done
}

net_info() {
	printlog "Networking..."
	test $OPTION_NET -eq 0 && { echolog Excluded; return 1; }
	OF=network.txt
	rpm_verify $OF sysconfig
	check_service $OF network
	check_service $OF nscd
	log_cmd $OF 'ifconfig -a'
	log_cmd $OF 'hwinfo --netcard'
	conf_files $OF /proc/sys/net/ipv4/ip_forward /etc/HOSTNAME
	log_cmd $OF 'hostname'
	# s390 specific
	if grep vmcp /proc/modules &>/dev/null; then
		log_cmd $OF 'vmcp query nic details'
		log_cmd $OF 'vmcp query lan details'
		log_cmd $OF 'vmcp query vswitch detail'
	else
		case $(uname -i) in
		s390x) 
			log_write $OF "#==[ s390x Hardware Detected ]======================#"
			log_write $OF "# Consider loading vmcp for more info: modprobe vmcp"
			log_write $OF
			;;
		esac
	fi
	IPADDRS=$(ip addr | grep 'inet ' | awk '{print $2}' | cut -d/ -f1)
	for IPADDR in $IPADDRS
	do
		if log_cmd $OF "ping -n -c1 -W1 $IPADDR"; then
			log_write $OF "# Local Interface Status: Success"
		else
			log_write $OF "# Local Interface Status: Failure"
		fi
		log_write $OF
	done

	IPADDR=$(route -n | grep 'UG ' | awk '{print $2}')
	if log_cmd $OF "ping -n -c1 -W1 $IPADDR"; then
		log_write $OF "# Default Route Status: Success"
	else
		log_write $OF "# Default Route Status: Failure"
	fi
	log_write $OF
	if [ -z "$IPADDR" ]; then
		log_cmd $OF 'route -n'
	fi

	test -e /etc/resolv.conf && IPADDRS=$(grep ^nameserver /etc/resolv.conf | cut -d' ' -f2) || IPADDRS=""
	for IPADDR in $IPADDRS
	do
		if log_cmd $OF "ping -n -c1 -W1 $IPADDR"; then
			log_write $OF "# DNS Name Server Status: Success"
		else
			log_write $OF "# DNS Name Server Status: Failure"
		fi
		log_write $OF
	done

	log_cmd $OF 'netstat -as'
	log_cmd $OF 'netstat -nlp'
	log_cmd $OF 'netstat -nr'
	log_cmd $OF 'netstat -i'
	log_cmd $OF 'arp -v'
	if [ -x /sbin/brctl ]; then
		log_cmd $OF 'brctl show'
		for BRIDGE in `brctl show | egrep -v "'bridge name'|vif" | awk '{print$1}'` 
		do 
			log_cmd $OF "brctl showmacs $BRIDGE"
		done
	fi
	for NIC in $(ifconfig -a | egrep -v "^ |^lo|^$" | awk '{print $1}')
	do
		log_cmd $OF "ethtool $NIC"
		log_cmd $OF "ethtool -k $NIC"
		log_cmd $OF "mii-tool -v $NIC"
	done
	conf_files $OF /etc/hosts /etc/host.conf /etc/resolv.conf /etc/nsswitch.conf /etc/nscd.conf /etc/hosts.allow /etc/hosts.deny
	conf_files $OF /etc/sysconfig/SuSEfirewall2 /etc/sysconfig/personal-firewall
	for TABLE in filter nat mangle raw
	do
		if grep iptable_$TABLE /proc/modules &>/dev/null
		then
			log_cmd $OF "iptables -t $TABLE -nvL"
			log_cmd $OF "iptables-save -t $TABLE"
		else
			log_write $OF "# NOTE: The iptable_$TABLE module is not loaded, skipping check"
			log_write $OF
		fi
	done
	test -d /etc/sysconfig/network && FILES=$(find /etc/sysconfig/network/ -maxdepth 1 -type f) || FILES=""
	conf_files $OF /etc/sysconfig/proxy $FILES 
	if [ -d /proc/net/bonding ]; then
		FILES=$(find /proc/net/bonding/ -type f)
		conf_files $OF $FILES 
	fi
	FILES=$(grep logfile /etc/nscd.conf | grep -v ^# | awk '{print $2}' | tail -1)
	test -n "$FILES" || FILES="/var/log/nscd.log"
	test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	echolog Done
}

disk_info() {
	printlog "Disk I/O..."
	test $OPTION_DISK -eq 0 && { echolog Excluded; return 1; }
	OF=fs-diskio.txt
	log_cmd $OF 'fdisk -l 2>/dev/null | grep Disk'
	conf_files $OF /proc/partitions /etc/fstab
	log_cmd $OF "mount"

	for DISK in $(cat /proc/partitions | grep -v ^m | grep -v ^$ | awk '{print $4}')
	do
		case $DISK in
		sd[a-z]|sd[a-z][a-z]) log_cmd $OF "parted -s /dev/$DISK print" ;;
		hd[a-z]|hd[a-z][a-z]) log_cmd $OF "parted -s /dev/$DISK print" ;;
		xvd[a-z]|xvd[a-z][a-z]) log_cmd $OF "parted -s /dev/$DISK print" ;;
		dasd[a-z]|dasd[a-z][a-z]) 
			log_cmd $OF "dasdview -i -f /dev/$DISK"
			log_cmd $OF "dasdview -t info -f /dev/$DISK"
			;;
		cciss*) 
			CCISS_DISK=$(echo $DISK | cut -d/ -f2)
			case $CCISS_DISK in
			c[0-9]d[0-9]) log_cmd $OF "parted -s /dev/cciss/$CCISS_DISK print" ;;
			esac
			CCISS_DISK=$(echo $DISK | cut -d\! -f2)
			case $CCISS_DISK in
			c[0-9]d[0-9]) log_cmd $OF "parted -s /dev/cciss/$CCISS_DISK print" ;;
			esac
			;;
		esac
	done

	log_cmd $OF 'ls -lR /dev/disk'
	log_cmd $OF 'ls -l /sys/block'

	if [ $ADD_OPTION_MINDISK -eq 0 ]; then
		log_cmd $OF 'iostat -x 1 4'
		log_cmd $OF 'sg_map -i -x'
		if [ -d /sys/block ]; then
			IDE_DISKS=$(find /sys/block/ -maxdepth 1 | grep hd\.)
			SCSI_DISKS=$(find /sys/block/ -maxdepth 1 | grep sd\.)
			CCISS_DISKS=$(find /sys/block/ -maxdepth 1 | grep cciss\*)
		else
			IDE_DISKS=""
			SCSI_DISKS=""
			CCISS_DISKS=""
		fi


		if [ -n "$IDE_DISKS" -a -d /proc/ide ]; then
			log_write $OF "#==[ IDE Detailed Info ]============================#"
			log_write $OF "#---------------------------------------------------#"
			FILES=$(find /proc/ide/ -maxdepth 1 -type f 2>/dev/null)
			conf_files $OF $FILES
			if rpm_verify $OF hdparm
			then
				DISKS=$(find /proc/ide/ -maxdepth 1 | grep hd\. | sort)
				for DISK in $DISKS
				do
					CURRENT_DISK="/dev/$(basename $DISK)"
					log_cmd $OF "hdparm -vi $CURRENT_DISK"
				done
			fi
		fi

		if [ -n "$SCSI_DISKS" ]; then
			log_write $OF "#==[ SCSI Detailed Info ]===========================#"
			log_write $OF "#---------------------------------------------------#"
			log_cmd $OF 'lsscsi'
			if log_cmd $OF 'scsiinfo -l'
			then
				FILES=$(scsiinfo -l)
				for DEVICE in $FILES
				do
					log_cmd $OF "scsiinfo -i $DEVICE"
				done
			fi
			log_cmd $OF 'lsscsi -v'
			test -d /proc/scsi && SCSI_DIRS=$(find /proc/scsi/ -type d) || SCSI_DIRS=""
			for SDIR in $SCSI_DIRS
			do
				test "$SDIR" = "/proc/scsi" -o "$SDIR" = "/proc/scsi/sg" -o "$SDIR" = "/proc/scsi/mptspi" && continue
				FILES=$(find ${SDIR}/ -maxdepth 1 -type f 2>/dev/null)
				conf_files $OF $FILES
			done
		fi

		if [ -n "$CCISS_DISKS" -a -d /proc/driver/cciss ]; then
			log_write $OF "#==[ CCISS Detailed Info ]==========================#"
			log_write $OF "#---------------------------------------------------#"
			FILES=$(find /proc/driver/cciss/ -maxdepth 1 -type f 2>/dev/null)
			conf_files $OF $FILES
		fi
		log_cmd $OF 'sfdisk -d'
	fi
	echolog Done
}

iscsi_info() {
	printlog "iSCSI..."
	test $OPTION_ISCSI -eq 0 && { echolog Excluded; return 1; }
	OF=fs-iscsi.txt
	case $SLES_VER in
	80|90) 
		if rpm_verify $OF linux-iscsi
		then
			log_cmd $OF 'iscsi-ls -l'
			conf_files $OF /etc/iscsi.conf /etc/initiatorname.iscsi
			log_cmd $OF 'sfdisk -l'
		fi
		;;
	10*|11*)
		log_write $OF "#___________________________________________________________#"
		log_write $OF "#____[ iSCSI Target Information ]___________________________#"
		log_write $OF
		if rpm_verify $OF iscsitarget
		then
			check_service $OF iscsitarget
			log_cmd $OF 'ietadm --op show'
			conf_files $OF /etc/ietd.conf /proc/net/iet/volume /proc/net/iet/session
		fi
		log_write $OF "#___________________________________________________________#"
		log_write $OF "#____[ iSCSI Initiator Information ]________________________#"
		log_write $OF
		if rpm_verify $OF open-iscsi
		then
			log_cmd $OF 'chkconfig boot.open-iscsi'
			check_service $OF open-iscsi
			CHKSRV=$?
			log_cmd $OF 'iscsi-iname'
			conf_files $OF /etc/iscsid.conf
			if [ $CHKSRV -eq 0 ]; then
				log_cmd $OF 'iscsiadm -m session'
				if log_cmd $OF 'iscsiadm -m node'
				then
					NODES=$(iscsiadm -m node | cut -d] -f1 | cut -d[ -f2)
					for NODE in $NODES
					do
						log_cmd $OF "iscsiadm -m node -r $NODE"
					done
				fi
			fi
		fi
		;;
	esac
	echolog Done
}

nfs_info() {
	printlog "NFS..."
	test $OPTION_NFS -eq 0 && { echolog Excluded; return 1; }
	OF=nfs.txt
	if rpm_verify $OF nfs-utils
	then
		check_service $OF portmap
		check_service $OF nfslock
		if check_service $OF nfsserver
		then
			log_cmd $OF 'exportfs'
			log_cmd $OF 'nfsstat'
			if log_cmd $OF 'showmount'
			then
				log_cmd $OF 'showmount -e'
				log_cmd $OF 'showmount -a'
			fi
		fi
		conf_files $OF /etc/exports /etc/sysconfig/nfs
		echolog Done
	else
		echolog Skipped
	fi
}

ntp_info() {
	printlog "NTP..."
	test $OPTION_NTP -eq 0 && { echolog Excluded; return 1; }
	OF=ntp.txt
	CONFFILE=/etc/ntp.conf
	case $SLES_VER in
	8*|9*|10*)
		if rpm_verify $OF xntp
		then
			case $SLES_VER in
			80|90) check_service $OF xntpd ;;
			10*)   check_service $OF ntp ;;
			esac
			log_cmd $OF 'ntpq -p'
			conf_files $OF $CONFFILE
			if [ -f $CONFFILE ]; then
				log_write $OF "#___________________________________________________________#"
				log_write $OF "#____[ Files Included in $CONFFILE ]____________________#"
				log_write $OF
				for KEYNAME in driftfile keys
				do
					FILES=$(grep ^${KEYNAME} $CONFFILE | awk '{print $2}')
					conf_files $OF $FILES
				done
				KEYNAME=logfile
				FILES=$(grep ^${KEYNAME} $CONFFILE | awk '{print $2}')
				[ -z "$FILES" ] && FILES=/var/log/ntp
				test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
			fi
			echolog Done
		else
			echolog Skipped
		fi
		;;
	11*)
		if rpm_verify $OF ntp
		then
			check_service $OF ntp
			log_cmd $OF 'ntpq -p'
			conf_files $OF $CONFFILE
			if [ -f $CONFFILE ]; then
				log_write $OF "#___________________________________________________________#"
				log_write $OF "#____[ Files Included in $CONFFILE ]____________________#"
				log_write $OF
				for KEYNAME in driftfile keys
				do
					FILES=$(grep ^${KEYNAME} $CONFFILE | awk '{print $2}')
					conf_files $OF $FILES
				done
				KEYNAME=logfile
				FILES=$(grep ^${KEYNAME} $CONFFILE | awk '{print $2}')
				[ -z "$FILES" ] && FILES=/var/log/ntp
				test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
			fi
			echolog Done
		else
			echolog Skipped
		fi
		;;
	esac
}

udev_info() {
	printlog "UDEV..."
	test $OPTION_UDEV -eq 0 && { echolog Excluded; return 1; }
	OF=udev.txt
	if rpm_verify $OF udev
	then
		UDEV_CONF=/etc/udev/udev.conf
		log_cmd $OF 'chkconfig boot.udev'
		conf_files $OF $UDEV_CONF
		case $SLES_VER in
		80|90) UDEVOPT="-d" ;;
		10*|11*) UDEVOPT="-e" ;;
		esac 
		log_cmd $OF "udevinfo $UDEVOPT"
		if [ -f $UDEV_CONF ]; then
			. $UDEV_CONF
			if [ -d "${udev_rules:=/etc/udev/rules.d}" ]; then
				FILES=$(find ${udev_rules}/ -type f)
				conf_files $OF $FILES
			fi
			test "$udev_db" != "" && log_cmd $OF "ls -l $udev_db"
		fi
		echolog Done
	else
		echolog Skipped
	fi
}

crash_info() {
	printlog "Crash Info..."
	test $OPTION_CRASH -eq 0 && { echolog Excluded; return 1; }
	OF=crash.txt
	SKIP=0
	if rpm_verify $OF lkcdutils
	then
		DUMPCFG="/etc/sysconfig/dump"
		log_cmd $OF "lkcd query"
		log_cmd $OF "chkconfig boot.lkcd"
		log_cmd $OF "chkconfig lkcd-netdump --list"
		conf_files $OF $DUMPCFG
		if [ -f $DUMPCFG ]; then
			DUMPDEV=$(grep ^DUMPDEV $DUMPCFG | sed -e 's/"//g' | cut -d= -f2)
			FOUND=$(echo $DUMPDEV | grep /dev)
			if [ -n "$FOUND" ]; then
				log_cmd $OF "ls -l $DUMPDEV"
			fi
		fi
		log_cmd $OF "sysctl kernel.sysrq"
		log_cmd $OF 'grep -A20 -i "saving lkcd dump" /var/log/boot.msg'
		test -d /var/log/dump && FILES=$(find /var/log/dump/ -type f 2>/dev/null | grep analysis) || FILES=""
		test -z "$FILES" || conf_files $OF $FILES
	else
		((SKIP++))
	fi

	if rpm_verify $OF kernel-kdump
	then
		DUMPCFG="/etc/sysconfig/kdump"
		rpm_verify $OF kexec-tools
		log_cmd $OF "uname -r"
		check_service $OF kdump
		conf_files $OF $DUMPCFG /proc/cmdline
		log_cmd $OF "sysctl kernel.sysrq"
		log_cmd $OF 'sysctl kernel 2>/dev/null | grep panic'
		if [ -f $DUMPCFG ]; then
			DUMPDIR=$(grep ^KDUMP_SAVEDIR $DUMPCFG | sed -e 's/"//g' | cut -d= -f2)
			if [ -d $DUMPDIR ]; then
				log_cmd $OF "find ${DUMPDIR}/"
			fi
		fi
	else
		((SKIP++))
	fi

	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

autofs_info() {
	printlog "AUTOFS..."
	test $OPTION_AUTOFS -eq 0 && { echolog Excluded; return 1; }
	OF=fs-autofs.txt
	if rpm_verify $OF autofs || rpm_verify $OF autofs4
	then
		check_service $OF autofs
		conf_files $OF /etc/sysconfig/autofs
		log_cmd $OF 'grep ^automount: /etc/nsswitch.conf'
		for SCHEME in $(grep ^automount: /etc/nsswitch.conf | sed -e 's/^.*:[ \t]*//')
		do
			log_write $OF "#--[ Automount Scheme: $SCHEME ]--#"
			case "$SCHEME" in
			files)
				if [ -f /etc/auto.master ]; then
					FILES=$(cat /etc/auto.master | grep -v ^# | awk '{print $2}')
					conf_files $OF /etc/auto.master $FILES
				else
					log_write $OF "Missing /etc/auto.master"
					log_write $OF
				fi
				;;
			nis)
				log_cmd $OF "ypcat -k auto.master"
				;;
			nisplus)
				log_cmd $OF "niscat -k auto_master.org_dir"
				;;
			ldap)
				log_cmd $OF "ldapsearch -x \"(&(objectclass=automountMap))\""
				log_cmd $OF "ldapsearch -x \"(&(objectclass=automount))\""
				log_cmd $OF "ldapsearch -x \"(&(objectclass=nisMap))\""
				log_cmd $OF "ldapsearch -x \"(&(objectclass=nisObject))\""
				;;
			esac
		done
		echolog Done
	else
		echolog Skipped
	fi
}

get_sles_ver() {
	KERNBASE=$(uname -r | cut -d- -f1)
	KERNCNT=$(echo $KERNBASE | sed -e 's/\./ /g' | wc -w)
	test $KERNCNT -lt 4 && KERNBASE="${KERNBASE}.0"
	KERNVER=$(echo $KERNBASE | awk -F\. '{printf "%g%g%02g%02g\n", $1, $2, $3, $4}')
	if [ $KERNVER -gt 262500 ]; then
		SLES_VER=110
	elif [ $KERNVER -gt 262200 ]; then
		SLES_VER=101
	elif [ $KERNVER -gt 261600 ]; then
		SLES_VER=100
	elif [ $KERNVER -eq 260500 ]; then
		SLES_VER=90
	elif [ $KERNVER -lt 260500 ]; then
		SLES_VER=80
	else
		SLES_VER=90
	fi
}

rpm_full_verify() {
	OF=rpm-verify.txt
	OFTMP=$LOG/$RPM_QA_FILE
	if [ $ADD_OPTION_RPMV -eq 1 ]; then
		echolog
		echolog "Starting full RPM verification"
		echolog
		STARTCNT=1
		ENDCNT=$(cat $OFTMP | wc -l)
		for RPMNAME in $(cat $OFTMP)
		do
			printvrpmlog $RPMNAME "$((STARTCNT++)) of $ENDCNT"
			log_cmd $OF "rpm -V $RPMNAME"
			echolog Done
		done
		rm -f $OFTMP
	fi
}

xen_info() {
	printlog "Xen..."
	test $OPTION_XEN -eq 0 && { echolog Excluded; return 1; }
	OF=xen.txt
	if rpm_verify $OF xen-tools
	then
		rpm_verify $OF libvirt
		log_cmd $OF "egrep \"vmdp|libvirt\" $RPMPATH"
		log_cmd $OF 'uname -r'
		check_service $OF xend
		log_cmd $OF 'grep ^NETWORKMANAGER /etc/sysconfig/network/config'
		log_write $OF "NOTE: NETWORKMANAGER should be set to \"no\" for Xen"
		log_write $OF
		conf_files $OF '/boot/grub/menu.lst /etc/xen/xend-config.sxp /etc/sysconfig/xendomains /etc/libvirt/libvirtd.conf'
		log_cmd $OF 'xm info'
		log_cmd $OF 'xm list'
		log_cmd $OF 'xm vcpu-list'
		log_cmd $OF 'ls -alR /etc/xen/vm/'
		log_cmd $OF 'ls -alR /etc/xen/images/'


		test -d /etc/xen/vm && FILES=$(find /etc/xen/vm/ -type f | sort) || FILES=""
		conf_text_files $OF $FILES
		log_cmd $OF 'xm list -l'
		test -d /var/lib/xend/domains && FILES=$(find /var/lib/xend/domains/ -type f | grep config.sxp) || FILES=""
		conf_text_files $OF $FILES

		log_cmd $OF 'brctl show'
		log_cmd $OF 'route -n'
		log_cmd $OF 'arp -v'
		unset NETCMD
		unset XSCRIPTS
		XCONF=/etc/xen/xend-config.sxp

		if [ -s $XCONF ]; then
			NETCMDLINE=$(grep '^(network\-script' $XCONF | sed -e 's/(//g;s/)//g')
			NETCMDTEST=$(echo $NETCMDLINE | awk '{print $2}')
			if [ -n "$NETCMDTEST" ]; then
				if echo $NETCMDTEST | grep \' &> /dev/null; then
					NETCMD="/etc/xen/scripts/`echo $NETCMDTEST | sed -e s/\'//g`"
				else
					NETCMD="/etc/xen/scripts/$NETCMDTEST"
				fi
			fi
			XSCRIPTS=$(grep '\-script' $XCONF 2>/dev/null | grep '^(' | awk '{print $2}' | sed -e "s/)//g;s/'//g")
			test -n "$NETCMD" && log_cmd $OF "$NETCMD status"
		fi
		for BRIDGE in `brctl show | grep -v ^bridge | egrep "^[a-z]|^[A-Z]" | awk '{print $1}'` 
		do 
			log_cmd $OF "brctl showmacs $BRIDGE"
		done

		for XSCRIPT in $XSCRIPTS
		do
			conf_text_files $OF /etc/xen/scripts/$XSCRIPT
		done


		if [ $ADD_OPTION_LOGS -eq 1 ]; then
			test -d /root/.virt-manager && FILES="$(find /root/.virt-manager/ -type f)" || FILES=""
			test -d /var/log/xen && FILES="$FILES $(find /var/log/xen/ -type f | sort)"
		else
			test -d /root/.virt-manager && FILES=/root/.virt-manager/virt-manager.log || FILES=""
			test -d /var/log/xen && FILES="$FILES $(find /var/log/xen/ -type f | grep 'log$' | sort)"
		fi
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES


		log_cmd $OF 'xm dmesg'
		echolog Done
	else
		echolog Skipped
	fi
}

apparmor_info() {
	printlog "AppArmor..."
	test $OPTION_APPARMOR -eq 0 && { rm -f $AARPTMP &>/dev/null; echolog Excluded; return 1; }
	OF=security-apparmor.txt
	SKIP=0
	if rpm_verify $OF subdomain-parser
	then
			rpm_verify $OF subdomain-parser-common
			rpm_verify $OF subdomain-utils
			rpm_verify $OF subdomain-profiles
			test -f $AARPTMP && cat $AARPTMP >> $LOG/$OF
			check_service $OF boot.subdomain
			log_cmd $OF 'unconfined'
	else
		((SKIP++))
	fi

	if rpm_verify $OF apparmor-parser
	then
		rpm_verify $OF apparmor-utils
		rpm_verify $OF apparmor-profiles
		test -f $AARPTMP && cat $AARPTMP >> $LOG/$OF
		log_cmd $OF "/etc/init.d/boot.apparmor status"
		log_cmd $OF 'unconfined'
		log_files $OF 0 /var/log/audit/audit.log
		test -d /etc/apparmor && FILES=$(find /etc/apparmor/ | grep conf) || FILES=""
		conf_files $OF $FILES
	else
		((SKIP++))
	fi

	rm -f $AARPTMP &>/dev/null
	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

ha_info() {
	printlog "HA Cluster..."
	test $OPTION_HA -eq 0 && { echolog Excluded; return 1; }
	OF=ha.txt
	if rpm_verify $OF heartbeat
	then
		check_service $OF heartbeat
		log_cmd $OF 'cl_status hbstatus'
		conf_files $OF /etc/ha.d/ha.cf /etc/ha.d/haresources
		log_cmd $OF 'ls -l /etc/ha.d/authkeys'
		log_cmd $OF 'ntpq -p'
		CHECKDIR="/var/lib/heartbeat/pengine"
		HALOG="$LOG/ha-pengine"
		if [ -d $CHECKDIR ]; then
			FOUND=$(find ${CHECKDIR}/ -type f)
			if [ -n "$FOUND" ]; then
				mkdir -p $HALOG
				log_write $OF "#==[ Command ]======================================#"
				if [ $ADD_OPTION_LOGS -eq 1 ]; then
					log_write $OF "# cp -a $CHECKDIR $HALOG"
					cp -a $CHECKDIR/* $HALOG &>/dev/null
				else
					log_write $OF "# cp $CHECKDIR $HALOG"
					log_write $OF "# NOTE: Only the newest $VAR_OPTION_PENGINE_FILES_LIMIT files are copied"
					for i in $(\ls -rA1t $CHECKDIR | tail -${VAR_OPTION_PENGINE_FILES_LIMIT})
					do
						cp ${CHECKDIR}/${i} $HALOG &>/dev/null
					done
				fi
				log_write $OF
			fi
		fi
		if cl_status hbstatus &>/dev/null
		then
			test $SLES_VER -ge 100 && log_cmd $OF 'crm_mon -r -1'
			log_cmd $OF 'cl_status listnodes'
			log_cmd $OF 'cl_status rscstatus'
			for HBNODE in $(cl_status listnodes 2>/dev/null)
			do
				log_cmd $OF "cl_status listhblinks $HBNODE"
				for HBLINK in $(cl_status listhblinks $HBNODE 2>/dev/null)
				do
					log_cmd $OF "cl_status hblinkstatus $HBNODE $HBLINK"
				done
			done
		fi
		test -d /var/lib/heartbeat && FILES=$(find /var/lib/heartbeat/ -type f | egrep -v "cores|pengine|hb_uuid") || FILES=""
		conf_files $OF /etc/ha_logd.cf $FILES
		test $SLES_VER -ge 100 && log_cmd $OF 'cibadmin -Q'
		FILES="/var/log/ha-log"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

slp_info() {
	printlog "SLP..."
	test $OPTION_SLP -eq 0 && { echolog Excluded; return 1; }
	OF=slp.txt
	if rpm_verify $OF openslp-server
	then
		check_service $OF slpd
	fi
	if rpm_verify $OF openslp
	then
		conf_files $OF /etc/slp.conf /etc/slp.reg /etc/slp.spi
		if [ -d /etc/slp.reg.d ]; then
			FILES=$(find /etc/slp.reg.d/ -type f)
			conf_files $OF $FILES
		fi
		log_cmd $OF 'slptool findscopes'
		if log_cmd $OF 'slptool findsrvtypes'
		then
			if [ $ADD_OPTION_SLP -eq 1 ]; then
				echonlog "Please Wait..."
				echonlog Services
				for SERVICE in $(slptool findsrvtypes)
				do
					log_cmd $OF "slptool findsrvs $SERVICE"
				done
			fi
		else
			log_write $OF "ERROR: Unable to get full SLP service lists, check 'slptool findsrvtypes'"
		fi
	fi
	echolog Done
	FILES="/var/log/slpd.log"
	test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
}

ocfs2_info() {
	printlog "OCFS2..."
	test $OPTION_OCFS2 -eq 0 && { echolog Excluded; return 1; }
	OF=ocfs2.txt
	if rpm_verify $OF ocfs2-tools
	then
		check_service $OF o2cb
		check_service $OF ocfs2
		log_cmd $OF "mount"
		timed_log_cmd $OF "mounted.ocfs2 -d"
		timed_log_cmd $OF "mounted.ocfs2 -f"
		conf_files $OF "/etc/ocfs2/cluster.conf /etc/sysconfig/o2cb"
		CHECKDIR="/sys/o2cb"
		if [ -d $CHECKDIR ]; then
			FILES=$(find ${CHECKDIR}/ -type f)
			conf_files $OF $FILES
		fi
		CHECKDIR="/sys/kernel/config/cluster"
		if [ -d $CHECKDIR ]; then
			FILES=$(find ${CHECKDIR}/ -type f)
			conf_files $OF $FILES
		fi
		FILES="/var/log/messages"
		test $ADD_OPTION_LOGS -eq 1 && grep_log_files ocfs $OF 0 $FILES || grep_log_files ocfs $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

memory_info() {
	printlog "Memory Details..."
	test $OPTION_MEM -eq 0 && { echolog Excluded; return 1; }
	OF=memory.txt
	log_cmd $OF "vmstat 1 4"
	log_cmd $OF "free -k"
	conf_files $OF /proc/meminfo /proc/vmstat
	log_cmd $OF 'sysctl -a 2>/dev/null | grep ^vm'
	conf_files $OF /proc/buddyinfo /proc/slabinfo
	if rpm -q numactl &>/dev/null; then
		log_cmd $OF 'numactl --hardware'
		log_cmd $OF 'numastat'
	fi
	echolog Done
}

open_files() {
	printlog "Open Files..."
	test $OPTION_OFILES -eq 0 && { echolog Excluded; return 1; }
	OF=open-files.txt
	if rpm_verify $OF lsof
	then
		log_cmd $OF "lsof -b +M -n -l"
		echolog Done
	else
		echolog Skipped
	fi
}

samba_info() {
	printlog "Samba..."
	test $OPTION_SMB -eq 0 && { echolog Excluded; return 1; }
	OF=samba.txt
	RPMPATH=$LOG/$RPMFILE

	log_cmd $OF "egrep \"samba|smb|cifs\" $RPMPATH"
	log_write $OF

	if rpm_verify $OF samba
	then
		for SERVICE in smb nmb
		do
			check_service $OF $SERVICE
		done
		SAMBA_LIB="/var/lib/samba"
		SAMBA_KRB="$SAMBA_LIB/smb_krb5"
		if [ -d $SAMBA_LIB ]; then
			log_cmd $OF "ls -al $SAMBA_LIB"
			conf_files $OF $SAMBA_LIB/browse.dat $SAMBA_LIB/wins.dat
		fi
		if [ -d $SAMBA_KRB ]; then
			conf_files $OF /etc/krb5.conf ${SAMBA_KRB}/* 
		fi
	fi

	if rpm_verify $OF samba-client
	then
		conf_files $OF /etc/samba/smb.conf
		log_cmd $OF "testparm -sv"
		log_cmd $OF "pdbedit -L"
	fi

	if rpm_verify $OF samba-winbind
	then
		for SERVICE in winbind
		do
			check_service $OF $SERVICE
		done
		log_cmd $OF 'wbinfo -u'
		log_cmd $OF 'wbinfo -g'
		log_cmd $OF 'wbinfo -p'
		log_cmd $OF 'wbinfo --own-domain'
		log_cmd $OF 'wbinfo --trusted-domains'
		log_cmd $OF 'wbinfo --check-secret'
		conf_files $OF /etc/samba/lmhosts /etc/nsswitch.conf /etc/security/pam_winbind.conf
	fi

	if [ -d /var/log/samba ]; then
		FILES=$(find /var/log/samba/ -type f)
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	fi
	
	echolog Done
}

fslist_info() {
	printlog "File System List..."
	test $ADD_OPTION_FSLIST -eq 0 && { echolog Skipped; return 1; }
	echonlog "Please Wait..."
	OF=$FSLIST_FILE
	log_cmd $OF 'find / -print'
	echolog Done
}

smartmon_info() {
	printlog "SMART Disks..."
	test $OPTION_SMART -eq 0 && { echolog Excluded; return 1; }
	OF=fs-smartmon.txt
	if rpm_verify $OF smartmontools
	then
		check_service $OF smartd
		conf_files $OF /proc/partitions /etc/smartd.conf
		for DISK in $(cat /proc/partitions | grep -v ^m | grep -v ^$ | awk '{print $4}')
		do
			case $DISK in
			sd[a-z]|sd[a-z][a-z]) log_cmd smartmon-$DISK "smartctl --all /dev/$DISK" ;;
			hd[a-z]|hd[a-z][a-z]) log_cmd smartmon-$DISK "smartctl --all /dev/$DISK" ;;
			esac
		done
		log_write $OF "#==[ Quick Status Check ]===========================#"
		grep -i "^SMART overall" $LOG/smartmon-* | awk -F/ '{print $5}' >> $LOG/$OF
		log_write $OF 
		cat $LOG/smartmon-* >> $LOG/$OF
		rm -f $LOG/smartmon-*
		echolog Done
	else
		echolog Skipped
	fi
}

ldap_info() {
	printlog "LDAP..."
	test $OPTION_LDAP -eq 0 && { echolog Excluded; return 1; }
	OF=ldap.txt
	SKIP=0

	log_write $OF "#___________________________________________________________#"
	log_write $OF "#____[ LDAP Client Information ]____________________________#"
	log_write $OF
	if rpm_verify $OF pwdutils
	then
		conf_files $OF /etc/ldap.conf /etc/nsswitch.conf /etc/sysconfig/ldap
	else
		((SKIP++))
	fi

	# Right now only openLDAP v2 is supported
	if rpm_verify $OF openldap2-client
	then
		LDAP_BIN="/usr/bin/ldapsearch"
		conf_files $OF /etc/openldap/ldap.conf
		log_write $OF "#==[ Search for LDAP Server's root DSE ]============#"
		if log_cmd $OF "$LDAP_BIN -x -b \"\" -s base \"objectclass=*\""; then
			log_write $OF "LDAP Connection: Success"
		else
			log_write $OF "LDAP Connection: FAILED"
		fi
		log_write $OF
	else
		((SKIP++))
	fi

	# Right now only openLDAP v2 is supported
	log_write $OF "#___________________________________________________________#"
	log_write $OF "#____[ LDAP Server Information ]____________________________#"
	log_write $OF
	if rpm_verify $OF openldap2
	then
		SLAPD_CONF="/etc/openldap/slapd.conf"
		# Extract the SLAPD directory from the conf file
		if [ -f $SLAPD_CONF ]; then
			SLAPD_DIR=$(grep -i ^directory $SLAPD_CONF | awk '{print $2}')
			test -z "$SLAPD_DIR" && SLAPD_DIR="/var/lib/ldap"
			SLAPD_PIDF=$(grep -i ^pidfile $SLAPD_CONF | awk '{print $2}')
			test -z "$SLAPD_PIDF" && SLAPD_PIDF="/var/run/slapd/slapd.pid"
			if [ -f $SLAPD_PIDF ]; then
				SLAPD_PID=$(cat $SLAPD_PIDF)
			else
				SLAPD_PID=""
			fi
			SLAPD_SCHEMAS=$(grep ^include $SLAPD_CONF | awk '{print $2}')
		fi
		check_service $OF ldap
		log_cmd $OF "netstat -nlp | grep slapd"
		log_cmd $OF "ls -al /etc/openldap/schema"
		conf_files $OF $SLAPD_CONF /etc/sysconfig/openldap
		if [ -d $SLAPD_DIR ]; then
			conf_files $OF $SLAPD_DIR/DB_CONFIG
			log_cmd $OF "ls -al $SLAPD_DIR"
		fi
		log_cmd $OF "lsof -p $SLAPD_PID"
		log_write $OF "#___________________________________________________________#"
		log_write $OF "#____[ Schema Files Included in LDAP Server ]_______________#"
		log_write $OF
		log_write $OF "$SLAPD_SCHEMAS"
		log_write $OF
		conf_files $OF $SLAPD_SCHEMAS
	else
		((SKIP++))
	fi

	test $SKIP -lt 3 && echolog Done || echolog Skipped
}

etc_info() {
	printlog "ETC..."
	test $OPTION_ETC -eq 0 && { echolog Excluded; return 1; }
	OF=etc.txt
	conf_files $OF $(find /etc/ -type f | grep conf$)
	conf_files $OF /etc/rc.dialout /etc/ppp/options /etc/ppp/ioptions /etc/ppp/peers/pppoe
	echolog Done
}

sysconfig_info() {
	printlog "SYSCONFIG..."
	test $OPTION_SYSCONFIG -eq 0 && { echolog Excluded; return 1; }
	OF=sysconfig.txt
	for FILE in $(find /etc/sysconfig/ -maxdepth 1 -type f | sort -f)
	do
		conf_files $OF $FILE
	done
	for FDIR in $(find /etc/sysconfig/ -type d | grep -v "/etc/sysconfig$" | sort)
	do
		for FILE in $(find ${FDIR}/ -type f | sort)
		do
			conf_files $OF $FILE
		done
	done
	echolog Done
}

proc_info() {
	printlog "PROC..."
	test $OPTION_PROC -eq 0 && { echolog Excluded; return 1; }
	OF=proc.txt
	for FILE in $(find /proc/ -maxdepth 1 -type f 2>/dev/null | egrep -v "kcore$|config.gz$|kmsg$|sysrq-trigger$|kallsyms$|mm$" | sort -f)
	do
		conf_files $OF $FILE
	done
	echolog Done
}

x_info() {
	printlog "X..."
	test $OPTION_X -eq 0 && { echolog Excluded; return 1; }
	OF=x.txt
	case $SLES_VER in
	80|90) if rpm_verify $OF XFree86
	then
		log_cmd $OF 'ls -al /dev | egrep "video.*|mouse.*"'
		log_cmd $OF '3Ddiag'
		rpm_verify $OF XFree86-Mesa
		rpm_verify $OF XFree86-libs
		conf_files $OF /etc/XF86Config /etc/X11/XF86Config
		if rpm_verify $OF sax2
		then
			log_cmd $OF 'sysp -q mouse'
			log_cmd $OF 'sysp -c'
			log_cmd $OF 'sysp -q keyboard'
			FILES="/var/log/SaX.log"
			test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		fi
		FILES="/var/log/XFree86.[0,1].log /root/.X.err /root/.xsession-errors"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
	;;
	10*|11*) if rpm_verify $OF xorg-x11-server
	then
		log_cmd $OF 'ls -al /dev | egrep "video.*|mouse.*"'
		log_cmd $OF '3Ddiag'
		rpm_verify $OF Mesa
		rpm_verify $OF xorg-x11-libs
		conf_files $OF /etc/sysconfig/displaymanager /etc/sysconfig/windowmanager /etc/X11/xorg.conf
		if rpm_verify $OF sax2
		then
			log_cmd $OF 'sysp -q mouse'
			log_cmd $OF 'sysp -c'
			log_cmd $OF 'sysp -q keyboard'
			log_files $OF $VAR_OPTION_LINE_COUNT /var/log/SaX.log
		fi
		FILES="/var/log/Xorg.[0,1].log /root/.X.err /root/.xsession-errors"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
	;;
	esac
}

ssh_info() {
	printlog "SSH..."
	test $OPTION_SSH -eq 0 && { echolog Excluded; return 1; }
	OF=ssh.txt
	if rpm_verify $OF openssh
	then
		check_service $OF sshd
		conf_files $OF /etc/ssh/sshd_config /etc/ssh/ssh_config /etc/pam.d/sshd
		log_cmd $OF 'netstat -nlp | grep sshd'
		echolog Done
	else
		echolog Skipped
	fi
}

slert_info() {
	printlog "SLERT..."
	test $OPTION_SLERT -eq 0 && { echolog Excluded; return 1; }
	OF=slert.txt
	if rpm_verify $OF kernel-rt
	then
		log_cmd $OF "uname -r"
		check_service $OF slert
		log_cmd $OF "ps -eo pid,user,args,ni,rtprio --sort rtprio"
		conf_files $OF /etc/slert/setup /proc/cpuinfo
		log_cmd $OF "grep cpuset /etc/mtab"
		CPUSET=$(grep ' cpuset ' /etc/mtab | cut -d' ' -f2)
		if [ -n "$CPUSET" ]; then
			log_cmd $OF "find ${CPUSET}/ -type f"
			FILES=$(find ${CPUSET}/ -type f)
			conf_files $OF $FILES
			for TASKS in $(find ${CPUSET}/ -type f | grep tasks)
			do
				log_write $OF "#==[ Task Scheduling ]==============================#"
				log_write $OF "# Threads in CPUSET: $TASKS"
				log_write $OF
				for TASK in $(cat $TASKS)
				do
					log_cmd $OF chrt -p $TASK
				done
			done
		else
			for TASK in $(ps axo pid | sed -e '/PID/d')
			do
				test -e /proc/$TASK && log_cmd $OF "chrt -p $TASK"
			done
		fi
		echolog Done
	else
		echolog Skipped
	fi
}

print_info() {
	printlog "Printing..."
	test $OPTION_PRINT -eq 0 && { echolog Excluded; return 1; }
	OF=print.txt
	SKIP=0
	if rpm_verify $OF cups
	then
		check_service $OF cups
		log_cmd $OF 'netstat -nlp | grep cupsd'
		log_cmd $OF '/usr/lib/cups/backupend/parallel'
		log_cmd $OF '/usr/lib/cups/backupend/usb'
		test -d /etc/cups/ppd && PPDFILES=$(find /etc/cups/ppd/ -type f) || PPDFILES=""
		conf_files $OF /etc/sysconfig/printer /etc/printcap /etc/cups/cupsd.conf /etc/cups/printers.conf /etc/cups/mime.types /etc/cups/mime.convs $PPDFILES
		FILES="/var/log/cups/error_log /var/log/cups/error_log.test /tmp/prnlog"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	else
		((SKIP++))
	fi

	if rpm_verify $OF cups-client
	then
		log_cmd $OF 'lpstat -t'
		log_cmd $OF 'lpc status'
	else
		((SKIP++))
	fi

	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

sar_info() {
	printlog "SAR Files..."
	test $OPTION_SAR -eq 0 && { echolog Excluded; return 1; }
	OF=sar.txt
	SARDIR=/var/log/sa
	SARSCDIR=$LOG/sar
	if rpm_verify $OF sysstat; then
		if [ -d $SARDIR ]; then
			FOUND=$(ls -A1 $SARDIR)
			if [ -n "$FOUND" ]; then
				mkdir -p $SARSCDIR
				log_write $OF "#==[ Command ]======================================#"
				log_write $OF "# cp $SARDIR/sa.* $SARSCDIR"
				if [ $ADD_OPTION_LOGS -eq 1 ]; then
					cp $SARDIR/sa\.* $SARSCDIR &>/dev/null
				else
					log_write $OF "# NOTE: Only the newest $VAR_OPTION_SAR_FILES_LIMIT files are copied"
					for i in $(\ls -A1 $SARDIR/sa\.* 2>/dev/null | tail -$VAR_OPTION_SAR_FILES_LIMIT)
					do
						cp $i $SARSCDIR &>/dev/null
					done
				fi
				echolog Done
			else
				echolog Skipped
			fi
		else
			echolog Skipped
		fi
	else
		echolog Skipped
	fi
}

dns_info() {
	printlog "DNS..."
	test $OPTION_DNS -eq 0 && { echolog Excluded; return 1; }
	OF=dns.txt
	if rpm_verify $OF bind; then
		check_service $OF named
		log_cmd $OF 'netstat -nlp | grep named'
		FILES=$(grep ^include /etc/named.conf | cut -d';' -f1 | sed -e 's/"//g'  | awk '{print $2}')
		conf_files $OF /etc/named.conf $FILES /etc/sysconfig/named
		ZDIR=$(grep ^[[:space:]]*directory /etc/named.conf | cut -d';' -f1 | sed -e 's/"//g'  | awk '{print $2}')
		if [ -n "$ZDIR" ]; then
			FILES=$(find ${ZDIR}/ -type f | grep zone) || unset FILES
			conf_files $OF $FILES
			FILES=$(find ${ZDIR}/ -type f | egrep -v "localtime|zone") || unset FILES
			conf_files $OF $FILES
		fi
		log_cmd $OF "grep named /var/log/warn"
		log_cmd $OF "grep named /var/log/messages"
		echolog Done
	else
		echolog Skipped
	fi
}

cimom_info() {
	printlog "CIMOM..."
	test $OPTION_CIMOM -eq 0 && { echolog Excluded; return 1; }
	OF=cimom.txt
	SKIP=0
	if rpm_verify $OF openwbem; then
		log_cmd $OF "egrep -i \"cim|provider\" $RPMPATH"
		check_service $OF owcimomd
		conf_files $OF /etc/openwbem/openwbem.conf
		log_cmd $OF 'ls -lR /etc/openwbem'
		for i in cert key
		do
			unset OWSSLCHECK
			OWSSLCHECK=$(grep "^http_server.SSL_${i}" /etc/openwbem/openwbem.conf | awk '{print $3}')
			if [ -n "$OWSSLCHECK" ]; then
				if [ -L $OWSSLCHECK ]; then
					case $SLES_VER in
					90) log_cmd $OF "readlink -fv $OWSSLCHECK" ;;
					10*) log_cmd $OF "readlink -ev $OWSSLCHECK" ;;
					esac
				fi
			fi
		done
		log_cmd $OF 'owenumnamespace -u https://localhost/root/cimv2'
		log_cmd $OF 'owenumclassnames -u https://localhost/root/cimv2'
		test -f /var/lib/openwbem/loadmof.log && FILES="/var/lib/openwbem/loadmof.log /var/lib/openwbem/loadmof.log.*" || unset FILES
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
	else
		((SKIP++))
	fi
	if rpm_verify $OF sblim-sfcb; then
		log_cmd $OF "egrep -i \"cim|provider\" $RPMPATH"
		check_service $OF sfcb
		log_cmd $OF "netstat -nlp | grep sfcb"
		conf_files $OF /etc/sfcb/sfcb.cfg
		log_cmd $OF "ls -lR /etc/sfcb"
	else
		((SKIP++))
	fi

	test $SKIP -lt 2 && echolog Done || echolog Skipped
}

ib_info() {
	printlog "InfiniBand..."
	test $OPTION_IB -eq 0 && { echolog Excluded; return 1; }
	OF=ib.txt
	if rpm_verify $OF ofed; then
		check_service $OF openibd
		conf_files $OF /etc/infiniband/openib.conf
		log_cmd $OF 'lspci -b'
		log_cmd $OF 'lspci -n'
		log_cmd $OF 'lsmod'
		log_cmd $OF 'ibv_devinfo -v'
		log_cmd $OF 'ibdiagnet'
		FILES=$(find /tmp/ -type f | grep ibdiagnet)
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		echolog Done
	else
		echolog Skipped
	fi
}

web_info() {
	printlog "Web..."
	test $OPTION_WEB -eq 0 && { echolog Excluded; return 1; }
	OF=web.txt
	if rpm_verify $OF apache2; then
		check_service $OF apache2
		conf_files $OF /etc/sysconfig/apache2 /etc/apache2/httpd.conf
		FILES=$(find /etc/apache2/ -type f | grep 'conf$' | grep -v 'httpd.conf')
		conf_files $OF $FILES
		FILES=$(find /var/log/apache2/ -type f)
		test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		TOMCAT=$(cat $LOG/$RPMFILE | grep 'tomcat' | awk '{print $1}')
		for i in $TOMCAT
		do
			rpm_verify $OF $i
		done
		for WEB_SERVICE in $(ls -1 /etc/init.d/*tomcat* 2>/dev/null)
		do
			check_service $OF $WEB_SERVICE
		done
		if [ -s /etc/sysconfig/j2ee ]; then
			conf_files $OF /etc/sysconfig/j2ee
			. /etc/sysconfig/j2ee
			conf_files $OF $CATALINA_HOME/conf/server.xml $CATALINA_HOME/logs/catalina.out
			FILES="$CATALINA_HOME/logs/catalina.out $CATALINA_HOME/logs/localhost_log*"
			test $ADD_OPTION_LOGS -eq 1 && log_files $OF 0 $FILES || log_files $OF $VAR_OPTION_LINE_COUNT $FILES
		fi
		echolog Done
	else
		echolog Skipped
	fi
}

hppsp_info() {
	OFPSP=psp.txt
	if [ -s /var/log/hppldu.log ]; then
		PSPFILES="/var/log/hppldu.log"
		test $ADD_OPTION_LOGS -eq 1 && log_files $OFPSP 0 $PSPFILES || log_files $OFPSP $VAR_OPTION_LINE_COUNT $PSPFILES
		if [ -d /var/hp ]; then
			PSPCFILES="$(find /var/hp/ -type f)"
			conf_files $OFPSP $PSPCFILES
		fi
	fi
}


sam_info() {
	printlog "Supportability Analysis..."
	test $OPTION_SAM -eq 0 && { echolog Excluded; return 1; }
	OF=sam.txt
	if rpm_verify $OF suse-sam; then
		echonlog "Please Wait..."
		log_cmd $OF 'sam -vvv'
		echolog Done
	else
		echolog Skipped
	fi
}

timed_cmd_cleanup() {
	TIMEOUT_PIDS=$(\ls -A1 $LOG/*SEMAPHORE.pid 2>/dev/null)
	if [ -n "$TIMEOUT_PIDS" ]; then
		test $VAR_OPTION_SILENT -eq 0 && { echo; }
		if (( $VAR_OPTION_SBM )); then
			printlog -b "Command Clean Up..."
		else
			printlog -b "Command Clean Up"
		fi
		for TIMEOUT_PID_FILE in $TIMEOUT_PIDS
		do
			echolog " -> $(basename $TIMEOUT_PID_FILE) ($(cat $TIMEOUT_PID_FILE))"
			PIDS2KILL=$(ps -eaf | grep `cat $TIMEOUT_PID_FILE` 2>/dev/null | grep -v grep | awk '{print $2}')
			kill $PIDS2KILL &>/dev/null
			sleep 1
			PIDS2KILL=$(ps -eaf | grep `cat $TIMEOUT_PID_FILE` 2>/dev/null | grep -v grep | awk '{print $2}')
			if [ -z "$PIDS2KILL" ]; then
				rm -f $TIMEOUT_PID_FILE &>/dev/null
			fi
		done
	fi
}

ascii_plugin() {
	FOUND=$(grep -i elf $PLUGIN_BIN 2>/dev/null)
	if [ -n "$FOUND" ]; then
		return 1
	else
		return 0
	fi
}

bad_plugin_dir() {
	if [ -d $XPLUGIN_DIR ]; then
		XPLUGIN_DIR_OWNER=$(stat -c %u $XPLUGIN_DIR)
		XPLUGIN_DIR_GRP=$(stat -c %g $XPLUGIN_DIR)
		XPLUGIN_DIR_MODE=$(stat -c %a $XPLUGIN_DIR)

		test $XPLUGIN_DIR_OWNER -eq 0 && OWNER_DENIED=0 || OWNER_DENIED=1
		case $XPLUGIN_DIR_GRP in
		0) GROUP_DENIED=0 ;;
		*)	if [ ${#XPLUGIN_DIR_MODE} -eq 3 ]; then
				case ${XPLUGIN_DIR_MODE:1:1} in
				0|1|4|5) GROUP_DENIED=0 ;;
				*) GROUP_DENIED=1 ;;
				esac
			else
				# Don't allow suid, guid, or sticky bits to be set
				GROUP_DENIED=1
			fi
		esac
		if [ ${#XPLUGIN_DIR_MODE} -eq 3 ]; then
			case ${XPLUGIN_DIR_MODE:2:1} in
			0|1|4|5) OTHER_DENIED=0 ;;
			*) OTHER_DENIED=1 ;;
			esac
		else
			# Don't allow suid, guid, or sticky bits to be set
			OTHER_DENIED=1
		fi

		BAD_DIR=0
		test $OWNER_DENIED -gt 0 && ((BAD_DIR++))
		test $GROUP_DENIED -gt 0 && ((BAD_DIR++))
		test $OTHER_DENIED -gt 0 && ((BAD_DIR++))
		test $BAD_DIR -gt 0 && return 0 || return 1
	else
		# good plugin directory
		return 1
	fi
}

exec_plugins() {
	if [ -d $XPLUGIN_DIR ]; then
		printlog "Supportconfig Plugins:"
		if bad_plugin_dir; then
			echolog Skipped
			return 5
		fi
		PLUGIN_CNT=$(\ls -A1 $XPLUGIN_DIR | wc -l)
		echolog $PLUGIN_CNT
		for PLUGIN_FEATURE in $PLUGIN_FEATURES
		do
			PLUGIN=${PLUGIN_FEATURE/p/}
			printlog "  Plugin: ${PLUGIN}..."
			test $((PLUGIN_OPTION_${PLUGIN})) -eq 0 && { echolog Excluded; continue; }
			PLUGIN_ERROR=0
			PLUGIN_SKIP=0
			PLUGIN_LOG_FILE="plugin-${PLUGIN}.txt"
			PLUGIN_LOG="${LOG}/${PLUGIN_LOG_FILE}"
			PLUGIN_BIN="${XPLUGIN_DIR}/${PLUGIN}"

			log_write $PLUGIN_LOG_FILE "#==[ Plugin ]=======================================#"			
			log_write $PLUGIN_LOG_FILE "#==[ Output: $PLUGIN_BIN ]====#"
			log_write $PLUGIN_LOG_FILE

			if [ -x $PLUGIN_BIN ]; then
				timed_log_cmd $PLUGIN_LOG_FILE "$PLUGIN_BIN"
				PLUGIN_RC=$?
				if [ $PLUGIN_RC -ne 0 ]; then
					if [ $PLUGIN_RC -eq 111 ]; then
						((PLUGIN_SKIP++))
					else
						((PLUGIN_ERROR++))
					fi
				fi
			else
				log_write $PLUGIN_LOG_FILE "ERROR: Missing or non-executible plugin"
				((PLUGIN_ERROR++))
			fi
			log_write $PLUGIN_LOG_FILE

			log_write $PLUGIN_LOG_FILE "#==[ Plugin ]=======================================#"			
			log_write $PLUGIN_LOG_FILE "#==[ File: cat -n $PLUGIN_BIN ]====#"
			log_write $PLUGIN_LOG_FILE

			if ascii_plugin; then
				cat -n $PLUGIN_BIN >> $PLUGIN_LOG 2>&1
			else
				log_write $PLUGIN_LOG_FILE "Excluding non ASCII file"
			fi
			log_write $PLUGIN_LOG_FILE

			if ((PLUGIN_ERROR)); then
				echolog Error
			elif ((PLUGIN_SKIP)); then
				echolog Skipped
			else
				echolog Done
			fi
		done
	fi
}

set_to_min() {
	init_plugins off
	for SRCH in OPTION_ ADD_OPTION_
	do
		for i in $(grep ^$SRCH $0 | cut -d= -f1 | sort)
		do
			(( $i=0 ))
		done
	done
	for SRCH in MIN_OPTION_ ADD_OPTION_MIN_
	do
		for i in $(grep ^$SRCH $0 | cut -d= -f1 | sort)
		do
			(( $i=1 ))
		done
	done
}

set_to_all() {
	init_plugins on
	for SRCH in OPTION_ ADD_OPTION_ MIN_OPTION_
	do
		for i in $(grep ^$SRCH $0 | cut -d= -f1 | sort)
		do
			(( $i=1 ))
		done
	done
	for SRCH in ADD_OPTION_MIN_
	do
		for i in $(grep ^$SRCH $0 | cut -d= -f1 | sort)
		do
			(( $i=0 ))
		done
	done
}

set_to_default() {
	init_plugins on
	DEF_FILE=$(mktemp /tmp/defoption.XXXXXXXX)
	for SRCH in OPTION_ ADD_OPTION_ MIN_OPTION_ VAR_OPTION_
	do
		for i in $(grep ^$SRCH $0 | sort)
		do
			echo "$i" >> $DEF_FILE
		done
	done
	grep ^VAR_OPTION_ $0 | sort >> $DEF_FILE
	. $DEF_FILE
	rm -f $DEF_FILE
}

valid_srnum() {
	if echo $CONTACT_SRNUM | egrep "[[:alpha:]|[:space:]]" &>/dev/null; then
		return 1
	elif [ ${#CONTACT_SRNUM} -ne $SRLEN ]; then
		return 1
	else
		return 0
	fi
}

check_log_dir() {
	# if supportconfig repeats execution too fast, make sure the directory is unique so files are not overwritten
	ORIGBASE=$BASE
	while [ -d $LOG -o -f ${LOG}.${COMPRESS} ]
	do
		test -x /usr/bin/uuidgen && BASE="${ORIGBASE}_$(uuidgen 2>/dev/null)" || BASE="${ORIGBASE}_$(date +%s%N)"
		LOG=/var/log/$BASE
	done
}

get_features() {
	FEATURES=$(grep ^OPTION_ $0 | cut -d= -f1 | sed -e 's/OPTION_//g')
	ADDITIONAL_FEATURES=$(grep ^ADD_OPTION_ $0 | cut -d= -f1 | sed -e 's/ADD_OPTION_/a/g')
	echo $FEATURES $ADDITIONAL_FEATURES $PLUGIN_FEATURES
}

# Default state is "on", unless "off" is specified as a parameter
init_plugins() {
	case $1 in
	off) FEATURE_STATE=0 ;;
	*) FEATURE_STATE=1 ;;
	esac
	test -d $XPLUGIN_DIR && PLUGIN_FEATURES=$(\ls -A1 $XPLUGIN_DIR | sed -e 's/^/p/g') || PLUGIN_FEATURES=""
	for PLUGIN_FEATURE in $PLUGIN_FEATURES
	do
		eval PLUGIN_OPTION_${PLUGIN_FEATURE/p/}=$FEATURE_STATE
	done
}

# Requires one parameter with value "on" or "off"
selected_features() {
	INVALID_KEYWORDS=0
	case $1 in
	on) FEATURE_STATE=1 ;;
	off) FEATURE_STATE=0 ;;
	*) echo "ERROR: selected_features: Invalid FEATURE_STATE, $1"; exit 10 ;;
	esac
	FEATURE_LIST="$(get_features)"
	for FEATURE in $(echo $SELECTED_FEATURE_LIST | sed -e 's/,/ /g')
	do
		if echo $FEATURE_LIST | grep $FEATURE &>/dev/null; then
			case ${FEATURE:0:1} in
			a) eval ADD_OPTION_${FEATURE/a/}=${FEATURE_STATE} ;;
			p) eval PLUGIN_OPTION_${FEATURE/p/}=${FEATURE_STATE} ;;
			*) eval OPTION_${FEATURE}=${FEATURE_STATE} ;;
			esac
		else
			echo "ERROR: Invalid Feature Keyword: $FEATURE"
			((INVALID_KEYWORDS++))
		fi
	done
	if (( INVALID_KEYWORDS )); then
		echo "Use -F for a list of valid feature keywords. Keywords are case sensitive."
		echo
		exit 11
	fi
}

toggle_features() {
	INVALID_KEYWORDS=0
	FEATURE_LIST="$(get_features)"
	for FEATURE in $(echo $SELECTED_FEATURE_LIST | sed -e 's/,/ /g')
	do
		if echo $FEATURE_LIST | grep $FEATURE &>/dev/null; then
			case ${FEATURE:0:1} in
			a) [ $(( ADD_OPTION_${FEATURE/a/} )) -eq 0 ] && eval ADD_OPTION_${FEATURE/a/}=1 || eval ADD_OPTION_${FEATURE/a/}=0 ;;
			p) [ $(( PLUGIN_OPTION_${FEATURE/p/} )) -eq 0 ] && eval PLUGIN_OPTION_${FEATURE/p/}=1 || eval PLUGIN_OPTION_${FEATURE/p/}=0 ;;
			*) [ $(( OPTION_${FEATURE} )) -eq 0 ] && eval OPTION_${FEATURE}=1 || eval OPTION_${FEATURE}=0 ;;
			esac
		else
			echo "ERROR: Invalid Feature Keyword: $FEATURE"
			((INVALID_KEYWORDS++))
		fi
	done
	if (( INVALID_KEYWORDS )); then
		echo "Use -F for a list of valid feature keywords. Keywords are case sensitive."
		echo
		exit 11
	fi
}

ehr() {
	echo "-----------------------------------------------------------------------------"
}

encrypt_tarball() {
	FOUND_KEY=$(gpg --list-keys 2>/dev/null | grep "$VAR_OPTION_GPG_UID" 2>/dev/null)
	if [ -z "$FOUND_KEY" ]; then
		echo "ERROR: GPG key not found: $VAR_OPTION_GPG_UID"
		echo "       File encryption failed, aborting"
		echo
		gpg --list-keys
		exit 13
	fi
	if (( VAR_OPTION_SILENT )); then
		gpg --batch --yes --trust-model always --encrypt --recipient "$VAR_OPTION_GPG_UID" $TARBALL &> /dev/null
		ERR=$?
		if [ $ERR -ne 0 ]; then
			echo "ERROR: gpg failed, RC=$ERR, aborting"
			echo
			exit 13
		fi
	else
		if (( $VAR_OPTION_SBM )); then
			echo "Encrypting Tar Ball..."
		else
			echo "Encrypting Tar Ball"
			ehr
		fi
		echo
		echo "Using GPG Key:  $VAR_OPTION_GPG_UID"
		echo "Command:        gpg --batch --yes --trust-model always --encrypt --recipient \"$VAR_OPTION_GPG_UID\" $TARBALL"
		gpg --batch --yes --trust-model always --encrypt --recipient "$VAR_OPTION_GPG_UID" $TARBALL
		ERR=$?
		if [ $ERR -ne 0 ]; then
			echo "ERROR: gpg failed, RC=$ERR, aborting"
			echo
			exit 13
		fi
		ENCRYPTED_TARBALL=1
		echo "Encrypted File: ${TARBALL}.gpg"
		echo
	fi
}

upload_tarball() {
	if (( UPLOAD_TARBALL )); then
		TARBALL_FILE=$(basename $TARBALL)
		UPLOAD_SERVICE=$(echo ${VAR_OPTION_UPLOAD_TARGET} | cut -d: -f1)
		if (( VAR_OPTION_SILENT )); then
			case $UPLOAD_SERVICE in
			ftp)
				UPLOAD_URL=$(echo ${VAR_OPTION_UPLOAD_TARGET} | sed -e 's!ftp://!!g;s!/!:/!')
				if (( ENCRYPTED_TARBALL )); then
					ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}.md5" "${TARBALL}.md5" &>/dev/null
					ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}.gpg" "${TARBALL}.gpg" &>/dev/null
				else
					ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}.md5" "${TARBALL}.md5" &>/dev/null
					ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}" "${TARBALL}" &>/dev/null
				fi
				;;
			scp)
				UPLOAD_URL=$(echo ${VAR_OPTION_UPLOAD_TARGET} | sed -e 's!scp://!!g;s!/!:/!')
				if (( ENCRYPTED_TARBALL )); then
					scp -qp "${TARBALL}.md5" "${UPLOAD_URL}/${TARBALL_FILE}.md5" &>/dev/null
					scp -qp "${TARBALL}.gpg" "${UPLOAD_URL}/${TARBALL_FILE}.gpg" &>/dev/null
				else
					scp -qp "${TARBALL}.md5" "${UPLOAD_URL}/${TARBALL_FILE}.md5" &>/dev/null
					scp -qp "${TARBALL}" "${UPLOAD_URL}/${TARBALL_FILE}" &>/dev/null
				fi
				;;
			http|https)
				if (( ENCRYPTED_TARBALL )); then
					UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.md5/g")
					curl -s -L -A SupportConfig -T "${TARBALL}.md5" "${UPLOAD_URL}" &>/dev/null
					UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.gpg/g")
					curl -s -L -A SupportConfig -T "${TARBALL}.gpg" "${UPLOAD_URL}" &>/dev/null
				else
					UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.md5/g")
					curl -s -L -A SupportConfig -T "${TARBALL}.md5" "${UPLOAD_URL}" &>/dev/null
					UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}/g")
					curl -s -L -A SupportConfig -T "${TARBALL}" "${UPLOAD_URL}" &>/dev/null
				fi
				;;
			*)
				exit 7
				;;
			esac
		else
			if (( $VAR_OPTION_SBM )); then
				echo "Uploading Tar Ball..."
			else
				echo "Uploading Tar Ball"
				ehr
			fi
			echo
			case $UPLOAD_SERVICE in
			ftp)
				UPLOAD_URL=$(echo ${VAR_OPTION_UPLOAD_TARGET} | sed -e 's!ftp://!!g;s!/!:/!')
				if (( VAR_OPTION_SBM )); then
					if (( ENCRYPTED_TARBALL )); then
						ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}.md5" "${TARBALL}.md5" &>/dev/null
						ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}.gpg" "${TARBALL}.gpg" &>/dev/null
					else
						ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}.md5" "${TARBALL}.md5" &>/dev/null
						ftp -Vu "${UPLOAD_URL}/${TARBALL_FILE}" "${TARBALL}" &>/dev/null
					fi
				else
					echo "ftp -vu \"${UPLOAD_URL}/${TARBALL_FILE}.md5\" \"${TARBALL}.md5\""
					echo
					ftp -vu "${UPLOAD_URL}/${TARBALL_FILE}.md5" "${TARBALL}.md5"
					echo
					if (( ENCRYPTED_TARBALL )); then
						echo "ftp -vu \"${UPLOAD_URL}/${TARBALL_FILE}.gpg\" \"${TARBALL}.gpg\""
						echo
						ftp -vu "${UPLOAD_URL}/${TARBALL_FILE}.gpg" "${TARBALL}.gpg"
					else
						echo "ftp -vu \"${UPLOAD_URL}/${TARBALL_FILE}\" \"${TARBALL}\""
						echo
						ftp -vu "${UPLOAD_URL}/${TARBALL_FILE}" "${TARBALL}"
					fi
				fi
				;;
			scp)
				UPLOAD_URL=$(echo ${VAR_OPTION_UPLOAD_TARGET} | sed -e 's!scp://!!g;s!/!:/!')
				if (( VAR_OPTION_SBM )); then
					if (( ENCRYPTED_TARBALL )); then
						scp -qp "${TARBALL}.md5" "${UPLOAD_URL}/${TARBALL_FILE}.md5" &>/dev/null
						scp -qp "${TARBALL}.gpg" "${UPLOAD_URL}/${TARBALL_FILE}.gpg" &>/dev/null
					else
						scp -qp "${TARBALL}.md5" "${UPLOAD_URL}/${TARBALL_FILE}.md5" &>/dev/null
						scp -qp "${TARBALL}" "${UPLOAD_URL}/${TARBALL_FILE}" &>/dev/null
					fi
				else
					echo "scp -p \"${TARBALL}.md5\" \"${UPLOAD_URL}/${TARBALL_FILE}.md5\""
					echo
					scp -p "${TARBALL}.md5" "${UPLOAD_URL}/${TARBALL_FILE}.md5"
					echo
					if (( ENCRYPTED_TARBALL )); then
						echo "scp -p \"${TARBALL}.gpg\" \"${UPLOAD_URL}/${TARBALL_FILE}.gpg\""
						echo
						scp -p "${TARBALL}.gpg" "${UPLOAD_URL}/${TARBALL_FILE}.gpg"
					else
						echo "scp -p \"${TARBALL}\" \"${UPLOAD_URL}/${TARBALL_FILE}\""
						echo
						scp -p "${TARBALL}" "${UPLOAD_URL}/${TARBALL_FILE}"
					fi
				fi
				;;
			http|https)
				if (( VAR_OPTION_SBM )); then
					if (( ENCRYPTED_TARBALL )); then
						UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.md5/g")
						curl -s -L -A SupportConfig -T "${TARBALL}.md5" "${UPLOAD_URL}" &>/dev/null
						UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.gpg/g")
						curl -s -L -A SupportConfig -T "${TARBALL}.gpg" "${UPLOAD_URL}" &>/dev/null
					else
						UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.md5/g")
						curl -s -L -A SupportConfig -T "${TARBALL}.md5" "${UPLOAD_URL}" &>/dev/null
						UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}/g")
						curl -s -L -A SupportConfig -T "${TARBALL}" "${UPLOAD_URL}" &>/dev/null
					fi
				else
					UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.md5/g")
					echo "curl -v -L -A SupportConfig -T \"${TARBALL}.md5\" \"${UPLOAD_URL}\""
					echo
					curl -v -L -A SupportConfig -T "${TARBALL}.md5" "${UPLOAD_URL}"
					echo
					if (( ENCRYPTED_TARBALL )); then
						UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}.gpg/g")
						echo "curl -v -L -A SupportConfig -T \"${TARBALL}.gpg\" \"${UPLOAD_URL}\""
						echo
						curl -v -L -A SupportConfig -T "${TARBALL}.gpg" "${UPLOAD_URL}"
					else
						UPLOAD_URL=$(echo $VAR_OPTION_UPLOAD_TARGET | sed -e "s/{[Tt][Aa][Rr][Bb][Aa][Ll][Ll]}/${TARBALL_FILE}/g")
						echo "curl -v -L -A SupportConfig -T \"${TARBALL}\" \"${UPLOAD_URL}\""
						echo
						curl -v -L -A SupportConfig -T "${TARBALL}" "${UPLOAD_URL}"
					fi
				fi
				;;
			*)
				echo "ERROR: Unsupported upload service type: ${UPLOAD_SERVICE}"
				echo
				echo "  Supported service types: ftp, scp"
				echo "  Example URI: ftp://ftp.novell.com/incoming"
				echo
				echo "  VAR_OPTION_UPLOAD_TARGET=\"${VAR_OPTION_UPLOAD_TARGET}\""
				;;
			esac
			echo
		fi
	fi
}

##############################################################################
#  main 
##############################################################################


CURRENTUID=$(id -u)
if [ $CURRENTUID -ne 0 ]; then
	echo "ERROR: You must be logged in as root."
	echo "       $(id)"
	echo
	exit 1
fi
init_plugins on
NSA_CHECK=0
ALL_ARGS="$@"
while getopts :\#ACDFG:LQT:O:E:M:N:P:I:S:X:H:R:U:W:bdeghi:klmo:pqr:suvx:yt:f: TMPOPT
do
	case $TMPOPT in
	\:)	clear; title
			case $OPTARG in
			*) echo "ERROR: Missing Argument -$OPTARG"
				;;
			esac
			echo; show_help; exit 0 ;;
	\?)	clear; title
			case $OPTARG in
			*) echo "ERROR: Invalid Option -$OPTARG"
				;;
			esac
			echo; show_help; exit 0 ;;
	A) set_to_all ;;
	C) clear; title; echo "Overwriting $SC_CONF with default options."; gen_sysconfig; exit 0 ;;
	D) set_to_default ;;
	F) get_features; exit 0 ;;
	G) VAR_OPTION_GPG_UID="$OPTARG" ;;
	L) ADD_OPTION_FSLIST=1 ;;
	Q) VAR_OPTION_SILENT=1 ;;
	T)	VAR_OPTION_BIN_TIMEOUT_SEC=$OPTARG ;;
	O)	VAR_OPTION_CONTACT_COMPANY="$OPTARG" ;;
	E) VAR_OPTION_CONTACT_EMAIL="$OPTARG" ;;
	M) VAR_OPTION_CONTACT_TERMINALID="$OPTARG" ;;
	N) VAR_OPTION_CONTACT_NAME="$OPTARG" ;;
	P) VAR_OPTION_CONTACT_PHONE="$OPTARG" ;;
	R) VAR_OPTION_LOG_DIRS="$OPTARG" ;;
	I) VAR_OPTION_LINE_COUNT=$OPTARG ;;
	X) VAR_OPTION_MSG_MAXSIZE=$OPTARG ;;
	H) VAR_OPTION_PENGINE_FILES_LIMIT=$OPTARG ;;
	S) VAR_OPTION_SAR_FILES_LIMIT=$OPTARG ;;
	U) VAR_OPTION_UPLOAD_TARGET="$OPTARG" && UPLOAD_TARBALL=1 ;;
	W) VAR_OPTION_CONTACT_STOREID="$OPTARG" ;;
	b) VAR_OPTION_SBM=1 ;;
	d) ADD_OPTION_MINDISK=1 ;;
	e) ADD_OPTION_EDIR=1 ;;
	g) COMPRESS="tgz"; COMPRESS_OPT="zcf" ;;
	h) title; show_help; exit 0 ;;
	i) SELECTED_FEATURE_LIST=$OPTARG; set_to_min; selected_features on ;;
	k) MIN_OPTION_AUTOMOD=0 ;;
	l) ADD_OPTION_LOGS=1 ;;
	p) init_plugins off ;;
	m) set_to_min ;;
	o) SELECTED_FEATURE_LIST=$OPTARG; toggle_features ;;
	q) VAR_OPTION_UNIQUE_FILE=1 ;;
	r) CONTACT_SRNUM=$OPTARG;
		if valid_srnum; then
			BASE="nts_SR${CONTACT_SRNUM}_${SC_SRV}_${SC_TIME}"
		else
			clear; title
			echo "ERROR: Invalid SR Number, -${TMPOPT} $CONTACT_SRNUM"
			echo "       Must be an $SRLEN digit numeric value."
			echo; show_help; exit 2
		fi ;;
	\#) set_to_min; MIN_OPTION_HC=0; MIN_OPTION_HARDWARE=0; MIN_OPTION_YAST=0; MIN_OPTION_SYSLOGS=0; NSA_CHECK=1; COMPRESS="tgz"; COMPRESS_OPT="zcf" ;;
	s) ADD_OPTION_SLP=1 ;;
	u) UPLOAD_TARBALL=1 ;;
	v) ADD_OPTION_RPMV=1 ;;
	x) SELECTED_FEATURE_LIST=$OPTARG; set_to_all; selected_features off ;;
	y) ADD_OPTION_MINYAST=1 ;;
	t) TARGET_DIRECTORY=$OPTARG && SAVE_LOGS_ONLY=1;;
	f) FROM_DIRECTORY=$OPTARG  && USE_SAVED_LOGS_ONLY=1;;
	esac
done

test $ADD_OPTION_EDIR -eq 1 && ADD_OPTION_FSLIST=1
test $ADD_OPTION_LOGS -eq 1 && ADD_OPTION_MINYAST=0

umask 0077

get_sles_ver

if [ -n "$TARGET_DIRECTORY" ]; then
	VAR_OPTION_LOG_DIRS=$TARGET_DIRECTORY
fi

# Ensures files uploaded to a novell.com address have unique file names
if (( UPLOAD_TARBALL )); then
	TONOVELL=$(echo $VAR_OPTION_UPLOAD_TARGET | grep -i "novell.com")
	[ -n "$TONOVELL" ] && VAR_OPTION_UNIQUE_FILE=1
fi

if (( VAR_OPTION_UNIQUE_FILE )); then
	test -x /usr/bin/uuidgen && BASE="${BASE}_$(uuidgen 2>/dev/null)" || BASE="${BASE}_$(date +%s%N)"
fi

if [ -n "$FROM_DIRECTORY" ]; then
	VAR_OPTION_LOG_DIRS=$FROM_DIRECTORY
	BASE=$(ls -t $FROM_DIRECTORY | grep nts | head -n1)
fi

for LOG in $VAR_OPTION_LOG_DIRS
do
	# If a full path was not assigned, the cwd will be prepended to the LOG path
	VALID_LOG=$(echo $LOG | grep '^/')
	if [ -z "$VALID_LOG" ]; then
		VALID_LOG=$(echo $LOG | grep '^\./')
		CURRENT_PATH="$(pwd)"
		if [ -n "$VALID_LOG" ]; then
			LOG="${CURRENT_PATH}/${LOG:2}"
		else
			LOG="${CURRENT_PATH}/${LOG}"
		fi
	fi
	# Create the paths
	LOG=${LOG}/${BASE}
	[ $USE_SAVED_LOGS_ONLY -eq 0 ] && check_log_dir
	if mkdir -p $LOG &>/dev/null; then 
		unset LOGERROR
		break
	else
		echo "ERROR: Cannot create $LOG"
		LOGERROR=1
	fi
done

test $LOGERROR && { echo; exit 3; }
PREFERRED_LOG_DIR=/var/log
CURRENT_LOG_DIR=$(dirname $LOG)

if [ "$USE_SAVED_LOGS_ONLY" != "1" ]; then

	if ! (( $VAR_OPTION_SILENT )); then
		if ! (( $VAR_OPTION_SBM )); then
			clear
		fi
	fi
	test $VAR_OPTION_SILENT -gt 0 && title >> $LOG/$BASIC_ENVF || title | tee -a $LOG/$BASIC_ENVF

	rpm_verify ${CSFILE} supportutils

	echolog "Gathering system information"
	if [ "$CURRENT_LOG_DIR" != "$PREFERRED_LOG_DIR" ]; then
		echolog "  NOTICE: Using alternate log directory $CURRENT_LOG_DIR"
	fi
	if bad_plugin_dir; then
		echolog "  WARNING: Invalid plugin directory, all plugins will be skipped."
		echo    "           See $CSFILE for details."
		log_write ${CSFILE} "   Plugin Directory:  $XPLUGIN_DIR"
		log_write ${CSFILE} "   Owner.Group:       ${XPLUGIN_DIR_OWNER}.${XPLUGIN_DIR_GRP}"
		log_write ${CSFILE} "   Access Rights:     $XPLUGIN_DIR_MODE"
		log_write ${CSFILE} "   The plugin directory should be writable only for root and group root."
		log_write ${CSFILE} "   Currently SUID, SGID and sticky bits are not allowed."
	fi
	log_write ${CSFILE} "  Environment Value: $SLES_VER ($KERNVER)"
	log_write ${CSFILE} "  Command with Args: $0 $ALL_ARGS"
	test -s $SC_CONF && log_write ${CSFILE} "  Using Options:     $SC_CONF"
	echolog

	log_options

	basic_healthcheck	#Minimum Requirement
	rpm_info				#Minimum Requirement
	basic_environment	#Minimum Requirement
	basic_report
	module_info
	memory_info
	disk_info
	messages_file		#Minimum Requirement
	yast_files			#Minimum Requirement
	fslist_info
	crash_info
	ntp_info
	proc_info
	boot_info
	slert_info
	update_info
	test $SLES_VER -lt 110 && update_d_info
	smt_info
	novell_edir_info
	novell_lum_info
	novell_ncp_info
	novell_nss_info
	novell_ncs_info
	novell_afp_info
	novell_cifs_info
	ha_info
	ocfs2_info
	pam_info
	ldap_info
	cimom_info
	open_files
	environment_info
	etc_info
	sysconfig_info
	chkconfig_info
	cron_info
	udev_info
	lvm_info
	evms_info
	soft_raid_info
	mpio_info
	net_info
	web_info
	test $SLES_VER -ge 100 && ib_info
	dns_info
	slp_info
	ssh_info
	iscsi_info
	samba_info
	nfs_info
	autofs_info
	sar_info
	apparmor_info
	test $SLES_VER -ge 100 && xen_info
	x_info
	print_info
	smartmon_info
	hardware_info		#Minimum Requirement
	test $SLES_VER -ge 110 && sam_info
	rpm_full_verify
	exec_plugins
	test $OPTION_MOD -eq 0 || log_cmd modules.txt 'lsmod'

	rm -f $LOG/$RPM_QA_FILE $LOG/$RPM_DIST_FILE
	timed_cmd_cleanup
	test $VAR_OPTION_SILENT -eq 0 && { echo; }

else
	test $VAR_OPTION_SILENT -eq 0 && { clear; title; }
fi

# don't continue if SAVE_LOGS_ONLY is set
[ "$SAVE_LOGS_ONLY" = "1" ] && exit 0;


# creating tar ball for NTS
TARBALL=${LOG}.${COMPRESS}
if ! (( $VAR_OPTION_SILENT )); then
	if (( $VAR_OPTION_SBM )); then
		echo 'Creating Tar Ball...'
	else
		echo 'Creating Tar Ball'
	fi
fi
cd $LOG
cd ..
tar ${COMPRESS_OPT} ${TARBALL} ${BASE}/*
LOGSIZE=$(ls -lh ${TARBALL} | awk '{print $5}')
md5sum $TARBALL | awk '{print $1}' > ${TARBALL}.md5
LOGMD5=$(cat ${TARBALL}.md5)


rm -rf $LOG

if [ $VAR_OPTION_SILENT -eq 0 ]; then
cat << EOF1

==[ DONE ]===================================================================
  Log file tar ball: ${TARBALL}
  Log file size:     ${LOGSIZE}
  Log file md5sum:   ${LOGMD5}

  Please attach the log file tar ball to your open Service Request at the 
  following URL:
  https://secure-support.novell.com/eService_enu

  You can also upload the tar ball to ftp.novell.com/incoming, or just use
  supportconfig -ur <srnum>, to upload the tar ball automatically.

  If you cannot attach the tar ball to the SR, then email it to the engineer.
=============================================================================


EOF1
fi

trap "{ echo TERMINATED BY USER; echo; exit 5; }" SIGINT
trap "{ echo SKIPPED BY USER; return 4; }" SIGQUIT

test -n "$VAR_OPTION_GPG_UID" && encrypt_tarball
upload_tarball

