#!/bin/sh
if [ "$1" = "" ]; then exit 1 ; fi
if [ "$2" = "" ]; then exit 1 ; fi
c1=`expr index $1 "@"`
if [ $c1 = 0 ]; then exit 1 ; fi
c2=`expr index $2 "@"`
if [ $c2 = 0 ]; then exit 1 ; fi
n1=$1
n2=`echo ${n1##*@}`
if [ "$n2" = "***.cn" ]
then
n3=`echo ${n1%%@*}`
else
n3=`echo ${n1/@/.}`
fi
n4=$2
n5=`echo ${n4/@/.}`
n6=`echo ${n4##*@}`
if [ "$n6" = "***.cn" ]
then
exit 1
fi
SAVEIFS=$IFS
IFS="
"
cou1=`find /cvsroot/ -name passwd -follow -exec grep -q ^$n3: {} ; -print`
if [ -n "$cou1" ]
then
for f in $cou1
do
echo "cvs: copy $n3 -> $n5"
echo $f
g=`grep ^$n3: $f`
i=`echo ${g/$n3:/$n5:}`
grep -q ^$i$ $f
if [ $? -ne 0 ]
then
sed -i.bak "/^$n5:/d" $f
sed -i.bak "/^$n3:/ a $i" $f
fi
f2=`echo ${f%/*}`/group
echo $f2
cou2=`grep -E "(:|,)$n3(,|$)|(:|,)$n5(,|$)" $f2`
if [ $? = 0 ]
then
perl -i.bak -lape '{s/(:|,)'"$n5"'(,|$)/$1/;s/,$//;if(m/(:|,)'"$n3"'(,|$)/){$_.=",'"$n5"'"}}' "$f2"
fi
done
fi
IFS=$SAVEIFS
转载于:https://my.oschina.net/tadcat/blog/149850