正在显示
3 个修改的文件
包含
110 行增加
和
136 行删除
trunk/scripts/_mirror.utils.sh
0 → 100755
| 1 | +#!/bin/bash | ||
| 2 | + | ||
| 3 | +############################################# | ||
| 4 | +# help for the first checkout. | ||
| 5 | +############################################# | ||
| 6 | +function first_checkout() | ||
| 7 | +{ | ||
| 8 | + mirror_name=$1 | ||
| 9 | + git_url=$2 | ||
| 10 | + project_dir=$3 | ||
| 11 | + sync_script=$4 | ||
| 12 | + | ||
| 13 | + failed_msg "当前分支不是${mirror_name}镜像"; | ||
| 14 | + | ||
| 15 | + cat <<END | ||
| 16 | +创建${mirror_name}镜像的过程如下: | ||
| 17 | +1. 在${mirror_name}上创建项目, | ||
| 18 | + 可创建空项目,或从https://github.com/winlinvip/simple-rtmp-server拷贝过来。 | ||
| 19 | +2. 在本地虚拟机上: | ||
| 20 | + git clone $git_url | ||
| 21 | + cd $project_dir && git checkout master && git branch 1.0release && git push origin 1.0release | ||
| 22 | +3. 创建同步的branch: | ||
| 23 | + git remote add upstream https://github.com/winlinvip/simple-rtmp-server.git | ||
| 24 | + git fetch upstream | ||
| 25 | + git checkout upstream/master -b srs.master | ||
| 26 | + git checkout upstream/1.0release -b srs.1.0release | ||
| 27 | +4. 执行本同步更新脚本,更新。 | ||
| 28 | + bash $sync_script | ||
| 29 | +END | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +############################################# | ||
| 33 | +# branch master | ||
| 34 | +############################################# | ||
| 35 | +function sync_master() | ||
| 36 | +{ | ||
| 37 | + for ((;;)); do | ||
| 38 | + git checkout srs.master && git pull | ||
| 39 | + ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 40 | + failed_msg "(master)更新github分支失败,自动重试"; | ||
| 41 | + continue | ||
| 42 | + else | ||
| 43 | + ok_msg "(master)更新github分支成功" | ||
| 44 | + fi | ||
| 45 | + break | ||
| 46 | + done | ||
| 47 | + | ||
| 48 | + git checkout master && git merge srs.master | ||
| 49 | + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "(master)合并github分支失败, ret=$ret"; exit $ret; fi | ||
| 50 | + ok_msg "(master)合并github分支成功" | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +############################################# | ||
| 54 | +# branch 1.0release | ||
| 55 | +############################################# | ||
| 56 | +function sync_1_0_release() | ||
| 57 | +{ | ||
| 58 | + for ((;;)); do | ||
| 59 | + git checkout srs.1.0release && git pull | ||
| 60 | + ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 61 | + failed_msg "(1.0release)更新github分支失败,自动重试"; | ||
| 62 | + continue | ||
| 63 | + else | ||
| 64 | + ok_msg "(1.0release)更新github分支成功" | ||
| 65 | + fi | ||
| 66 | + break | ||
| 67 | + done | ||
| 68 | + | ||
| 69 | + git checkout 1.0release && git merge srs.1.0release | ||
| 70 | + ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "(1.0release)合并github分支失败, ret=$ret"; exit $ret; fi | ||
| 71 | + ok_msg "(1.0release)合并github分支成功" | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +############################################# | ||
| 75 | +# push | ||
| 76 | +############################################# | ||
| 77 | +function sync_push() | ||
| 78 | +{ | ||
| 79 | + mirror_name=$1 | ||
| 80 | + | ||
| 81 | + for ((;;)); do | ||
| 82 | + git push | ||
| 83 | + ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 84 | + failed_msg "提交${mirror_name}分支失败,自动重试"; | ||
| 85 | + continue | ||
| 86 | + else | ||
| 87 | + ok_msg "提交${mirror_name}分支成功" | ||
| 88 | + fi | ||
| 89 | + break | ||
| 90 | + done | ||
| 91 | + | ||
| 92 | + git checkout master | ||
| 93 | + ok_msg "${mirror_name}同步git成功" | ||
| 94 | +} |
| @@ -20,78 +20,18 @@ cd $work_dir | @@ -20,78 +20,18 @@ cd $work_dir | ||
| 20 | ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi | 20 | ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi |
| 21 | ok_msg "导入脚本成功" | 21 | ok_msg "导入脚本成功" |
| 22 | 22 | ||
| 23 | +source $work_dir/scripts/_mirror.utils.sh | ||
| 24 | + | ||
| 23 | git remote -v|grep code.csdn.net >/dev/null 2>&1 | 25 | git remote -v|grep code.csdn.net >/dev/null 2>&1 |
| 24 | ret=$?; if [[ 0 -ne $ret ]]; then | 26 | ret=$?; if [[ 0 -ne $ret ]]; then |
| 25 | - failed_msg "当前分支不是CSDN镜像"; | ||
| 26 | - cat <<END | ||
| 27 | -创建CSDN镜像的过程如下: | ||
| 28 | -1. 在CSDN上创建项目,从https://github.com/winlinvip/simple-rtmp-server拷贝过来。 | ||
| 29 | -2. 在本地虚拟机上: | ||
| 30 | - git clone git@code.csdn.net:winlinvip/srs-csdn.git | ||
| 31 | - cd srs-csdn && git checkout master && git branch 1.0release && git push origin 1.0release | ||
| 32 | -3. 创建同步的branch: | ||
| 33 | - git remote add upstream https://github.com/winlinvip/simple-rtmp-server.git | ||
| 34 | - git fetch upstream | ||
| 35 | - git checkout upstream/master -b srs.master | ||
| 36 | - git checkout upstream/1.0release -b srs.1.0release | ||
| 37 | -4. 执行本同步更新脚本,更新。 | ||
| 38 | - bash scripts/csdn.mirror.sh | ||
| 39 | -END | 27 | + first_checkout "CSDN" \ |
| 28 | + "git@code.csdn.net:winlinvip/srs-csdn.git" \ | ||
| 29 | + "srs-csdn" "$work_dir/scripts/csdn.mirror.sh" | ||
| 40 | exit 0; | 30 | exit 0; |
| 41 | fi | 31 | fi |
| 42 | 32 | ||
| 43 | -############################################# | ||
| 44 | -# branch master | ||
| 45 | -############################################# | ||
| 46 | -for ((;;)); do | ||
| 47 | - git checkout srs.master && git pull | ||
| 48 | - ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 49 | - failed_msg "(master)更新github分支失败,自动重试"; | ||
| 50 | - continue | ||
| 51 | - else | ||
| 52 | - ok_msg "(master)更新github分支成功" | ||
| 53 | - fi | ||
| 54 | - break | ||
| 55 | -done | ||
| 56 | - | ||
| 57 | -git checkout master && git merge srs.master | ||
| 58 | -ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "(master)合并github分支失败, ret=$ret"; exit $ret; fi | ||
| 59 | -ok_msg "(master)合并github分支成功" | ||
| 60 | - | ||
| 61 | -############################################# | ||
| 62 | -# branch 1.0release | ||
| 63 | -############################################# | ||
| 64 | -for ((;;)); do | ||
| 65 | - git checkout srs.1.0release && git pull | ||
| 66 | - ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 67 | - failed_msg "(1.0release)更新github分支失败,自动重试"; | ||
| 68 | - continue | ||
| 69 | - else | ||
| 70 | - ok_msg "(1.0release)更新github分支成功" | ||
| 71 | - fi | ||
| 72 | - break | ||
| 73 | -done | ||
| 74 | - | ||
| 75 | -git checkout 1.0release && git merge srs.1.0release | ||
| 76 | -ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "(1.0release)合并github分支失败, ret=$ret"; exit $ret; fi | ||
| 77 | -ok_msg "(1.0release)合并github分支成功" | ||
| 78 | - | ||
| 79 | -############################################# | ||
| 80 | -# push | ||
| 81 | -############################################# | ||
| 82 | - | ||
| 83 | -for ((;;)); do | ||
| 84 | - git push | ||
| 85 | - ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 86 | - failed_msg "提交CSDN分支失败,自动重试"; | ||
| 87 | - continue | ||
| 88 | - else | ||
| 89 | - ok_msg "提交CSDN分支成功" | ||
| 90 | - fi | ||
| 91 | - break | ||
| 92 | -done | ||
| 93 | - | ||
| 94 | -git checkout master | ||
| 95 | -ok_msg "CSDN同步git成功" | 33 | +sync_master |
| 34 | +sync_1_0_release | ||
| 35 | +sync_push "CSDN" | ||
| 96 | 36 | ||
| 97 | exit 0 | 37 | exit 0 |
| @@ -20,78 +20,18 @@ cd $work_dir | @@ -20,78 +20,18 @@ cd $work_dir | ||
| 20 | ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi | 20 | ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi |
| 21 | ok_msg "导入脚本成功" | 21 | ok_msg "导入脚本成功" |
| 22 | 22 | ||
| 23 | +source $work_dir/scripts/_mirror.utils.sh | ||
| 24 | + | ||
| 23 | git remote -v|grep git.oschina.net >/dev/null 2>&1 | 25 | git remote -v|grep git.oschina.net >/dev/null 2>&1 |
| 24 | ret=$?; if [[ 0 -ne $ret ]]; then | 26 | ret=$?; if [[ 0 -ne $ret ]]; then |
| 25 | - failed_msg "当前分支不是OSChina镜像"; | ||
| 26 | - cat <<END | ||
| 27 | -创建OSChina镜像的过程如下: | ||
| 28 | -1. 在OSChina上创建项目,从https://github.com/winlinvip/simple-rtmp-server拷贝过来。 | ||
| 29 | -2. 在本地虚拟机上: | ||
| 30 | - git clone git@git.oschina.net:winlinvip/srs.oschina.git | ||
| 31 | - cd srs.oschina && git checkout master && git branch 1.0release && git push origin 1.0release | ||
| 32 | -3. 创建同步的branch: | ||
| 33 | - git remote add upstream https://github.com/winlinvip/simple-rtmp-server.git | ||
| 34 | - git fetch upstream | ||
| 35 | - git checkout upstream/master -b srs.master | ||
| 36 | - git checkout upstream/1.0release -b srs.1.0release | ||
| 37 | -4. 执行本同步更新脚本,更新。 | ||
| 38 | - bash scripts/oschina.mirror.sh | ||
| 39 | -END | 27 | + first_checkout "OSChina" \ |
| 28 | + "git@git.oschina.net:winlinvip/srs.oschina.git" \ | ||
| 29 | + "srs.oschina" "$work_dir/scripts/oschina.mirror.sh" | ||
| 40 | exit 0; | 30 | exit 0; |
| 41 | fi | 31 | fi |
| 42 | 32 | ||
| 43 | -############################################# | ||
| 44 | -# branch master | ||
| 45 | -############################################# | ||
| 46 | -for ((;;)); do | ||
| 47 | - git checkout srs.master && git pull | ||
| 48 | - ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 49 | - failed_msg "(master)更新github分支失败,自动重试"; | ||
| 50 | - continue | ||
| 51 | - else | ||
| 52 | - ok_msg "(master)更新github分支成功" | ||
| 53 | - fi | ||
| 54 | - break | ||
| 55 | -done | ||
| 56 | - | ||
| 57 | -git checkout master && git merge srs.master | ||
| 58 | -ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "(master)合并github分支失败, ret=$ret"; exit $ret; fi | ||
| 59 | -ok_msg "(master)合并github分支成功" | ||
| 60 | - | ||
| 61 | -############################################# | ||
| 62 | -# branch 1.0release | ||
| 63 | -############################################# | ||
| 64 | -for ((;;)); do | ||
| 65 | - git checkout srs.1.0release && git pull | ||
| 66 | - ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 67 | - failed_msg "(1.0release)更新github分支失败,自动重试"; | ||
| 68 | - continue | ||
| 69 | - else | ||
| 70 | - ok_msg "(1.0release)更新github分支成功" | ||
| 71 | - fi | ||
| 72 | - break | ||
| 73 | -done | ||
| 74 | - | ||
| 75 | -git checkout 1.0release && git merge srs.1.0release | ||
| 76 | -ret=$?; if [[ 0 -ne $ret ]]; then failed_msg "(1.0release)合并github分支失败, ret=$ret"; exit $ret; fi | ||
| 77 | -ok_msg "(1.0release)合并github分支成功" | ||
| 78 | - | ||
| 79 | -############################################# | ||
| 80 | -# push | ||
| 81 | -############################################# | ||
| 82 | - | ||
| 83 | -for ((;;)); do | ||
| 84 | - git push | ||
| 85 | - ret=$?; if [[ 0 -ne $ret ]]; then | ||
| 86 | - failed_msg "提交OSChina分支失败,自动重试"; | ||
| 87 | - continue | ||
| 88 | - else | ||
| 89 | - ok_msg "提交OSChina分支成功" | ||
| 90 | - fi | ||
| 91 | - break | ||
| 92 | -done | ||
| 93 | - | ||
| 94 | -git checkout master | ||
| 95 | -ok_msg "OSChina同步git成功" | 33 | +sync_master |
| 34 | +sync_1_0_release | ||
| 35 | +sync_push "OSChina" | ||
| 96 | 36 | ||
| 97 | exit 0 | 37 | exit 0 |
-
请 注册 或 登录 后发表评论