[Bio] / SoftRelTools / addacl Repository:
ViewVC logotype

View of /SoftRelTools/addacl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (download) (annotate) (vendor branch)
Fri Dec 20 20:20:56 2002 UTC (15 years, 11 months ago) by efrank
Branch: BobJacobsen, MAIN
CVS Tags: Head-20-Dec-2002, HEAD
Changes since 1.1: +0 -0 lines

Import from SLAC.  Not sure this is going to serve us, but there is a ton
of experience in this package.

#!/bin/sh
#   add acl to $BFROOT/ACL

    pid=`getpid`	
    tmp="/tmp/addacl.$pid"
    editor=$EDITOR
    if [ "$editor" = "" ]; then
       editor="emacs"
    fi   
 
#-> parse argument
    set -- `getopt e:nt $*`
    if [ $? = 0 ]
    then
	while [ $1 != -- ]
	do
	    case $1 in
	    -e) editor=$2; shift;;
	    -t) trace=1; set -x;;
	    -n) noexec=1;;
	    esac
	    shift
	done
	shift
    fi

#-> usage
    if [ "$#" -gt 1 ]; then
	echo "addacl [-t] newdir"
	echo "-t: trace"
	exit 1
    fi	

    if [ "$#" -eq 0 ]; then
	echo "package name: (q=quit)"
	read ans
	if [ "$ans" = "q" ]; then
	    exit 1
	fi
	if [ "$ans" = "" ]; then
            echo "must provide name of package"
            exit 1
        fi
	newdir=$ans
    else
	newdir=$1
    fi	

#-> create a temporary directory
    if [ ! -d $tmp ]; then
	mkdir $tmp
	if [ $? != 0 ]; then 
	   echo "cannot mkdir $tmp, error"
	fi
    else
	echo $tmp already exist, error	
    fi


#-> check out template
    cd $tmp
    if [ "$trace" = 1 ]; then
	echo "-> $cvs co CVSROOT/ACL/template/acl"
    fi
    cvs co CVSROOT/ACL/template/acl
    if [ $? != 0 ]; then
	echo cannot check out CVSROOT/ACL/template/acl, error
	cd /tmp; rm -r -f $tmp
	exit 1
    fi	

#-> add new directory 
    cd CVSROOT/ACL
    if [ $? != 0 ]; then
	echo "error in 'cd CVSROOT/ACL'"
	cd /tmp; rm -r -f $tmp
	exit 1
    fi
 
    if [ -d $newdir ]; then
	echo $tmp/$newdir exist
	cd /tmp; rm -r -f $tmp
	exit 1
    fi	

    mkdir $newdir
    if [ "$trace" = 1 ]; then
	echo "-> cvs add $newdir"
    fi
    cvs add $newdir
    cd $newdir

#-> copy acl template over
    if [ "$trace" = 1 ]; then
	echo "-> cp ../template/acl acl"
    fi
    cp ../template/acl acl

#-> let user edit acl file
    $editor acl

#-> add acl
    if [ "$trace" = 1 ]; then
	echo "-> cvs add acl"
    fi
    cvs add acl
    if [ $? != 0 ]; then
	echo "error in 'cvs add acl'"
	echo "maybe CVSROOT/ACL/$newdir already exist?"
	cd /tmp; rm -r -f $tmp
	exit 1
    fi	

#-> commit acl 
    if [ "$trace" = 1 ]; then
	echo "-> cvs ci -m 'add acl for $newdir'"
    fi
    cvs ci -m "add acl for $newdir"
    if [ $? != 0 ]; then
	echo error in 'cvs ci'
	cd /tmp; rm -r -f $tmp
	exit 1
    fi	

#-> remove template and newdir from /tmp
    cd /tmp; rm -r -f $tmp


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3