用法
1. 準備工作
下載腳本地址
http://www.kdeopen.com
解開cvs.tar.gz
tar zxvf cvs.tar.gz
2. 安裝CVS服務(wù)器
#cd cvs
#./install
3. 添加用戶
#./cvsadduser [cvs用戶] [系統(tǒng)用戶] [密碼]
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
}