zoukankan      html  css  js  c++  java
  • CentOS6.9快速安装配置svn

    CentOS6.9快速安装配置svn

    环境介绍:

    操作系统:CentOS release 6.9 (Final)
    192.168.65.130 (svn服务器)
    192.168.65.129 (svn客户端)

    一、svn安装检查(在两台上都执行)

    if [ ! -f /usr/bin/svn ]; then
        yum -y install subversion >/dev/null
        echo "svn has been installed." >/dev/null
        /usr/bin/svn --version|head -1|awk -F" " '{print $3}'
    fi
    View Code

    二、创建版本库文件夹(仅在130上操作)

    mkdir -p /data/svn/sinsvn
    #创建版本库
    svnadmin create /data/svn/sinsvn
    mkdir -p /data/www/sinsvn
    View Code

    三、主要操作

    #导入所需管理的项目到版本库repository中
    svn import /data/www/sinsvn/ file:///data/svn/sinsvn -m "svn first test"
    #检查是否导入成功
    svn list --verbose file:///data/svn/sinsvn
    #修改版本库的配置文件
    # vim /data/svn/sinsvn/conf/svnserve.conf
    cat >/data/svn/sinsvn/conf/svnserve.conf <<"EOF"
    [general]
    anon-access = none
    auth-access = write
    password-db = /data/svn/passwd
    authz-db = /data/svn/authz
    realm =sinsvn
    EOF
    
    cp /data/svn/sinsvn/conf/passwd /data/svn
    cp /data/svn/sinsvn/conf/authz /data/svn
    
    #修改允许访问版本库的用户文件
    # vim /data/svn/passwd
    cat >/data/svn/passwd <<"EOF"
    [users]
    harry = harry
    sin = sin
    EOF
    
    
    # vim /data/svn/authz
    cat >/data/svn/authz <<"EOF"
    [groups]
    myteam = harry,sin
    
    [/]
    harry = rw
    
    [sinsvn:/]
    @myteam = rw
    
    [secsvn:/www]
    @myteam =r
    sin= rw
    
    [sincms:/]
    sin= rw
    harry=
    EOF
    
    
    # 启动 svn 服务
    svnserve -d -r /data/svn/
    
    # 查看
    ps -ef|grep svnserve|grep -v 'grep'
    netstat -anltp|grep 3690
    View Code

    四、测试

    # 测试,在另外一台机器上操作(129),目的是效果更为明显些
    # 1mkdir -p /data/www
    mkdir -p /data/www
    cd /data/www/
    # 2、svn co 代码
    svn co svn://192.168.65.130/sinsvn --username=harry --password=harry
    
    # 3、添加branches,tags,trunk目录
    cd sinsvn/
    mkdir branches
    mkdir tags
    mkdir trunk
    
    svn add branches trunk tags
    svn ci -m 'create branches trunk tags dir'
    
    # 4、在trunk中添加测试文件,并提交到版本库
    cd trunk
    touch index.php
    mkdir class
    touch class/conn.php
    
    svn add index.php 
    svn add class/
    
    ......
    
    svn ci -m 'test file'
    
    
    svn delete index.php class class/ index.php
    svn ci -m 'delete files'
    
    mkdir webgame
    svn add webgame/
    svn ci -m 'add webgame dir'
    
    # 追加操作
    cd webgame
    cp /tmp/VMwareTools-10.2.0-7259539.tar.gz .
    cp /tmp/yum.log .
    svn add *
    svn ci -m 'add VMwareTools yum.log for test'
    
    
    ############### 这里假设130的机器上有个web项目
    mkdir -p /data/webdir
    cd /data/webdir
    svn co svn://192.168.65.130/sinsvn/trunk/webgame --username=harry --password=harry
    
    # 追加操作
    cd /data/webdir/webgame/
    svn update 
    ll # 可以查看到更新后的结果
    View Code

    五、脚本定制更新

    # 定时更新脚本(针对整个目录自动更新的脚本,被动模式)
    cat >/root/svnauto_update.sh<<"EOF"
    cd /data/webdir/webgame/
    svn update &>>/tmp/svnauto_update.log
    EOF
    
    chmod +x /root/svnauto_update.sh
    chmod +x /etc/crontab
    /etc/init.d/crond restart
    # 添加至crontab计划任务中
    
    
    cat >>/var/spool/cron/root<<"EOF"
    
    # svnauto_update.sh 
    * 09-23 * * *  /bin/sh /root/svnauto_update.sh
    EOF
    
    # 自动更新脚本(针对版本号触发式更新)
    #svn 目录:/data/svn/sinsvn
    #站点目录:/data/webdir/webgame
    
    #实现:
    #1.找到svn项目的hooks目录,这里是/data/svn/sinsvn/hooks。目录中默认会几个对应操作的钩子模板,我们需要创建一个post-commit的文件。
    find /data/svn/sinsvn/ -name hooks
    
    #2.新建post-commit,内容如下
    cat >/data/svn/sinsvn/hooks/post-commit<<"EOF"
    #!/bin/bash
    REPOS="$1"
    REV="$2"
    export LANG=zh_CN.UTF-8
    echo "Code Deployed at "$1" Committed revision "$2" ; `date "+%Y-%m-%d %H:%M:%S"`" >> /tmp/post-commit.log
    /usr/bin/svn update --username harry --password harry /data/webdir/webgame >> /tmp/post-commit.log
    EOF
    
    chmod +x /data/svn/sinsvn/hooks/post-commit
    View Code
  • 相关阅读:
    如何找按钮数组在布局中的横竖坐标位置?
    java中使用rmi进行远程方法调用
    测试视频集,各种测试用的视频文件
    如何彻底禁用VS 2008的智能感知功能
    JavaScript秘密花园 Type Casting,undefined,eval,setTimeout,Auto Semicolon Insertion
    JavaScript秘密花园 scope, namespace, constructor, equality and comparisons
    造成内存位置访问无效的一个原因
    depends在VS2008消失了
    12月10日晚的月全食照片
    JavaScript秘密花园 Array, Array Constructor, for in loop, typeof, instanceOf
  • 原文地址:https://www.cnblogs.com/bjx2020/p/8727641.html
Copyright © 2011-2022 走看看