#!/bin/csh -f
#
# Network Installation Kit
#
# install.kerberos: install kerberos clients and remote services
#
# Tom Coppeto
# MIT Network Group
# 17 September 1994
#
# Last Modified 2 January 1996 by jyp
#

set pltfrm = `/usr/bin/uname`

source $util/aliases

top:

vclear

vecho "INSTALL"
vecho ""
vecho "                                Kerberos"
vecho $bar
vecho ""
vecho ""
vecho "New files: "
vecho "               /bin/athena/kinit       /bin/athena/klist"
vecho "               /bin/athena/kdestroy    /bin/athena/kpasswd"
vecho "               /bin/athena/ksrvutil    /bin/athena/ksrvtgt"
vecho "               /bin/athena/rcp         /bin/athena/rsh"
vecho "               /bin/athena/rlogin      /bin/athena/rkinit"
vecho "               /etc/athena/kshd        /etc/athena/klogind"
vecho "               /etc/athena/krb.realms  /etc/athena/krb.conf"

if ($pltfrm == "SunOS") then
	vecho "	              /etc/athena/login.krb"
else
	vecho "               /etc/athena/rkinitd     /etc/athena/login.krb"
endif

vecho "Modified files: "
if ($pltfrm == "IRIX") then
	vecho "               /etc/inetd.conf"
else
	vecho "               /etc/athena/rc.conf"
endif

vecho "Disk consumed:"
if ($pltfrm == "IRIX") then
	vecho "               /          1213K"
else
	vecho "               /          789K"
endif

vecho ""
df / | vcat
vecho ""

if($interactive == true) then
	get_response "continue? (yes/no) " "yes" "no"
	if ($status == 2) then
		exit -1
	endif
endif

vlog "**   running install.kerberos:"

#
# create directories
#

vecho "     creating directories..."
if(! -d /bin/athena) mkdir /bin/athena
if(! -d /etc/athena) mkdir /etc/athena

if ($preset_kinstall != "") then
        set kinstall = $preset_kinstall
else
        echo "You have the option of installing the kerberos clients"
        echo "on your local disk. Normally, these would be accessed"
        echo "through the afs file system."
        echo ""
        get_response "would you like these installed locally? (yes/no) " "yes" "no"
        if ($status == 2) then
                set kinstall = no
        else
                set kinstall = yes
        endif
endif

vecho ""
vecho "     installing binaries..."

if($kinstall == yes) then
	install -c -m 755 $krb/kpasswd /bin/athena
	install -c -m 755 $krb/ksrvutil /bin/athena
	install -c -m 755 $krb/ksrvtgt /bin/athena
	install -c -m 755 $krb/rcp /bin/athena
	install -c -m 755 $krb/rsh /bin/athena
	install -c -m 755 $krb/rlogin /bin/athena
	install -c -m 755 $krb/rkinit /bin/athena
endif

vlog "     kerberos: installed binaries local"

install -c -m 755 $krb/kinit /bin/athena
install -c -m 755 $krb/klist /bin/athena
install -c -m 755 $krb/kdestroy /bin/athena
install -c -m 755 $krb/login.krb /etc/athena
install -c -m 755 $krb/klogind /etc/athena
install -c -m 755 $krb/kshd /etc/athena
if ($pltfrm == "IRIX") then 
	install -c -m 755 $krb/rkinitd /etc/athena
endif

vecho "     installing configs..."
install -c -m 644 $krb/krb.conf /etc/athena
install -c -m 644 $krb/krb.realms /etc/athena

vlog "     kerberos: installed binaries and configs"

#
# inetd.conf
#
set col = `fgrep telnet /etc/inetd.conf | awk '{print $5}'`
# want to check for inet version here
fgrep "MIT additions" /etc/inetd.conf > /dev/null
if($status) then
	vecho "     adding kerberos services to inetd..."
        cat $krb/inetd.add >> /etc/inetd.conf
	if ($pltfrm == "IRIX") then
		echo "rkinit  stream  tcp     nowait  root     /etc/athena/rkinitd     rkinitd" >> /etc/inetd.conf 
	endif
        vlog "     krb: added kerberos services to inetd.conf"
endif


#
# configure rc.conf
#

if ($pltfrm == "IRIX") then
	vecho "     updating version..."
	version add KerberosRemoteServices $krbremversion
else
	vecho "     updating rc and version..."
	install.rc
	config.rc KRBCLIENT true
endif

version add KerberosClient $krbversion
vlog "     kerberos: updated version"
vlog "     krb: done."

vecho "done."

if($interactive == true) then
	echo ""
	get_response "Press <return> to continue..." "<return>"
else
        sleep 5
endif

exit 0
