#!/bin/ksh -p
# $Id: //depot/stable/explorer/tools/sunray#2 $
#
# Explorer Version:
EXP_VERSION=4.0
#

# Source tools functions
. ${EXP_LIB}/exp_tools

# Run if specified to do so
script=${0##*/}
which_gate_exit $script default all

TEXT=`gettext "SUNWuto not installed"`
require "pkginfo -q SUNWuto" "${TEXT}"

# Collect Configuration files
get_file "/etc/opt/SUNWut/auth.props"                        sunray/
get_file "/etc/opt/SUNWut/auth.props.bak"                    sunray/
get_file "/etc/opt/SUNWut/gmSignature"                       sunray/
get_file "/var/tmp/SUNWut/utpreserve.tar"                    sunray/
get_file "/etc/opt/SUNWut/utsettings_defaults.properties"    sunray/
get_file "/etc/opt/SUNWut/utsettings_mandatory.properties"   sunray/
get_file "/etc/opt/SUNWut/utadmin.conf"                      sunray/
get_file "/etc/opt/SUNWut/policy/utpolicy"                   sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsnmprad.conf"      sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsnmpserv.conf"     sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.acl.conf"    sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.at.conf"     sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.at.ut.conf"  sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.conf"        sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.ini"         sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.oc.conf"     sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dsserv.oc.ut.conf"  sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dswebfilter.conf"   sunray/
get_file "/etc/opt/SUNWconn/ldap/current/dswebfriendly.conf" sunray/
get_file "/etc/opt/SUNWconn/ldap/current/ldapfilter.conf"    sunray/
get_file "/etc/opt/SUNWconn/ldap/current/ldapsync.conf"      sunray/
get_file "/etc/opt/SUNWconn/ldap/current/ldaptemplates.conf" sunray/

# Collect message/log files:
get_file "/var/opt/SUNWut/log/admin_log*"               sunray/
get_file "/var/opt/SUNWut/log/auth_log*"                sunray/
get_file "/var/opt/SUNWut/log/messages*"                sunray/
get_file "/var/opt/SUNWconn/ldap/log/*.log"             sunray/
get_file "/var/opt/SUNWconn/ldap/log/dsserv.replog"     sunray/
get_file "/var/opt/SUNWconn/ldap/replog/dspushd.replog" sunray/
get_file "/var/opt/SUNWconn/ldap/replog/dspulld.status" sunray/
get_file "/var/http/utadmin/websites/default_site/logs" sunray/

# Collect other configuration information - output from the following commands:
get_cmd "/opt/SUNWut/sbin/utgstatus"       sunray/
get_cmd "/opt/SUNWut/sbin/utreplica -l"    sunray/
get_cmd "/opt/SUNWut/sbin/utuser -L"       sunray/
get_cmd "/opt/SUNWut/sbin/utuser -L -g"    sunray/
get_cmd "/opt/SUNWut/sbin/utpolicy"        sunray/
get_cmd "/opt/SUNWut/sbin/utglpolicy"      sunray/
get_cmd "/opt/SUNWut/sbin/utadm -p"        sunray/
get_cmd "/opt/SUNWut/sbin/utcard -l"       sunray/
get_cmd "/opt/SUNWut/sbin/utdesktop -L -c" sunray/
get_cmd "/opt/SUNWut/sbin/utdesktop -l -g" sunray/
get_cmd "/opt/SUNWut/sbin/utmhadm"         sunray/
get_cmd "/bin/ls -lR /tftpboot"            sunray/
get_cmd "/bin/ls -lR /tmp/SUNWut"          sunray/
get_cmd "/bin/ls -lR /var/opt/SUNWut"      sunray/
get_cmd "/bin/ls -lR /var/opt/SUNWconn"    sunray/
get_cmd "/usr/sbin/dhtadm -P"              sunray/

for NET in `/opt/SUNWut/sbin/utadm -p | nawk '{ print $3 }' | sed -e '/Network/d'`
do
    get_cmd "/usr/sbin/pntadm -P ${NET}" sunray/
done

for pkg in SUNWuta SUNWutj SUNWutk SUNWutkx SUNWutm SUNWuto SUNWutr SUNWutu SUNWutux
do
    get_cmd "/usr/sbin/pkgchk ${pkg}" sunray/
done

get_file "/etc/dt/config/Xservers" sunray/
get_file "/etc/dt/config/Xconfig"  sunray/

get_dir  "/var/opt/SUNWut/ndbm" sunray/

get_file "/var/dhcp/dhcptab"                        sunray/
get_file "/etc/dt/config/Xservers.SUNWut.prototype" sunray/
get_file "/etc/dt/config/Xconfig.SUNWut.prototype"  sunray/
get_file "/usr/dt/config/Xstartup"                  sunray/
get_file "/var/dt/Xerrors"                          sunray/

# Collect files added/modified by the installation process: 
get_file "/etc/dt/config/sessionetc" sunray/

# Get Sunray VERSION
VERSION=`pkgparam SUNWuto VERSION | cut -c1-3`
case "${VERSION}" in
    1.0|1.1|1.2)
	# Collect installation logs (pre-1.3)
	get_file "/var/tmp/utinstall.*.log"            sunray/
	get_file "/var/tmp/utconfig.*.log"             sunray/
	get_file "/var/opt/SUNWut/tmp/utreplica.*.log" sunray/

	if [ "${VERSION}" = "1.2" ]
	then
	    get_cmd "/opt/SUNWut/bin/utxconfig -o" sunray/
	fi
	;;
    *)
	get_cmd "/opt/SUNWut/bin/utxconfig -o" sunray/

	get_dir recursive "/var/opt/SUNWut/kiosk" sunray/

        get_file "/var/adm/log/ut*" sunray/
	;;
esac
