#!/bin/sh

# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
#ident  "@(#)postpatch 1.1     03/09/16 SMI"

echo "-------postpatch started--------"
f=/etc/inittab
t=/tmp/e.tmp
bak=$f.ORIG.SSRR

l="ts:23:respawn:/etc/svr_tty -f -w -s >> /var/remote.support/logs/svr_tty.log 2>&1"

# make backup
cp $f $bak

# determine what's the current state
if grep "svr_tty -f -w -s" $f > /dev/null ; then
        echo " Already has correct inittab entry with -w"
elif grep "svr_tty" $f > /dev/null; then
        echo " Has older version of inittab line w/o -w"
        echo " Proceeding to modify"
        grep -v "svr_tty -f -s" $f > $t
        echo $l >> $t
        cat $t > $f
else
        echo " Does not have an svr_tty entry"
        echo " Adding new entry"
        echo "$l" >> $f
fi

# rerun telinit
/etc/telinit q

# restrat svr_tty
pkill svr_tty

# making sure that ssrr_trans/recv is restarted
pkill ssrr_trans
pkill ssrr_recv

echo " Reset init"

# making sure that the rss users's .login does not have and entry for rss_recv
f=/var/rss/.login
if [ -f $f ] ; then
	echo " Found $f"
	if grep "ssrr_recv" $f; then
		echo " Renaming to $f.SSRR"
		mv $f $f.SSRR
	fi
fi

echo "-------postpatch completed--------"
