#menu# Set up your machine to behave more like System V Release 4.0
#help#     This script sets up several optional features which make
#help#     the behavior more like a System V Release 4.0 system.  
#help#     The following will change:
#help#      *login will issue an initgroups() call which puts the user in
#help#           all of the groups to which he/she belongs and it 
#help#		 it will ignore signals not found in SVR4
#help#      *su will issue an initgroups() call which puts the user in 
#help#           all of the groups to which he/she belongs before executing; 
#help#		 all attempts to su will be logged in /var/adm/sulog 
#help#      *cron will issue an initgroups() call to enable access to files 
#help#           belonging to all groups of which the user is a member;
#help#           all cron activity will be logged 
#help#     See the manual pages for su(1), cron(1M), login(4) and kopt(8) 
#help#     for more information.
#help#     You will be asked about using sendmail for mail transmission.
#help#     See System Administrator's Guide for more information on sendmail.
flags="-qq -k$$"	# flags for checkyn to implement [q] (quit)

trap 'rm -f /tmp/login$$ /tmp/cron$$; exit 0' 1 2 15

echo "In addition to the things set up by this script, you may want to"
echo "set other things up to be more System V Release 4.0 like.  These include:"
echo "	*setting up the System V Release 4.0 line printer system"
echo "	*changing /etc/profile and /etc/cshrc to include /svr4/bin in the path"
echo "	 used for searching for executables"
echo "	*using the System V Release 4.0 accounting system"

checkyn ${flags} -f  -H "This will change the behavior of the system to be more like System V Release 4.0" \
  -f "Change to System V Release 4.0 behavior?" ||  exit 0

# OK, go for it
touch /etc/default/login
echo ""
echo "Modifying /etc/default/login to enable SVR4SIGNALS and INITGROUPS."
sed -e '/^.*SVR4SIGNALS=.*/d' \
    -e '/^.*INITGROUPS=.*/d' /etc/default/login > /tmp/login$$
echo 'SVR4SIGNALS=YES
INITGROUPS=YES' >> /tmp/login$$
mv /tmp/login$$ /etc/default/login

touch /etc/default/cron
echo ""
echo "Modifying /etc/default/cron to enable CRONLOG and INITGROUPS."
sed -e '/^.*INITGROUPS=.*/d' \
    -e '/^.*CRONLOG=.*/d' /etc/default/cron > /tmp/cron$$
echo 'INITGROUPS=YES
CRONLOG=YES' >> /tmp/cron$$
mv /tmp/cron$$ /etc/default/cron

touch /etc/default/su
echo ""
echo "Modifying /etc/default/su to enable INITGROUPS and set SULOG=/var/adm/sulog."
sed -e '/^.*INITGROUPS=.*/d' \
    -e '/^.*SULOG=.*/d'  /etc/default/su > /tmp/su$$
echo 'INITGROUPS=YES
SULOG=/var/adm/sulog' >> /tmp/su$$
mv /tmp/su$$ /etc/default/su

echo ""
# turn on the kopts in /etc/init.d/set_kopts
if ( grep -s "^#SVR4" /etc/init.d/set_kopts > /dev/null )
then
	cp /etc/init.d/set_kopts /etc/init.d/set_kopts.save$$
	echo Updating /etc/init.d/set_kopts 
	echo If anything goes wrong, a saved copy is in /etc/init.d/set_kopts.save$$
ed /etc/init.d/set_kopts << ENDSCRIPT
H
1,\$s/^#SVR4//
w
q
ENDSCRIPT
else
	echo The file /etc/init.d/set_kopts is not in the expected form
	echo for automatic updating.  It may have been updated already.
	echo Please check that it includes the following statements:
	echo	/etc/kopt set _posix_chown_restricted -1
	echo	/etc/kopt set _riscos_group_parent -1
	echo	/etc/kopt set _riscos_kill_stopped_orphans -1
	echo	/etc/kopt set _riscos_utime_owner -1
fi
echo ""

if checkyn ${flags} -f  -H "This will cause the mail system to use the sendmail program." \
  -f "Use sendmail for mail transmission?" 
then
	echo ""
	echo "Creating /usr/lib/sendmail.ok"
	touch /usr/lib/sendmail.ok
fi

chmod 444 /etc/default/login /etc/default/cron /etc/default/su
chown root /etc/default/login /etc/default/cron /etc/default/su
chgrp mips /etc/default/login /etc/default/cron /etc/default/su
