diff --git a/README.md b/README.md index 5a70332..8fef89c 100644 --- a/README.md +++ b/README.md @@ -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 @@ -54,6 +79,8 @@ systemctl start yukid systemctl status yukid ``` +### Configure repositories + Setup repository: ```bash @@ -105,6 +132,7 @@ 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 @@ -112,18 +140,24 @@ For post sync hook, the environment variables that are passed to the hook script * 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 + ``` diff --git a/etc/daemon.example.toml b/etc/daemon.example.toml index e580cf2..1237b75 100644 --- a/etc/daemon.example.toml +++ b/etc/daemon.example.toml @@ -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"