Skip to content

Commit 5581822

Browse files
author
jacob.zb
committed
fix bug and improve readme
1 parent e42e898 commit 5581822

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,32 @@ config.json
5151
| cos_region | COS 地区信息 | |
5252

5353
# 推荐用法
54-
在自己的 VPS 上利用定时任务触发该脚本。通过 COS 更新本地的订阅
54+
在自己的 VPS 上利用定时任务触发该脚本。通过 COS 更新本地的订阅
55+
56+
57+
# 部署
58+
59+
## 脚本
60+
```shell
61+
git clone https://github.com/coderbean/COS-CordCloud.git
62+
cd ./COS-CordCloud/
63+
python3 -m venv ./venv
64+
source ./venv/bin/activate
65+
pip install -r requirements.txt
66+
cp config-template.json config.json # 复制后并填写相关信息
67+
python update_clash_config.py # 测试并查看结果
68+
```
69+
70+
## 定时任务(Ubuntu 16 为例子)
71+
72+
每小时执行一次
73+
`0 */1 * * * cd /root/script/COS-CordCloud/ && source ./venv/bin/activate && python update_clash_config.py && deactivate`
74+
75+
crontab 配置
76+
```shell
77+
apt install cron # 安装cronie
78+
sudo systemctl enable cron.service; sudo systemctl start cron.service # 开通并开启cronie后台服务
79+
touch ~/MyCrontab && vim ~/MyCrontab # 建立一个MyCrontab(名字可以随便取)的文件并编辑之。
80+
crontab ~/MyCrontab # 载入MyCrontab计划到cron服务模块中
81+
crontab -l # 查看crontab计划,看看是否一切就绪
82+
```

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
autopep8==1.5
21
certifi==2019.11.28
32
chardet==3.0.4
43
cos-python-sdk-v5==1.7.7
5-
dicttoxml==1.7.4
64
idna==2.8
75
pycodestyle==2.5.0
86
requests==2.22.0

update_clash_config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#-*- coding:utf-8 -*-
12
import base64
23
import urllib.request
34
import os
@@ -160,7 +161,7 @@ def download_template(config, client):
160161

161162

162163
def get_config():
163-
f = open('config.json', 'r')
164+
f = open('config.json', 'r', encoding = 'utf-8')
164165
text = f.read()
165166
f.close()
166167
config = json.loads(text)

0 commit comments

Comments
 (0)