歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux資訊 >> 更多Linux

CVS 管理腳本

  、用法    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:$cvspasschpasswd    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/shadowgawk -F: '{print $1":"$2":'$SYSUSER'"}'>>$CVSROOT/passwd    userdel $CVSUSER    }    if [ -z $1 ]; then    echo "Usage: $0 [cvsuser] [system user] [password]"    echo " $0 chen cvs 123456"    exit 0    else    # echo $CVSUSER , $SYSUSER , $CVSPASS    isExists=`grep -c "$CVSUSER\>" $CVSROOT/passwd`    # echo $isExists    if [ "$isExists" = "0" ]; then    cvsadduser    else    echo "$0 : user $1 exists"    exit 0    fi    fi    [root@linux cvs]#    3. 刪除用戶程序源碼    [root@linux cvs]# cat cvsuserdel    #!/bin/sh    ##############################################################    # Script to cvs passwd    # File:/root/admintool    ##############################################################    # Setup environment for script execution    ENVS="`pwd`"/envs    if [ -f $ENVS ]; then    . $ENVS    else    CVSROOT=/cvsroot/CVSROOT    CVSUSER=$1    # echo "The file exist."    # exit 0    fi    cvsuserdel() {    isExists=`gawk -F: '$1=="'$CVSUSER'"{print $1}' $CVSROOT/passwd`    if [ "$CVSUSER" = "$isExists" ]; then    DLINE=`grep -n "$CVSUSER\>" $CVSROOT/passwdgawk -F: '{print $1}'`    mv -f $CVSROOT/passwd $CVSROOT/passwd.old    sed $DLINE'd' $CVSROOT/passwd.old>>$CVSROOT/passwd    else    echo "$0 : user $CVSUSER does not exist"    fi    }    if [ -z $1 ]; then    echo "Usage: $0 [cvsuser] [newpassword] "    echo " $0 chen 123456"    exit 0    else    cvsuserdel    exit 1    fi    [root@linux cvs]#    4. 修改密碼程序源碼    [root@linux cvs]# cat cvspasswd    #!/bin/sh    ##############################################################    # Script to cvs passwd    # File:/root/admintool    ##############################################################    # Setup environment for script execution    ENVS="`pwd`"/envs    if [ -f $ENVS ]; then    . $ENVS    else    CVSROOT=/cvsroot/CVSROOT    CVSUSER=$1    CVSPASS=$2    # echo "The file exist."    # exit 0    fi    cvspasswd() {    isExists=`gawk -F: '$1=="'$CVSUSER'"{print $1}' $CVSROOT/passwd`    # echo $isExists    if [ "$CVSUSER" = "$isExists" ]; then    # echo "true"    adduser $CVSUSER -g nobody -s /dev/null -d /tmp    echo "$CVSUSER:$CVSPASS"chpasswd    SDPASS=`gawk -F: '$1=="'$CVSUSER'"{print $2}' /etc/shadow`    DLINE=`grep -n "$CVSUSER\>" $CVSROOT/passwdgawk -F: '{print $1}'`    SYSUSER=`grep "$CVSUSER\>" $CVSROOT/passwdgawk -F: '{print $3}'`    mv -f $CVSROOT/passwd $CVSROOT/passwd.old    sed $DLINE'd' $CVSROOT/passwd.old>>$CVSROOT/passwd    echo $CVSUSER:$SDPASS:$SYSUSER>>$CVSROOT/passwd    userdel $CVSUSER    # echo $SDPASS,$DLINE,$SYSUSER    else    echo "$0 : user $1 does not exist"    fi    }    if [ -z $1 ]; then    echo "Usage: $0 [cvsuser] [newpassword] "    echo " $0 chen 123456"    exit 0    else    cvspasswd    exit 1    fi    exit 1    [root@linux cvs]#    三、xinetd.d啟動文件  [root@linux cvs]# cat cvspserver    service cvspserver    {    socket_type = stream    protocol = tcp    wait = no    user = root    server = /usr/bin/cvs    server_args = -f --allow-root=/cvsroot pserver    log_on_suceess +=USERID    log_on_failure +=USERID    }    [root@linux cvs]#    作者:Netkiller(陳景峰)    2002年1月30日星期三 第一版《Linux CVS Server與jCVS Client進行分布式開發》  2002年7月22日星期一 第二版 《Linux CVS Server + jCVS-5.3.2 Client進行分布式開發》    2002年9月8日星期日 《CVS管理腳本》    如有問題:    OICQ:13721218    ICQ:101888222    E-Mail: [email protected]




Copyright © Linux教程網 All Rights Reserved