用法
1. 准备工作
下载脚本地址
http://www.kdeopen.com
解开cvs.tar.gz
tar zxvf cvs.tar.gz
2. 安装CVS服务器
#cd cvs
#./install
3. 添加用户
#./cvsadduser [cvs用户] [系统用户] [密码]
4. 删除用户
#./cvsuserdel [cvs用户]
5. 修改密码
#./cvspasswd [cvs用户] [新密码]
二、脚本源码
1. 安装程序源码
[root@linux cvs]# cat install
#!/bin/sh
echo "adduser cvs"
adduser cvs
echo -n "Seting password for cvs :"
read cvspass
echo cvs:$cvspass|chpasswd
echo "adduser cvsroot"
adduser cvsroot -g cvs
echo -n "Seting password for cvsroot :"
read cvsrootpass
lpasswd cvsroot -P $cvsrootpass
if [ -f /etc/xinetd.d/cvspserver ]; then
echo "file cvspserver exists !"
exit 0
else
mkdir -m 755 /cvsroot
chown -R cvsroot /cvsroot
chgrp -R cvs /cvsroot
cp cvspserver /etc/xinetd.d
/etc/init.d/xinetd restart
echo "export CVSROOT=server:cvsroot@"`hostname`":/cvsroot">>/home/cvsroot/.bash_profile
su - cvsroot -c "cvs -d /cvsroot init"
fi
[root@linux cvs]#
2. 添加用户程序源码
[root@linux cvs]# cat cvsadduser
#!/bin/sh
##############################################################
# Script to cvs adduser
# File:/root/admintool
##############################################################
# Setup environment for script execution
ENVS="`pwd`"/envs
if [ -f $ENVS ]; then
. $ENVS
else
CVSROOT=/cvsroot/CVSROOT
CVSUSER=$1
SYSUSER=$2
CVSPASS=$3
# echo "The file exist."
# exit 0
fi
if ! [ -f $CVSROOT/passwd ]; then
touch $CVSROOT/passwd
fi
cvsadduser() {
adduser $CVSUSER -g cvs -s /dev/null -d /tmp
echo "$CVSUSER:$CVSPASS"|chpasswd
grep "$CVSUSER>" /etc/shadow|gawk -F: '{print $1":"$2":'$SYSUSER'"}'>>$CVSROOT/passwd
userdel $CVSUSER
}