:
# vinegar - script to remove the symbolic links created by spray in 
#		/usr/lib/X11 and /usr/skunk in order to be able to run the software 
#		provided on the SCO Skunkware CD-ROM
#
# Written 05-Aug-94 by rr@sco.com
#
# Usage : vinegar <mount-point>
#         Where <mount-point> is the directory on which the CD-ROM is mounted
#         If mounted on /usr/skunk, no argument is necessary
#

usage() {
	echo "Usage: vinegar [mount-point]"
	echo "\tWhere mount-point refers to the directory on which"
	echo "\tthe CD-ROM is mounted. If no arguments are given, it"
	echo "\tis assumed the CD-ROM is mounted on /usr/skunk."
	exit 1
}

Remove_Symlink() {
	ls -l $1 | grep $MOUNT_PT > /dev/null && rm -f $1
}

[ $# = 0 ] && MOUNT_PT=/usr/skunk

[ $# = 1 ] && MOUNT_PT=$1

[ $# -gt 1 ] && usage

#
# check to see if the user has root privelege
#
fuid=`id`
uid=`echo $fuid | awk ' { print $1 } '`
[ "$uid" = "uid=0(root)" ] || {
	echo "You must have root priveleges to run vinegar."
	usage
	exit 1
}

#
# check to make sure the cd is mounted and what we expect is there
#
[ -f $MOUNT_PT/pics/README ] || usage
[ -d $MOUNT_PT/lib/X11/app-defaults ] || usage

APPDEFDIR=/usr/lib/X11/app-defaults
SKUNKLIST="README RELEASE.NOTES \
	audio bin cdmt etc games include info interviews lib man pics \
		src tls usr xc"

#
# clean up the X11 app-defaults directory
#
[ -d $APPDEFDIR ] && {
	cd $APPDEFDIR
	for i in $MOUNT_PT/lib/X11/app-defaults/*
	do
		[ "$i" = "$MOUNT_PT/lib/X11/app-defaults/XMcd" ] && continue
		Remove_Symlink `basename $i`
	done
}

#
# clean up the Fresco DLL's
#
cd $MOUNT_PT/lib
for i in *.so *.so.1.0
do
	Remove_Symlink /usr/lib/$i
done

#
# clean up the Willow symlink
#
Remove_Symlink /usr/lib/X11/willow

#
# clean up the Periodic uid file
#
Remove_Symlink /usr/lib/X11/uid/periodic.uid


#
# set up directory links in /usr/local/lib (for now)
#
LOCALLIBDIRS="gcc-lib povray sc-6.21 xboing/levels xc xconq mosaic lynx \
	X11"
LOCALLIBFILS="libg++.a"
for i in $LOCALLIBDIRS
do
	Remove_Symlink /usr/local/lib/$i
done
for i in $LOCALLIBFILS
do
	Remove_Symlink /usr/local/lib/$i
done
