Skip to content

Commit

Permalink
chore: Update README and template TOML
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Jul 23, 2024
1 parent 76f16f5 commit ebc72a3
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 25 deletions.
54 changes: 44 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,32 @@ Sync local repositories with remote.

## Quickstart

Download the binaries from the [Release](https://github.com/ustclug/Yuki/releases) page. For example:
### Setup

#### Debian and Ubuntu

Download `yuki_*_amd64.deb` from the [latest release][latest-release] and install it:

[latest-release]: https://github.com/ustclug/Yuki/releases/latest

```shell
# Using v0.6.1 for example
wget https://github.com/ustclug/Yuki/releases/download/v0.6.1/yuki_0.6.1_amd64.deb
sudo dpkg -i yuki_0.6.1_amd64.deb
```

Copy `/etc/yuki/daemon.example.toml` to `/etc/yuki/daemon.toml` and edit accordingly.

Create the `mirror` user and start the system service:

```shell
sudo useradd -m mirror
sudo systemctl enable --now yukid.service
```

#### Other distros

Download the binaries from the [latest release][latest-release]. For example:

```bash
wget https://github.com/ustclug/Yuki/releases/latest/download/yukictl_linux_amd64
Expand Down Expand Up @@ -54,6 +79,8 @@ systemctl start yukid
systemctl status yukid
```

### Configure repositories

Setup repository:

```bash
Expand Down Expand Up @@ -105,25 +132,32 @@ sed -i.bak 's/interval/cron/' /path/to/repo/configs/*.yaml
```

For post sync hook, the environment variables that are passed to the hook script are changed:

* `Dir` -> `DIR`: the directory of the repository
* `Name` -> `NAME`: the name of the repository

## Development

* Build `yukid`:

```
make yukid
```
```shell
make yukid
```

* Build `yukictl`:

```
make yukictl
```
```shell
make yukictl
```

* Build Debian package:

```shell
make deb
```

* Lint the whole project:

```
make lint
```
```shell
make lint
```
77 changes: 62 additions & 15 deletions etc/daemon.example.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,71 @@
debug = false
## 设置 debug 为 true 后会打开 echo web 框架的 debug 模式
## 以及在日志里输出程序里打印日志的位置
#debug = true

listen_addr = "127.0.0.1:9999"
db_url = "/home/mirror/yukid.db"
repo_config_dir = "/home/mirror/repos/"
## 设置 sqlite 数据库文件的路径
## 格式可以是文件路径或者是 url(如果需要设置特定参数的话)。例如:
## /var/run/yukid/data.db
## file:///home/fred/data.db?mode=ro&cache=private
## 参考 https://www.sqlite.org/c3ref/open.html
db_url = "/path/to/yukid.db"

fs = "zfs"
## 每个仓库的同步配置存放的文件夹
## 每个配置的后缀名必须是 `.yaml`
## 配置的格式参考下方 Repo Configuration
repo_config_dir = ["/path/to/config-dir"]

# uid:gid
owner = "1000:1000"
## 设置同步日志存放的文件夹
## 默认值是 /var/log/yuki/
#repo_logs_dir = "/var/log/yuki/"

log_file = "/home/mirror/log/yukid.log"
repo_logs_dir = "/home/mirror/log/"
log_level = "error"
## 数据所在位置的文件系统
## 可选的值为 "zfs" | "xfs" | "default"
## 影响获取仓库大小的方式,如果是 "default" 的话仓库大小恒为 `-1`
## 默认值是 "default"
#fs = "default"

bind_ip = "0.0.0.0"
## 设置 Docker Daemon 地址
## unix local socket: unix:///var/run/docker.sock
## tcp: tcp://127.0.0.1:2375
## 默认值是 "unix:///var/run/docker.sock"
#docker_endpoint = "unix:///var/run/docker.sock"

name_prefix = "syncing-"
## 设置同步程序的运行时的 uid 跟 gid,会影响仓库文件的 uid 跟 gid
## 格式为 uid:gid
## 默认值是 yukid 进程的 uid 跟 gid
#owner = "1000:1000"

images_upgrade_interval = "1h"
## 设置 yukid 的日志文件
## 默认值是 "/dev/stderr"
#log_file = "/path/to/yukid.log"

post_sync = ["/home/mirror/scripts/post_sync.sh"]
## 设置 log level
## 可选的值为 "debug" | "info" | "warn" | "error"
## 默认值是 "info"
#log_level = "info"

sync_timeout = "48h"
## 设置监听地址
## 默认值是 "127.0.0.1:9999"
#listen_addr = "127.0.0.1:9999"

## 设置同步仓库的时候默认绑定的 IP
## 默认值为空,即不绑定
#bind_ip = "1.2.3.4"

## 设置创建的 container 的名字前缀
## 默认值是 "syncing-"
#name_prefix = "syncing-"

## 设置同步完后执行的命令
## 默认值为空
#post_sync = ["/path/to/the/program"]

## 设置更新用到的 docker images 的频率
## 默认值为 "1h"
#images_upgrade_interval = "1h"

## 同步超时时间,如果超过了这个时间,同步容器会被强制停止
## 支持使用 time.ParseDuration() 支持的时间格式,诸如 "10m", "1h" 等
## 如果为 0 的话则不会超时。注意修改的配置仅对新启动的同步容器生效
## 默认值为 0
#sync_timeout = "48h"

0 comments on commit ebc72a3

Please sign in to comment.