campo-sirio/CVSROOT/cvspermuserdir.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

110 lines
2.2 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 adds/deletes a directory path to the CVSPermissions database for
# a particular user.
cleanup ()
{
if [ -d CVSROOT ];then
rm -rf CVSROOT
fi
}
checkoutCVSROOT ()
{
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
}
printusage ()
{
echo "Usage : $0 <`uname -s` user name> <--add[-a] | --del[-d] > <path to add>"
exit 1
}
if [ $# -lt 3 ];then
printusage;
fi
checkoutCVSROOT
grep "^$1\$" CVSROOT/users.restricted >/dev/null
if [ $? -eq 1 ];then
echo User is not a restricted user. Exiting
cleanup
exit 1;
fi
cd CVSROOT
#Add a permission file if required
if [ ! -f $1.permission ];then
touch $1.permission
cvs add $1.permission >/dev/null
fi
COMMITMSG=""
case "$2" in
--add | -a)
grep "^$3\$" $1.permission >/dev/null
if [ $? -ne 0 ];then
echo $3 >> $1.permission
COMMITMSG=`echo "Added directory " $3`
fi;;
--del | -d)
grep "^$3\$" $1.permission >/dev/null
if [ $? -eq 0 ];then
grep -v "^$3\$" $1.permission >> $1.permission.new
mv $1.permission.new $1.permission
COMMITMSG=`echo "Removed directory " $3`
fi;;
-? | -h | --help | -h*)
printusage;;
esac
cd ..
cvs commit -m "$COMMITMSG" CVSROOT
echo commiting changes to the CVS repository...
if [ $? -ne 0 ];then
echo Repository commit failed. Please try later.
else
echo $COMMITMSG
fi
cleanup
exit 0