:
# rvi_install: installation script for 'rvi' (must be run as 'root').
# Author: Fred Buck
#
# 	-- modified for Magpie installation --
#
# READ THE FOLLOWING CAREFULLY:
# Position yourself in the desired parent directory for the
# rvi-directory before running this script.  If you want the
# rvi-directory to reside under "/", do a "cd /" before running
# the script.  If you want it to reside under "/bbs", then first
# do a "cd /bbs", and so on.  If you want it to be called something
# other than "bozo", change the definition of "RVIDIR".
# 
# If you have more than one device on which you want an rvi-directory,
# run this script separately for each device you want to install an
# rvi-directory on.  Make sure that the users relegated to 'rvi' on
# each device have their $RVIDIR set appropriately for the local
# rvi-directory.
#
# This script doesn't compile nor relocate 'rvi'.  To compile 'rvi',
# enter "cc -o rvi rvi.c" in whatever directory you happen to have
# 'rvi.c'.  The resulting program, 'rvi', must be owned by 'root' and
# setuid'd to 'root'; so after compiling it, consider some sequence like
# "chown root rvi; chmod u+s rvi; chmod a+x rvi" (executed as 'root').
# Finally, make sure that 'rvi' is accessible to whatever restricted
# users you want to make it accessible to.

RVIDIR="./vitmp"

mkdir $RVIDIR; chown bin $RVIDIR; chmod 0755 $RVIDIR
mkdir $RVIDIR/tmp; chown bin $RVIDIR/tmp; chmod 0777 $RVIDIR/tmp
mkdir $RVIDIR/etc; chown bin $RVIDIR/etc; chmod 0755 $RVIDIR/etc
mkdir $RVIDIR/bin; chown bin $RVIDIR/bin; chgrp root $RVIDIR/bin;
   chmod 755 $RVIDIR/bin
ln /etc/termcap $RVIDIR/etc/termcap; if [ $? -ne 0 ]
	then
		cp /etc/termcap $RVIDIR/etc/termcap;
	fi
mkdir $RVIDIR/usr; chown bin $RVIDIR/usr; chmod 0755 $RVIDIR/usr
mkdir $RVIDIR/usr/lib; chown bin $RVIDIR/usr/lib; chmod 0755 $RVIDIR/usr/lib
ln /usr/lib/ex3.7strings $RVIDIR/usr/lib/ex3.7strings; if [ $? -ne 0 ]
	then
		cp /usr/lib/ex3.7strings $RVIDIR/usr/lib/ex3.7strings
	fi
ln /bin/vi $RVIDIR/vi; if [ $? -ne 0 ]
	then
		cp /bin/vi $RVIDIR/vi
	fi
ln /bin/rsh $RVIDIR/rsh; if [ $? -ne 0 ]
	then
		cp /bin/rsh $RVIDIR/rsh
	fi
ln /bin/cat $RVIDIR/bin/cat; if [ $? -ne 0 ]
	then
		cp /bin/cat $RVIDIR/bin/cat
	fi
ln /bin/echo $RVIDIR/bin/echo; if [ $? -ne 0 ]
	then
		cp /bin/echo $RVIDIR/bin/echo
	fi

# 'view' parent script
echo ":\necho \"Parent Message\"\ncat tmp/\$MAGPAR\n" > $RVIDIR/view
chmod 755 $RVIDIR/view
mkdir tmp
chmod 777 tmp
chmod 4755 rvi; chown root rvi; chgrp root rvi
chmod 775 VIsh; chown root VIsh; chgrp root VIsh
mv VIsh $RVIDIR

# format utilities (requires C compiler)
# compile with 'sh fmt.sh'
mv fmt.sh $RVIDIR

cd $RVIDIR; echo `pwd` >/etc/default/rvi; chmod 0644 /etc/default/rvi
