#!/bin/sh
# $NetBSD: script3,v 1.2 2004/03/09 21:36:37 garbled Exp $

NUM=`grep -c "^$1" /etc/ssh/sshd_config`

if [ "$2" = "1" ]; then
	VAR=`grep "^$1" /etc/ssh/sshd_config | awk '{print $2}' | head -1`
	if [ -z "$VAR" ]; then
		VAR=`grep "^$1" /usr/share/sushi/system/sshdconf/defaults | awk '{print $2}' | head -1`
	fi
fi
if [ "$2" = "2" ]; then
	if [ $NUM -gt 1 ]; then
		VAR=`grep "^$1" /etc/ssh/sshd_config | awk '{print $2}' | head -2 | tail -1`
	fi
	if [ -z "$VAR" ]; then
		VAR=`grep "^$1" /usr/share/sushi/system/sshdconf/defaults | awk '{print $2}' | head -2 | tail -1`
	fi
fi
if [ "$2" = "3" ]; then
	if [ $NUM -gt 2 ]; then
		VAR=`grep "^$1" /etc/ssh/sshd_config | awk '{print $2}' | tail -1`
	fi
	if [ -z "$VAR" ]; then
		VAR=`grep "^$1" /usr/share/sushi/system/sshdconf/defaults | awk '{print $2}' | tail -1`
	fi
fi

if [ -z "$VAR" ]; then
	echo ""
else
	echo "$VAR"
fi
