#!/bin/sh
#
# This file is released under the terms of the Artistic License.
# Please see the file LICENSE, included in this package, for details.
#
# Copyright The DBT-2 Authors
#

while getopts "o:" opt; do
	case ${opt} in
	o)
		OUTPUT_DIR=${OPTARG}
		mkdir -p $OUTPUT_DIR
		;;
	esac
done

echo "$(uname -o) $(uname -m) $(uname -r)" > ${OUTPUT_DIR}/uname.txt

SYSCTL="/sbin/sysctl"
if [ ! -f "${SYSCTL}" ]; then
	SYSCTL=true
fi

# I don't think capturing error messages is important here.
OS=`uname -s`
if [ -f ${SYSCTL} ]; then
	if [ "x${OS}" = "xLinux" ]; then
		${SYSCTL} -a 2> /dev/null | sort > ${OUTPUT_DIR}/proc.txt
	elif [ "x${OS}" = "xSunOS" ]; then
		${SYSCTL} -a 2> /dev/null | sort > ${OUTPUT_DIR}/proc.txt
	else
		echo "Unknown OS: ${OS}"
	fi
fi
