#!/bin/bash
#
# ::copy::
# ::maintainer::
#
# temp script to get various system infos, recorded into /tmp/$CMD.tmp dir
#
CMD=`basename $0`
tdir=/tmp/$CMD.tmp

rm -rf $tdir
mkdir $tdir || exit $?

files="
	/etc/kusa/kusa.conf
	/root/port-from-original.sh
	/etc/kubackup-*.conf
"

for file in `ls $files 2>/dev/null`
do
	cp -a "$file" $tdir/.
done


if [ -f /etc/lsb-release ]
then
	cat /etc/lsb-release | grep DISTRIB_RELEASE | sed -e 's/.*=//' > $tdir/release
elif [ -f /etc/fedora-release ]
then
	cat /etc/fedora-release | sed \
		-e 's/.* release /fc/' \
		-e 's/ .*//' \
		> $tdir/release
elif [ -f /etc/mandriva-release ]
then
	cat /etc/mandriva-release | sed \
		-e 's/.* release //' \
		-e 's/ .*//' \
		> $tdir/release
fi

uname -r > $tdir/kernel

[ -f /etc/motd.tail ] && {
	grep 'system.*updated' /etc/motd.tail | sed -e 's/.* on //' > $tdir/updated
}

[ "`which xm 2>/dev/null`" != "" ] && {
	xm list 2>/dev/null | sed -e '1,2d' -e 's/ .*//' > $tdir/xmlist
}

[ "`which virsh 2>/dev/null`" != "" ] && {
	virsh list > $tdir/vmlist
}

cp /dev/null $tdir/users

for dir in `ls /home`
do
	[ -d /home/$dir ] || continue
	[ $dir == "lost+found" ] && continue
	echo $dir
done > $tdir/users

exit 0
