campo-sirio/CVSROOT/cvspermsetup.sh
alex 3eea33047c users
git-svn-id: svn://10.65.10.50/trunk@16884 c028cbd2-c16b-5b4b-a496-9718f37d4682
2008-07-17 14:54:49 +00:00

128 lines
3.5 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (C) 2002 Vivek Venugopalan. All Rights Reserved.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
# This script set up a repository for restricted access ie enables it for
# CVSPermissions
cleanup ()
{
if [ -d CVSROOT ];then
rm -rf CVSROOT
fi
}
chkreturnandexit ()
{
if [ $1 -ne 0 ];then
echo $2
cleanup
exit 1;
fi
}
echo checking out CVSROOT module for the repository.
cvs co CVSROOT >/dev/null 2>/dev/null
if [ $? -eq 1 ];then
echo Could not access the CVSROOT module. Exiting!
exit 1;
fi
cd CVSROOT
#Check to see if SystemAuth is enabled. We cannot work without system auth being enabled.
grep '^ *SystemAuth *= *yes' config >/dev/null 2>&1
if [ $? -eq 1 ];then
echo "This installation does not use System Authentication (probably uses CVSROOT/password). CVSPermissions cannot be used with this intallation"
exit 1;
fi
#If there is a path specified on the command line assume that CVSPermissions
#has been installed in that path. Else assume that the directory in which
#this program started has the file path
if [ -z $1 ];then
FILEPATH=`dirname $0`
else
FILEPATH=$1
fi
grep "cvspermissions.sh\$" commitinfo >/dev/null 2>&1
if [ $? -eq 1 ];then
echo Modifying CVSROOT/commitinfo file to enable CVSPermissions
echo "DEFAULT $FILEPATH/cvspermissions.sh" >> commitinfo
fi
grep "cvspermtagcheck.sh\$" taginfo >/dev/null 2>&1
if [ $? -eq 1 ];then
echo Modifying CVSROOT/taginfo file to enable CVSPermissions
echo "DEFAULT $FILEPATH/cvspermtagcheck.sh" >> taginfo
fi
#Add users.restricted if required.
if [ ! -f users.restricted ];then
echo "Adding users.restricted"
#Add the users.restricted file
touch users.restricted
cvs add users.restricted >/dev/null 2>/dev/null
chkreturnandexit $? "Could not create CVSPermission file. Exiting"
#add our file to the checkout list
grep -v "^users\.restricted\$" checkoutlist > checkoutlist.new
echo users.restricted >> checkoutlist.new
mv checkoutlist.new checkoutlist
fi
#Add a CVS writers file if not present
if [ ! -f writers ];then
echo "Creating repository writers"
#Add self to writers - otherwise the next CVS command will fail since we
#wont have write permission to the repository (CVSROOT)
echo $USER > writers
cvs add writers >/dev/null 2>/dev/null
chkreturnandexit $? "Could not create a writers file. Exiting"
fi
#Add a CVS readers file if not present
if [ ! -f readers ];then
echo "Creating repository readers"
touch readers
cvs add readers >/dev/null 2>/dev/null
chkreturnandexit $? "Could not create a readers file. Exiting"
fi
cd ..
echo "Committing CVSPermission configuration to the CVSROOT module"
cvs commit -m "Enabled CVSPermissions for the repository" CVSROOT >/dev/null 2>/dev/null
chkreturnandexit $? "Could not commit configuration files. Exiting"
cleanup
echo CVSPermissions setup successfully completed.
exit 0