Skip to content

self hosting

炳 edited this page May 30, 2025 · 17 revisions

自建 repo

步骤参见Debian 文档。Debian 仓库有两种格式,这个仓库现在为官方归档格式。

建立并定时更新 repo

  1. clone 本 git 仓库,进入 git 仓库目录。
  2. 确认系统安装有 curl、jq、python3 requests,没有请使用包管理器安装。
  3. 运行 init_deb.py 初始化。
    需要其他架构请修改其中的SQL语句。
  4. 创建定时任务,定时运行 run.sh 并保存日志
    crontab 样例:50 6,10,14,18 * * * cd [THIS_DIR] && ./run.sh &>> ./deb/status/$(date +%Y-%m-%d).txt

    标准输出只输出应用变更,所以要使用 &>> 将标准输出和标准输入全部保存。
    你也可以像我一样将标准输入推送到 Telegram 或 Email 中。
    50 6,10,14,18 * * * cd [THIS_DIR] && ./run.sh 2>> deb/status/$(date +%Y-%m-%d).txt | ./send.py

  5. 要建立在线仓库请使用 Web 服务器将 deb 目录暴露出去。

(用户)使用 repo

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

请根据实际情况进行

echo 'Types: deb
URIs: https://packages.wcbing.top/deb  改为你仓库的地址
Suites: wcbing
Components: main
Signed-By: 你签名的 gpg 公钥
' | sudo tee /etc/apt/sources.list.d/wcbing.sources

随后 apt update 即可。

建立在线仓库提示

实际使用中:

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

给出一个 nginx 配置参考:

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