标签:span lin push echo git pull while null origin apple
sh脚本下载gitlab-A的代码,
exp脚本自动读入gitlab-B的用户名及密码,提交实现同步.
$ cat ai_sdk_middleware.sh
#!/bin/bash
cd /opt/gitlabmirror-repo/Faceline
git clone ssh://git@gitlab.xxxxxx.com:9022/faceline/ai_sdk_middleware.git
cp ai_sdk_middleware.exp ai_sdk_middleware/
git branch -r | grep -v ‘\->‘ | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
cd ai_sdk_middleware
git fetch --all
git pull --all
echo ‘*.exp‘ >> .git/info/exclude
$ cat ai_sdk_middleware.exp
#!/usr/bin/expect -f
set user "root"
set pwd "1qaz1qaz"
spawn git remote rename origin old-origin
spawn git remote add origin http://172.16.2.42:8099/faceline/ai_sdk_middleware
spawn git push -u origin --all
expect "Username*"
send "$user\r"
expect "Password*"
send "$pwd\r"
expect eof
spawn git push origin --tags --force
expect "Username*"
send "$user\r"
expect "Password*"
send "$pwd\r"
expect eof
定时同步:
* 6 * * * /opt/gitlabmirror-repo/Faceline/ai_sdk_middleware.sh && cd /opt/gitlabmirror-repo/Faceline/ai_sdk_middleware && /usr/bin/expect -f ai_sdk_middleware.exp >/dev/null 2>&1
结束。
标签:span lin push echo git pull while null origin apple
原文地址:https://www.cnblogs.com/liusingbon/p/12983813.html