#!/usr/bin/ksh

if [[ "`whoami`" != "root" ]] ; then
	echo "Must be root to run this patch script."
	exit 1
fi
if [[ ! -f osis50-groups-patch-files.tar.gz ]] ; then
   echo "Can't find osis50-groups-patch-files.tar.gz"
   exit 1
fi
if [[ ! -f /usr/.smdb./IAEBASE500.lk ]] ; then
   echo "This patch can only be applied to Open Source Internet Solutions V5.0
   which does not appear to be installed." 
   exit 1
fi
echo "Applying Open Source Internet Solutions V5.0 Administration Utility patch"

CurrentDir=`pwd`
cd /usr/internet/admin

for File in ./cgi-bin-users/adduser ./cgi-bin-users/general_users_proc.tcl ./cgi-bin-users/quo_tags_form_proc.tcl ./cgi-bin-system/ldam/group_attr.tcl ./cgi-bin-system/ldam/config_tables.tcl
do
	mv $File ${File}.OSIS50-orig
done

gunzip -c ${CurrentDir}/osis50-groups-patch-files.tar.gz | tar xf -
if [[ $? -eq 0 ]] ; then
	echo "Open Source Internet Solutions V5.0 Administration Utility patch applied successfully"
else
	echo "Failed to extract patch files."
fi
