Files
drouter/_dev/build-image-remote.sh
T
liuzhuohua 64df3cf331 feat: Drouter 1.0.0 —— Debian 13 软路由管理系统
一套跑在 Debian 13 (trixie) 上的软路由管理系统,提供 43 个功能页面的
Web 管理面板:WAN 接入、PPPoE 多拨、DHCP/DNS、IPv6、防火墙、QoS 限速、
访问控制、DDNS、文件共享、Docker 管理等。

核心设计原则:不重新实现任何协议
  PPPoE 交给 ppp,DHCP 交给 dnsmasq,IPv6 RA 交给 radvd,NAT 交给 nftables。
  Web 面板只做三件事:渲染原生配置文件 → 语法预检 → 原子写入并 reload。
  面板删掉后,系统仍是一台配置完好的 Debian 路由器。

安全默认值
  · 安装后不接管网络:不改默认路由、不开 IP 转发、不启动 DHCP 服务
  · 所有改网络的动作都需要用户在面板上亲手点「应用」
  · 避开 5900 端口,不触碰 VNC / X 会话
  · 配置写入前先做语法预检,失败则回滚

架构
  · backend/  Python 3 标准库,零第三方依赖(9 个模块)
  · web/      原生 JS/CSS,无构建步骤
  · 常驻 helper 通过 Unix socket 提供 75 个动作,socket 不可用时回退 subprocess
  · 鉴权走 X-Token 请求头

打包
  · packaging/build-deb.sh            → drouter_1.0.0_all.deb(含 6 个 systemd 单元)
  · scripts/make-offline-deps.sh      → 236 个依赖 .deb + 本地仓库索引
  · packaging/build-offline-bundle.sh → 自包含离线包,目标机零外网可装
  · packaging/build-docker.sh         → 容器镜像(体验用)

测试
  40 套单元测试 + 3 个前端检查脚本(菜单映射 / 离线渲染 / 手机适配),
  全部挂在 devtools/sync.sh 的预检链里。

许可:MIT
2026-09-30 19:26:24 +08:00

35 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 在目标机构建 drouter Docker 镜像。
#
# 关键:基础镜像 debian:trixie-slim 里 /etc/apt/sources.list.d/debian.sources
# 指向 deb.debian.org,在国内拉 9.7MB 的 Packages 索引要几十秒甚至超时。
# 所以构建前先把容器内的源换成 163 镜像 —— 用 buildah 的 --build-arg 做不到
# (Dockerfile 里没有 ARG),改成「先 run 一个容器改源,再 commit 成临时基础镜像」。
set -e
cd /tmp/drouter-build || exit 1
echo "=== 1/3 准备国内源的基础镜像 ==="
CTR=$(buildah from docker.io/library/debian:trixie-slim)
buildah run "$CTR" -- bash -c '
cat > /etc/apt/sources.list <<EOF
deb http://mirrors.163.com/debian/ trixie main contrib non-free non-free-firmware
deb http://mirrors.163.com/debian/ trixie-updates main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
EOF
rm -f /etc/apt/sources.list.d/debian.sources
apt-get update -qq 2>&1 | tail -2
echo " 容器内源已换成 163"
'
buildah commit "$CTR" drouter-base-163:latest
buildah rm "$CTR" >/dev/null
echo "=== 2/3 构建镜像 ==="
# 把 Dockerfile 的 FROM 换成刚做好的临时基础镜像
sed 's|^FROM debian:trixie-slim|FROM drouter-base-163:latest|' \
packaging/docker/Dockerfile > /tmp/Dockerfile.drouter
buildah bud -f /tmp/Dockerfile.drouter -t drouter:1.0.0 --isolation=chroot .
echo "BUILD_RC=$?"
echo "=== 3/3 结果 ==="
buildah images | head -6