-
Notifications
You must be signed in to change notification settings - Fork 2
/
Creategithubfile
executable file
·55 lines (55 loc) · 2.2 KB
/
Creategithubfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
#开始整理config.yaml配置文件并提取代理
. /etc/profile
date=$(date "+%Y-%m-%d %H:%M:%S")
echo --$date-- "------------------------开始同步配置到github-------------------------" |tee -a /tmp/cf.log
parm_path=$(cd `dirname $0`; pwd)
cp $parm_path/formwork.update_to_github /tmp/no_dns_config.yaml
for filename in $(ls cfiplist)
do
while read line
do
let l++
uuid=`sed -n "$l p" uuid`
work=`sed -n "$l p" workhost`
if echo $line | grep "峰值速度";then
a=${line%:*}
b=${line#*:}
line="- {name: $b, server: $a, port: 80, type: vless, $uuid, tls: false, network: ws, ws-opts: {path: '"/?ed=2048"', headers: {$work}}}"
sed -i '/以上为代理地址请插入/i\'" $line"'' /tmp/no_dns_config.yaml
sed -i '/以上为节点选择组的自动选择代理请插入/i\'" - $b"'' /tmp/no_dns_config.yaml
sed -i '/以上为自动选择组下面的代理地址请插入/i\'" - $b"'' /tmp/no_dns_config.yaml
sed -i '/以上为负载均衡组下面的代理地址请插入/i\'" - $b"'' /tmp/no_dns_config.yaml
sed -i '/以上为故障转移组下面的代理地址请插入/i\'" - $b"'' /tmp/no_dns_config.yaml
sed -i '/以上为漏网之鱼组下面的代理地址请插入/i\'" - $b"'' /tmp/no_dns_config.yaml
fi
done < $filename
done
cd $parm_path
cp /tmp/no_dns_config.yaml no_dns_config.yaml
cp /tmp/config_cl.yaml config_dns_yes.yaml
while true;
do
date=$(date "+%Y-%m-%d %H:%M:%S")
echo "$date 更新!" > README.md
#git init
git add .
git commit -m "$date"
git remote set-url origin https://${GITHUBTOKEN}@github.com/hebe061103/cfip.git
result=`git push -u origin master`
if echo "$result" | grep -e "set up to track";then
date=$(date "+%Y-%m-%d %H:%M:%S")
echo --$date-- "------------------------同步到github成功-------------------------" |tee -a /tmp/cf.log
break
else
let num++
date=$(date "+%Y-%m-%d %H:%M:%S")
echo --$date-- "------------------------同步失败,开始进行第$num次重试-------------------------" |tee -a /tmp/cf.log
sleep 10
if [ $num -eq 10 ];then
date=$(date "+%Y-%m-%d %H:%M:%S")
echo --$date-- "------------------------重试$num次失败,故障退出-------------------------" |tee -a /tmp/cf.log
break
fi
fi
done