Skip to content

self hosting

炳 edited this page Dec 9, 2024 · 15 revisions

自建 repo

参见Debian 文档,这个仓库使用了扁平仓库格式(Flat Repository Format)

建立并定时更新 repo

  1. clone 本 git 仓库,进入 git 仓库目录。
  2. 确认系统安装有 curl、jq,没有请使用 apt 安装。
  3. 下载或用 Go 安装 github-downloader
  4. 运行 init_deb.py 初始化。
    需要其他架构请修改其中的SQL语句。
  5. 本地仓库请提前修改 run.sh,删去 merge-apt-repo 相关内容。
  6. 创建定时任务,定时运行 run.sh
    crontab 样例:0 11,15,19 * * * cd [THIS_DIR] && ./run.sh >> ./deb/status.txt
  7. 要建立在线仓库请使用 Web 服务器将 deb 目录暴露出去。

(用户)使用 repo

参考下面的命令,新建软件源配置文件。

请根据实际情况进行修改。

  • 在线仓库
    echo "deb [trusted=yes] https://path-of-repo/$(dpkg --print-architecture) /" | sudo tee /etc/apt/sources.list.d/wcbing.list
  • 本地仓库
    echo "deb [trusted=yes] file:/path/to/debs ./" | sudo tee /etc/apt/sources.list.d/wcbing.list

随后 apt update 即可。

建立在线仓库提示

实际使用中:

  • 官网提供的下载链接一般是 CDN 链接,为提升下载速度、减轻自建源压力,建议将这些请求重定向到官网上。
  • 部分国内软件下载链接有验证,单纯反代不可以,暂时从自建源下载。
  • 国内下载 Github 上的文件时比较慢,可以使用一些 Github 下载加速服务进行代理。

假设你将本项目 clone 在了 /packages,并将 repo 暴露在了 https://packages.wcbing.top/deb(首页请自行设置)。
给出一个 nginx 配置参考:

split_clients "${remote_addr}" $ghp {
    33% ghp.ci;
    33% ghproxy.cc;
    34% gh-proxy.com;
}
server {
    server_name packages.wcbing.top;
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
    charset 'utf-8';
    location ~ /.*/(https:/github\.com.*) {
        return 302 https://$ghp/$1;
    }
    location ~ /.*/(https?):/(.+/.*) {
        return 302 $1://$2;
    }
    location / { 
        root /packages;
    }
}
Clone this wiki locally