winlin

add oschina mirror

@@ -2,17 +2,6 @@ @@ -2,17 +2,6 @@
2 2
3 echo "更新CSDN镜像的脚本" 3 echo "更新CSDN镜像的脚本"
4 4
5 -# 创建CSDN镜像的过程如下:  
6 -# 1. 在CSDN上创建项目,从https://github.com/winlinvip/simple-rtmp-server拷贝过来。  
7 -# 2. 在本地虚拟机上:  
8 -# git clone git@code.csdn.net:winlinvip/srs-csdn.git  
9 -# 3. 创建同步的branch:  
10 -# git remote add upstream https://github.com/winlinvip/simple-rtmp-server.git  
11 -# git fetch upstream  
12 -# git checkout upstream/master -b srs.master  
13 -# 4. 执行本同步更新脚本,更新。  
14 -# bash scripts/csdn.mirror.sh  
15 -  
16 echo "argv[0]=$0" 5 echo "argv[0]=$0"
17 if [[ ! -f $0 ]]; then 6 if [[ ! -f $0 ]]; then
18 echo "directly execute the scripts on shell."; 7 echo "directly execute the scripts on shell.";
@@ -39,7 +28,7 @@ ret=$?; if [[ 0 -ne $ret ]]; then @@ -39,7 +28,7 @@ ret=$?; if [[ 0 -ne $ret ]]; then
39 1. 在CSDN上创建项目,从https://github.com/winlinvip/simple-rtmp-server拷贝过来。 28 1. 在CSDN上创建项目,从https://github.com/winlinvip/simple-rtmp-server拷贝过来。
40 2. 在本地虚拟机上: 29 2. 在本地虚拟机上:
41 git clone git@code.csdn.net:winlinvip/srs-csdn.git 30 git clone git@code.csdn.net:winlinvip/srs-csdn.git
42 - git checkout master && git branch 1.0release && git push origin 1.0release 31 + cd srs-csdn && git checkout master && git branch 1.0release && git push origin 1.0release
43 3. 创建同步的branch: 32 3. 创建同步的branch:
44 git remote add upstream https://github.com/winlinvip/simple-rtmp-server.git 33 git remote add upstream https://github.com/winlinvip/simple-rtmp-server.git
45 git fetch upstream 34 git fetch upstream
  1 +#!/bin/bash
  2 +
  3 +echo "更新OSChina镜像的脚本"
  4 +
  5 +echo "argv[0]=$0"
  6 +if [[ ! -f $0 ]]; then
  7 + echo "directly execute the scripts on shell.";
  8 + work_dir=`pwd`
  9 +else
  10 + echo "execute scripts in file: $0";
  11 + work_dir=`dirname $0`; work_dir=`(cd ${work_dir} && pwd)`
  12 +fi
  13 +work_dir=`(cd ${work_dir}/.. && pwd)`
  14 +product_dir=$work_dir
  15 +
  16 +# allow start script from any dir
  17 +cd $work_dir
  18 +
  19 +. ${product_dir}/scripts/_log.sh
  20 +ret=$?; if [[ $ret -ne 0 ]]; then exit $ret; fi
  21 +ok_msg "导入脚本成功"
  22 +
  23 +git remote -v|grep git.oschina.net >/dev/null 2>&1
  24 +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
  40 + exit 0;
  41 +fi
  42 +
  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 +ok_msg "OSChina同步git成功"
  95 +
  96 +exit 0