• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            runsisi

              C++博客 :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              45 隨筆 :: 15 文章 :: 26 評論 :: 0 Trackbacks
            年前說給scienceluo寫一個(gè)這樣的腳本,很簡單的邏輯,實(shí)現(xiàn)的功能為在linux下建一個(gè)svn的版本庫,考慮的條件也很簡單,只能用在平時(shí)寫代碼的時(shí)候?yàn)榱朔奖闩R時(shí)建個(gè)svn的版本庫用用~~
            在openSUSE-12.2, CentOS-6.3, 以及RHEL6.0(均為64bit環(huán)境)下簡單測試通過:),ubuntu-12.10默認(rèn)的shell為dash(當(dāng)然可以指定使用bash),且對awk的gensub函數(shù)不支持,所以該腳本無法在ubuntu下使用(可以用sed實(shí)現(xiàn)同樣的功能,但懶得弄了,平時(shí)也用不到ubuntu的環(huán)境)~
            腳本支持建立多個(gè)版本庫,但如果想要同時(shí)訪問,則多個(gè)版本庫要在相同的父目錄下,否則的話就只能訪問最新建的那個(gè)版本庫了,因?yàn)閱?dòng)svnserve服務(wù)器時(shí)指定的服務(wù)器根目錄參數(shù)填的是用戶最新建的那個(gè)svn版本庫路徑的父目錄;
            還一個(gè)需要注意的地方,建立的版本庫必須用svn://127.0.0.1/test_repo類似這樣的路徑來訪問,注意紅色的svn://前綴,因?yàn)榉?wù)器用的是subversion自帶的獨(dú)立服務(wù)器~

            /Files/runsisi/mksvn.rar


            #! /bin/sh

            # author runsisi@hust.edu.cn
            #
             date 2013/02/05
            #
             modified 2013/02/12

            # variables forward declaration, it is not neccessary for shell script though
            svn_repo_root_dir=""

            function is_subversion_exist()
            {
                which svnadmin > /dev/null 2>&1
                [ $? -eq 0 ] && return 1
                return 0
            }

            function is_sys_root_dir()
            {
                echo $1 | awk '{if ($0 ~ /^\/$/) exit 1; else exit 0;}'
            }

            function is_relative_path()
            {
                echo $1 | awk '{if ($0 ~ /^\//) exit 0; else exit 1;}'
            }

            function get_svn_root_dir()
            {
                read -e -p "輸入要?jiǎng)?chuàng)建的svn根目錄:" svn_repo_root_dir
                [ -z "$svn_repo_root_dir" ] && echo "非法路徑,abort!" && return 1
                # whitespaces at each end of the path are trimed
                svn_repo_root_dir=$(echo "$svn_repo_root_dir" | sed 's/^[[:blank:]]*\(\)[[:blank:]]*$/\1/g')
                is_sys_root_dir "$svn_repo_root_dir"
                [ $? -eq 1 ] && echo "非法路徑,不能是根目錄,abort!" && return 1
                # get rid of last / character(s) in path
                svn_repo_root_dir=$(echo "$svn_repo_root_dir" | sed 's/\(\)\/*$/\1/g')
                # escape whitespaces inside path
                svn_repo_root_dir=$(echo "$svn_repo_root_dir" | sed 's/ /\\ /g')
                # expand ~ character in path
                eval svn_repo_root_dir="$svn_repo_root_dir"
                # test if this path already exist
                [ -e "$svn_repo_root_dir" ] && echo "該svn路徑已存在,請刪除后再創(chuàng)建,abort!" && return 1
                # test if this path is a relative path or not
                is_relative_path "$svn_repo_root_dir"
                # convert to absolute path
                [ $? -eq 1 ] && svn_repo_root_dir=$(pwd)/$svn_repo_root_dir
                return 0
            }

            function create_svn_repo()
            {
                mkdir -p $(dirname "$1")
                svnadmin create "$1"
                return 0
            }

            function edit_svn_conf_file()
            {
                svn_repo_conf_dir="$1/conf"
                awk '{
                    if ($0 ~ /^#[[:blank:]]*anon-access/)
                        print gensub(/^#[[:blank:]]*(anon-access)/, "\\1", "g");
                    else if ($0 ~ /^#[[:blank:]]*auth-access/)
                        print gensub(/^#[[:blank:]]*(auth-access)/, "\\1", "g");
                    else if ($0 ~ /^#[[:blank:]]*password-db/)
                        print gensub(/^#[[:blank:]]*(password-db)/, "\\1", "g");
                    else print;}' "$svn_repo_conf_dir/svnserve.conf" > "$svn_repo_conf_dir/tmp_svnserve.conf"
                rm -f "$svn_repo_conf_dir/svnserve.conf"
                mv "$svn_repo_conf_dir/tmp_svnserve.conf" "$svn_repo_conf_dir/svnserve.conf"
                vi "$svn_repo_conf_dir/passwd"
                return 0
            }

            function start_svn_server()
            {
                killall -9 svnserve 2&> /dev/null
                svnserve -d -r $(dirname "$1")
                return 0
            }

            function main()
            {
                is_subversion_exist
                [ $? -eq 0 ] && echo "subversion不存在,需要先安裝subversion" && return 1
                get_svn_root_dir
                [ ! $? -eq 0 ] && return 1
                create_svn_repo "$svn_repo_root_dir"
                [ ! $? -eq 0 ] && return 1
                edit_svn_conf_file "$svn_repo_root_dir"
                [ ! $? -eq 0 ] && return 1
                start_svn_server "$svn_repo_root_dir"
                [ ! $? -eq 0 ] && return 1
                return 0
            }

            main
            posted on 2013-02-16 21:44 runsisi 閱讀(1001) 評論(0)  編輯 收藏 引用

            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久无码AV中文出轨人妻| 日韩av无码久久精品免费| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久久一本精品99久久精品88| 久久精品国产91久久综合麻豆自制| 久久精品中文字幕有码| 狠狠综合久久AV一区二区三区| 国产精品免费福利久久| 久久亚洲精品无码观看不卡| 久久发布国产伦子伦精品| 日韩精品无码久久一区二区三| 久久亚洲精品成人AV| 三级韩国一区久久二区综合| 久久久久久午夜成人影院| 日韩十八禁一区二区久久| 99久久精品国内| 久久精品中文无码资源站| 久久久久女教师免费一区| 999久久久免费精品国产| 久久精品国产日本波多野结衣| 久久av免费天堂小草播放| 久久婷婷国产麻豆91天堂| 亚洲AV无码久久精品狠狠爱浪潮 | 亚洲成av人片不卡无码久久| 国产午夜久久影院| 伊人久久精品无码二区麻豆| 合区精品久久久中文字幕一区| 久久夜色tv网站| 精品国产福利久久久| 亚洲国产精品无码久久久不卡| 午夜精品久久久久久| 欧美日韩精品久久久久| 精品久久久久中文字| 7国产欧美日韩综合天堂中文久久久久 | 色欲综合久久躁天天躁蜜桃| 久久99九九国产免费看小说| 久久久WWW成人免费精品| 伊人色综合久久天天| 欧美一区二区精品久久| 亚洲综合精品香蕉久久网97| 精品亚洲综合久久中文字幕|