mirror of
https://github.com/Dichgrem/Dwrt-build.git
synced 2026-02-05 02:11:56 -05:00
Compare commits
10 Commits
v1.0
...
130a2298f2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
130a2298f2 | ||
|
|
15e1df01f5 | ||
|
|
f69b2749db | ||
|
|
fc3fe57112 | ||
|
|
b150951529 | ||
|
|
d842d24605 | ||
|
|
816642fba6 | ||
|
|
e2bc8f73ea | ||
|
|
31c5070c58 | ||
|
|
9f4f053257 |
424
.github/workflows/build.yml
vendored
424
.github/workflows/build.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Build Custom WRT
|
name: Build WRT
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -11,9 +11,13 @@ on:
|
|||||||
options:
|
options:
|
||||||
- openwrt
|
- openwrt
|
||||||
- immortalwrt
|
- immortalwrt
|
||||||
- x-wrt
|
- immortalwrt-mt798x
|
||||||
- lienol
|
- immortalwrt-mt798x-6.6
|
||||||
- lede
|
tag:
|
||||||
|
description: "版本号"
|
||||||
|
required: false
|
||||||
|
default: "v24.10.3"
|
||||||
|
type: string
|
||||||
version_type:
|
version_type:
|
||||||
description: "版本类型"
|
description: "版本类型"
|
||||||
required: true
|
required: true
|
||||||
@@ -22,30 +26,127 @@ on:
|
|||||||
options:
|
options:
|
||||||
- "snapshot"
|
- "snapshot"
|
||||||
- "stable"
|
- "stable"
|
||||||
branch:
|
|
||||||
description: "snapshot-branch"
|
|
||||||
required: false
|
|
||||||
default: "master"
|
|
||||||
type: string
|
|
||||||
tag:
|
|
||||||
description: "stable-tag"
|
|
||||||
required: false
|
|
||||||
default: "v24.10.2"
|
|
||||||
type: string
|
|
||||||
config_path:
|
config_path:
|
||||||
description: "config 路径"
|
description: "配置文件路径"
|
||||||
required: true
|
required: true
|
||||||
default: "config/myconfig"
|
default: "config/x86_64_config"
|
||||||
type: string
|
type: string
|
||||||
|
proxy_passwall2:
|
||||||
|
description: "启用Passwall2"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
proxy_luci_app_zzz:
|
||||||
|
description: "启用luci-app-zzz"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
proxy_luci_app_momo:
|
||||||
|
description: "启用luci-app-momo"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
threads:
|
threads:
|
||||||
description: "编译线程数(留空或填写 0 则自动使用 nproc)"
|
description: "编译线程数(填写 0 则使用 nproc)"
|
||||||
required: false
|
required: false
|
||||||
default: "0"
|
default: "0"
|
||||||
type: string
|
type: string
|
||||||
|
cache_enabled:
|
||||||
|
description: "启用缓存加速编译"
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
custom_shell:
|
||||||
|
description: "默认 shell"
|
||||||
|
required: false
|
||||||
|
default: "ash"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- ash
|
||||||
|
- bash
|
||||||
|
luci_theme:
|
||||||
|
description: "LuCI 主题"
|
||||||
|
required: false
|
||||||
|
default: "argon"
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- argon
|
||||||
|
- bootstrap
|
||||||
|
- material
|
||||||
|
enable_bbr:
|
||||||
|
description: "启用 BBR 拥塞控制"
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
type: boolean
|
||||||
|
custom_hostname:
|
||||||
|
description: "自定义 hostname(留空则跳过)"
|
||||||
|
required: false
|
||||||
|
default: "Dwrt"
|
||||||
|
type: string
|
||||||
|
custom_ip:
|
||||||
|
description: "自定义 IP 地址(留空则跳过)"
|
||||||
|
required: false
|
||||||
|
default: "192.168.1.1"
|
||||||
|
type: string
|
||||||
|
root_password:
|
||||||
|
description: "自定义 root 密码(留空则跳过)"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
type: string
|
||||||
|
custom_banner:
|
||||||
|
description: "自定义 SSH 横幅(留空则默认)"
|
||||||
|
required: false
|
||||||
|
default: ""
|
||||||
|
type: string
|
||||||
|
|
||||||
|
env:
|
||||||
|
CCACHE_DIR: ${{ github.workspace }}/wrt/.ccache
|
||||||
|
DL_DIR: ${{ github.workspace }}/wrt/dl
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
validate:
|
||||||
|
name: 验证输入参数
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
is_valid: ${{ steps.validate.outputs.is_valid }}
|
||||||
|
config_exists: ${{ steps.validate.outputs.config_exists }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Validate inputs
|
||||||
|
id: validate
|
||||||
|
run: |
|
||||||
|
echo "🔍 验证输入参数..."
|
||||||
|
|
||||||
|
# 验证 threads 参数
|
||||||
|
if [ -n "${{ inputs.threads }}" ]; then
|
||||||
|
if ! [[ "${{ inputs.threads }}" =~ ^[0-9]+$ ]]; then
|
||||||
|
echo "❌ threads 参数必须是数字"
|
||||||
|
echo "is_valid=false" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 验证配置文件是否存在
|
||||||
|
if [ -f "${{ inputs.config_path }}" ]; then
|
||||||
|
echo "config_exists=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "✅ 配置文件存在:${{ inputs.config_path }}"
|
||||||
|
else
|
||||||
|
echo "config_exists=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "❌ 配置文件不存在:${{ inputs.config_path }}"
|
||||||
|
echo "is_valid=false" >> "$GITHUB_OUTPUT"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "is_valid=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "✅ 所有输入参数验证通过"
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: 编译固件
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: validate
|
||||||
|
timeout-minutes: 360
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout current repository
|
- name: Checkout current repository
|
||||||
@@ -54,28 +155,55 @@ jobs:
|
|||||||
- name: Free up disk space
|
- name: Free up disk space
|
||||||
run: |
|
run: |
|
||||||
echo "🧹 开始清理无用文件,释放磁盘空间"
|
echo "🧹 开始清理无用文件,释放磁盘空间"
|
||||||
# 删除预装但编译中不需要的 SDK/工具
|
|
||||||
sudo rm -rf /usr/share/dotnet \
|
sudo rm -rf /usr/share/dotnet \
|
||||||
/usr/local/lib/android \
|
/usr/local/lib/android \
|
||||||
/opt/ghc \
|
/opt/ghc \
|
||||||
/opt/hostedtoolcache \
|
|
||||||
/opt/az \
|
/opt/az \
|
||||||
/opt/microsoft
|
/opt/microsoft \
|
||||||
# 删除 GitHub Actions self-hosted runner 缓存目录(如果存在)
|
/usr/local/share/boost \
|
||||||
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
/usr/share/swift \
|
||||||
# 删除系统缓存和日志
|
/usr/local/lib/nodejs
|
||||||
sudo rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* /var/log/*.log
|
sudo apt-get clean
|
||||||
# 显示当前磁盘使用情况
|
sudo rm -rf /var/lib/apt/lists/*
|
||||||
echo "📊 磁盘使用情况:"
|
echo "📊 磁盘使用情况:"
|
||||||
df -h || true
|
df -h || true
|
||||||
|
|
||||||
- name: Determine Git ref
|
- name: Setup ccache
|
||||||
|
uses: hendrikmuhs/ccache-action@v1.2
|
||||||
|
if: inputs.cache_enabled == true
|
||||||
|
with:
|
||||||
|
key: ${{ runner.os }}-wrt-ccache-${{ inputs.project }}-${{ inputs.version_type }}
|
||||||
|
max-size: 2G
|
||||||
|
|
||||||
|
- name: Cache downloads
|
||||||
|
uses: actions/cache@v4
|
||||||
|
if: inputs.cache_enabled == true
|
||||||
|
with:
|
||||||
|
path: ${{ env.DL_DIR }}
|
||||||
|
key: ${{ runner.os }}-wrt-dl-${{ inputs.project }}-${{ inputs.version_type }}-${{ hashFiles('**/*.config') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-wrt-dl-${{ inputs.project }}-${{ inputs.version_type }}-
|
||||||
|
${{ runner.os }}-wrt-dl-${{ inputs.project }}-
|
||||||
|
${{ runner.os }}-wrt-dl-
|
||||||
|
|
||||||
|
- name: Cache build directory
|
||||||
|
uses: actions/cache@v4
|
||||||
|
if: inputs.cache_enabled == true
|
||||||
|
with:
|
||||||
|
path: wrt/build_dir
|
||||||
|
key: ${{ runner.os }}-wrt-build-${{ inputs.project }}-${{ inputs.version_type }}-${{ hashFiles('**/*.config') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-wrt-build-${{ inputs.project }}-${{ inputs.version_type }}-
|
||||||
|
${{ runner.os }}-wrt-build-${{ inputs.project }}-
|
||||||
|
${{ runner.os }}-wrt-build-
|
||||||
|
|
||||||
|
- name: Choose Wrt Version
|
||||||
id: refinfo
|
id: refinfo
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ inputs.version_type }}" = "snapshot" ]; then
|
if [ "${{ inputs.version_type }}" = "snapshot" ]; then
|
||||||
echo "ref=${{ inputs.branch }}" >> $GITHUB_OUTPUT
|
echo "ref=master" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
echo "ref=${{ inputs.tag }}" >> $GITHUB_OUTPUT
|
echo "ref=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -91,7 +219,8 @@ jobs:
|
|||||||
libelf-dev libfuse-dev liblzma-dev libxml2-dev libyaml-dev \
|
libelf-dev libfuse-dev liblzma-dev libxml2-dev libyaml-dev \
|
||||||
uuid-dev device-tree-compiler antlr3 gperf \
|
uuid-dev device-tree-compiler antlr3 gperf \
|
||||||
time bc jq xxd swig upx-ucl ccache ecj fastjar imagemagick \
|
time bc jq xxd swig upx-ucl ccache ecj fastjar imagemagick \
|
||||||
llvm linux-tools-common libbpf-dev linux-tools-$(uname -r)
|
llvm linux-tools-common libbpf-dev linux-tools-$(uname -r) \
|
||||||
|
u-boot-tools device-tree-compiler
|
||||||
|
|
||||||
- name: Determine Git URL
|
- name: Determine Git URL
|
||||||
id: projectinfo
|
id: projectinfo
|
||||||
@@ -100,43 +229,175 @@ jobs:
|
|||||||
immortalwrt)
|
immortalwrt)
|
||||||
echo "url=https://github.com/immortalwrt/immortalwrt.git" >> $GITHUB_OUTPUT
|
echo "url=https://github.com/immortalwrt/immortalwrt.git" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
x-wrt)
|
immortalwrt-mt798x)
|
||||||
echo "url=https://github.com/x-wrt/x-wrt.git" >> $GITHUB_OUTPUT
|
echo "url=https://github.com/hanwckf/immortalwrt-mt798x.git" >> $GITHUB_OUTPUT
|
||||||
|
;;
|
||||||
|
immortalwrt-mt798x-6.6)
|
||||||
|
echo "url=https://github.com/padavanonly/immortalwrt-mt798x-6.6.git" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
openwrt)
|
openwrt)
|
||||||
echo "url=https://git.openwrt.org/openwrt/openwrt.git" >> $GITHUB_OUTPUT
|
echo "url=https://git.openwrt.org/openwrt/openwrt.git" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
lienol)
|
|
||||||
echo "url=https://github.com/Lienol/openwrt.git" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
lede)
|
|
||||||
echo "url=https://github.com/coolsnowwolf/lede.git" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "❌ 未知项目: ${{ inputs.project }}" >&2
|
echo "❌ 未知项目: ${{ inputs.project }}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
- name: Clone repository
|
- name: Clone Wrt source
|
||||||
run: |
|
run: |
|
||||||
echo "📥 克隆 ${{ inputs.project }} 仓库"
|
echo "📥 克隆 ${{ inputs.project }} 仓库"
|
||||||
git clone "${{ steps.projectinfo.outputs.url }}" wrt
|
git clone --depth 1 "${{ steps.projectinfo.outputs.url }}" -b "${{ steps.refinfo.outputs.ref }}" wrt || \
|
||||||
cd wrt
|
(git clone "${{ steps.projectinfo.outputs.url }}" wrt && cd wrt && git checkout "${{ steps.refinfo.outputs.ref }}")
|
||||||
echo "🔖 切换到版本:${{ steps.refinfo.outputs.ref }}"
|
echo "🔖 当前版本:$(cd wrt && git describe --tags --always || git rev-parse --short HEAD)"
|
||||||
git checkout "${{ steps.refinfo.outputs.ref }}"
|
|
||||||
|
- name: Apply custom configurations
|
||||||
|
working-directory: wrt
|
||||||
|
run: |
|
||||||
|
echo "⚙️ 应用自定义配置..."
|
||||||
|
|
||||||
|
# 检测项目类型
|
||||||
|
DETECT_TARGET_FILE="package/base-files/files/etc/openwrt_release"
|
||||||
|
if [ -f "$DETECT_TARGET_FILE" ]; then
|
||||||
|
if grep -qi "immortalwrt" "$DETECT_TARGET_FILE"; then
|
||||||
|
TARGET_TYPE="ImmortalWrt"
|
||||||
|
else
|
||||||
|
TARGET_TYPE="OpenWrt"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -d "feeds/packages" ]; then
|
||||||
|
TARGET_TYPE="ImmortalWrt"
|
||||||
|
else
|
||||||
|
TARGET_TYPE="OpenWrt"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "📋 检测到目标类型:$TARGET_TYPE"
|
||||||
|
|
||||||
|
# 1. 设置自定义 hostname
|
||||||
|
if [ -n "${{ inputs.custom_hostname }}" ]; then
|
||||||
|
CONFIG_GEN_FILE="package/base-files/files/bin/config_generate"
|
||||||
|
if [ -f "$CONFIG_GEN_FILE" ]; then
|
||||||
|
if [ "$TARGET_TYPE" = "ImmortalWrt" ]; then
|
||||||
|
sed -i "s/ImmortalWrt/${{ inputs.custom_hostname }}/g" "$CONFIG_GEN_FILE"
|
||||||
|
else
|
||||||
|
sed -i "s/OpenWrt/${{ inputs.custom_hostname }}/g" "$CONFIG_GEN_FILE"
|
||||||
|
fi
|
||||||
|
echo "✅ Hostname 已设置为:${{ inputs.custom_hostname }}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 2. 设置自定义 IP 地址
|
||||||
|
if [ -n "${{ inputs.custom_ip }}" ]; then
|
||||||
|
CONFIG_GEN_FILE="package/base-files/files/bin/config_generate"
|
||||||
|
if [ -f "$CONFIG_GEN_FILE" ]; then
|
||||||
|
sed -i 's/192\.168\.[0-9]*\.[0-9]*/${{ inputs.custom_ip }}/g' "$CONFIG_GEN_FILE"
|
||||||
|
echo "✅ 默认 IP 已设置为:${{ inputs.custom_ip }}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 3. 设置 root 密码
|
||||||
|
if [ -n "${{ inputs.root_password }}" ]; then
|
||||||
|
SHADOW_FILE="package/base-files/files/etc/shadow"
|
||||||
|
if [ -f "$SHADOW_FILE" ]; then
|
||||||
|
HASH=$(openssl passwd -1 '${{ inputs.root_password }}')
|
||||||
|
if grep -q "^root:" "$SHADOW_FILE"; then
|
||||||
|
sed -i "s|^root:[^:]*:|root:${HASH}:|" "$SHADOW_FILE"
|
||||||
|
elif grep -q "^root::" "$SHADOW_FILE"; then
|
||||||
|
sed -i "s|root::|root:${HASH}:|" "$SHADOW_FILE"
|
||||||
|
fi
|
||||||
|
echo "✅ root 密码已设置"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 4. 设置 LuCI 主题
|
||||||
|
mkdir -p package/base-files/files/etc/uci-defaults
|
||||||
|
cat >package/base-files/files/etc/uci-defaults/99_set_theme <<'EOF'
|
||||||
|
uci set luci.main.mediaurlbase=/luci-static/${{ inputs.luci_theme }}
|
||||||
|
uci commit luci
|
||||||
|
EOF
|
||||||
|
chmod +x package/base-files/files/etc/uci-defaults/99_set_theme
|
||||||
|
echo "✅ LuCI 主题已设置为:${{ inputs.luci_theme }}"
|
||||||
|
|
||||||
|
# 5. 启用/禁用 BBR
|
||||||
|
if [ "${{ inputs.enable_bbr }}" = "true" ]; then
|
||||||
|
mkdir -p package/base-files/files/etc/sysctl.d
|
||||||
|
cat >package/base-files/files/etc/sysctl.d/99-bbr.conf <<'EOF'
|
||||||
|
net.core.default_qdisc=fq_codel
|
||||||
|
net.ipv4.tcp_congestion_control=bbr
|
||||||
|
EOF
|
||||||
|
echo "✅ BBR 拥塞控制算法已启用"
|
||||||
|
else
|
||||||
|
rm -f package/base-files/files/etc/sysctl.d/99-bbr.conf || true
|
||||||
|
echo "ℹ️ BBR 拥塞控制算法已禁用"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 6. 设置默认 shell
|
||||||
|
PASSWD_FILE="package/base-files/files/etc/passwd"
|
||||||
|
if [ -f "$PASSWD_FILE" ]; then
|
||||||
|
if [ "${{ inputs.custom_shell }}" = "bash" ]; then
|
||||||
|
if grep -q "/bin/ash" "$PASSWD_FILE"; then
|
||||||
|
sed -i "s|/bin/ash|/bin/bash|g" "$PASSWD_FILE"
|
||||||
|
echo "✅ 默认 shell 已设置为 bash"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if grep -q "/bin/bash" "$PASSWD_FILE"; then
|
||||||
|
sed -i "s|/bin/bash|/bin/ash|g" "$PASSWD_FILE"
|
||||||
|
echo "✅ 默认 shell 已设置为 ash"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 7. 设置自定义 SSH 横幅
|
||||||
|
mkdir -p package/base-files/files/etc
|
||||||
|
if [ -n "${{ inputs.custom_banner }}" ]; then
|
||||||
|
cat >package/base-files/files/etc/banner <<'EOF'
|
||||||
|
${{ inputs.custom_banner }}
|
||||||
|
EOF
|
||||||
|
echo "✅ 使用自定义 banner"
|
||||||
|
else
|
||||||
|
cat >package/base-files/files/etc/banner <<'EOF'
|
||||||
|
| | _____ _____ ____________/ |______ | |
|
||||||
|
| |/ \ / \ / _ \_ __ \ __\__ \ | |
|
||||||
|
| | Y Y \ Y Y ( <_> ) | \/| | / __ \| |__
|
||||||
|
|___|__|_| /__|_| /\____/|__| |__| (____ /____/
|
||||||
|
\/ \/ By Dich \/
|
||||||
|
-----------------------------------------------------
|
||||||
|
EOF
|
||||||
|
echo "✅ 默认 banner 已设置"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "✅ 自定义配置完成"
|
||||||
|
|
||||||
- name: Copy and Run diy.sh
|
- name: Copy and Run diy.sh
|
||||||
run: |
|
run: |
|
||||||
echo "📂 复制 diy.sh 到 wrt 目录并执行"
|
echo "📂 复制 diy.sh 到 wrt 目录并执行(可选)"
|
||||||
|
if [ -f diy.sh ]; then
|
||||||
cp diy.sh wrt/diy.sh
|
cp diy.sh wrt/diy.sh
|
||||||
cd wrt
|
cd wrt
|
||||||
chmod +x diy.sh
|
chmod +x diy.sh
|
||||||
./diy.sh
|
./diy.sh || echo "⚠️ diy.sh 执行失败,继续构建..."
|
||||||
|
else
|
||||||
|
echo "ℹ️ diy.sh 不存在,跳过"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Update and install feeds
|
- name: Update and install feeds
|
||||||
working-directory: wrt
|
working-directory: wrt
|
||||||
run: |
|
run: |
|
||||||
|
if [ "${{ inputs.proxy_luci_app_zzz }}" = "true" ]; then
|
||||||
|
echo "📦 添加 luci-app-zzz feed"
|
||||||
|
echo "src-git luci-app-zzz https://github.com/Dichgrem/luci-app-zzz.git" >> "feeds.conf.default"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ inputs.proxy_passwall2 }}" = "true" ]; then
|
||||||
|
echo "📦 添加 passwall2 feed"
|
||||||
|
echo "src-git passwall https://github.com/xiaorouji/openwrt-passwall2.git" >> "feeds.conf.default"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${{ inputs.proxy_luci_app_momo }}" = "true" ]; then
|
||||||
|
echo "📦 添加 luci-app-momo feed"
|
||||||
|
echo "src-git momo https://github.com/nikkinikki-org/OpenWrt-momo.git" >> "feeds.conf.default"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "📦 更新 feeds"
|
echo "📦 更新 feeds"
|
||||||
./scripts/feeds update -a
|
./scripts/feeds update -a
|
||||||
echo "📦 安装 feeds"
|
echo "📦 安装 feeds"
|
||||||
@@ -145,11 +406,6 @@ jobs:
|
|||||||
- name: Setup configuration
|
- name: Setup configuration
|
||||||
run: |
|
run: |
|
||||||
echo "📋 复制配置:${{ inputs.config_path }} → wrt/.config"
|
echo "📋 复制配置:${{ inputs.config_path }} → wrt/.config"
|
||||||
if [ ! -f "${{ inputs.config_path }}" ]; then
|
|
||||||
echo "❌ 找不到配置文件:${{ inputs.config_path }}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp "${{ inputs.config_path }}" wrt/.config
|
cp "${{ inputs.config_path }}" wrt/.config
|
||||||
|
|
||||||
cd wrt
|
cd wrt
|
||||||
@@ -168,14 +424,19 @@ jobs:
|
|||||||
diff -u .config.before_oldconfig .config || true
|
diff -u .config.before_oldconfig .config || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Download source packages
|
- name: Download packages
|
||||||
working-directory: wrt
|
working-directory: wrt
|
||||||
run: |
|
run: |
|
||||||
echo "⬇️ 下载所有源码包(使用单线程 -j1 避免卡住)"
|
echo "⬇️ 下载所有源码包(使用单线程 -j1 避免卡住)"
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
START=$(date +%s)
|
||||||
time make download -j1
|
time make download -j1
|
||||||
|
END=$(date +%s)
|
||||||
|
DURATION=$((END - START))
|
||||||
|
echo "✅ 下载完成,耗时:${DURATION}秒"
|
||||||
|
|
||||||
- name: Build Firmware
|
- name: Build Firmware
|
||||||
|
id: build
|
||||||
working-directory: wrt
|
working-directory: wrt
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ inputs.threads }}" = "0" ] || [ -z "${{ inputs.threads }}" ]; then
|
if [ "${{ inputs.threads }}" = "0" ] || [ -z "${{ inputs.threads }}" ]; then
|
||||||
@@ -186,7 +447,9 @@ jobs:
|
|||||||
|
|
||||||
echo "🚀 全量编译(并行 ${JOBS})开始"
|
echo "🚀 全量编译(并行 ${JOBS})开始"
|
||||||
START=$(date "+%Y-%m-%d %H:%M:%S")
|
START=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
|
START_TS=$(date +%s)
|
||||||
echo "⏱️ 编译开始:${START}"
|
echo "⏱️ 编译开始:${START}"
|
||||||
|
echo "jobs_count=${JOBS}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
@@ -204,31 +467,72 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
END=$(date "+%Y-%m-%d %H:%M:%S")
|
END=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
|
END_TS=$(date +%s)
|
||||||
|
DURATION=$((END_TS - START_TS))
|
||||||
|
DURATION_H=$((DURATION / 3600))
|
||||||
|
DURATION_M=$(((DURATION % 3600) / 60))
|
||||||
|
DURATION_S=$((DURATION % 60))
|
||||||
|
|
||||||
echo "✅ 编译成功"
|
echo "✅ 编译成功"
|
||||||
echo "⏱️ 编译结束:${END}"
|
echo "⏱️ 编译结束:${END}"
|
||||||
|
echo "⏱️ 总耗时:${DURATION_H}小时 ${DURATION_M}分钟 ${DURATION_S}秒"
|
||||||
|
echo "build_success=true" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: list all target files
|
- name: Build statistics
|
||||||
|
if: steps.build.outputs.build_success == 'true'
|
||||||
run: |
|
run: |
|
||||||
echo ">>> 打印 wrt/bin/targets 下所有文件:"
|
echo "📊 编译统计信息:"
|
||||||
|
echo "项目:${{ inputs.project }}"
|
||||||
|
echo "版本:${{ steps.refinfo.outputs.ref }}"
|
||||||
|
echo "编译线程:${{ steps.build.outputs.jobs_count }}"
|
||||||
|
echo "缓存状态:${{ inputs.cache_enabled }}"
|
||||||
|
echo ""
|
||||||
|
echo "固件文件列表:"
|
||||||
if [ -d wrt/bin/targets ]; then
|
if [ -d wrt/bin/targets ]; then
|
||||||
find wrt/bin/targets -type f | sed 's/^/ - /'
|
find wrt/bin/targets -type f -exec ls -lh {} \; | awk '{print $9, $5}'
|
||||||
else
|
echo ""
|
||||||
echo "❗ wrt/bin/targets 目录不存在"
|
echo "总固件大小:"
|
||||||
|
du -sh wrt/bin/targets
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
- name: Upload build log on failure
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
if: failure()
|
||||||
|
with:
|
||||||
|
name: ${{ inputs.project }}-build-log-error
|
||||||
|
path: wrt/world_debug.log
|
||||||
|
retention-days: 7
|
||||||
|
if-no-files-found: ignore
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
if: steps.build.outputs.build_success == 'true'
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.project }}-output
|
name: ${{ inputs.project }}-output-${{ inputs.version_type }}-${{ github.run_number }}
|
||||||
path: |
|
path: |
|
||||||
wrt/bin/targets/**
|
wrt/bin/targets/**
|
||||||
!wrt/bin/targets/x86/64/packages/**
|
!wrt/bin/targets/x86/64/packages/**
|
||||||
|
!wrt/bin/targets/**/packages/**
|
||||||
if-no-files-found: warn
|
if-no-files-found: warn
|
||||||
compression-level: 6
|
compression-level: 6
|
||||||
overwrite: false
|
overwrite: false
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
- name: Upload build log
|
- name: Upload config diff
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
if: steps.build.outputs.build_success == 'true'
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.project }}-build-log
|
name: ${{ inputs.project }}-config-diff
|
||||||
path: wrt/world_debug.log
|
path: |
|
||||||
|
wrt/.config
|
||||||
|
wrt/.config.before_oldconfig
|
||||||
|
if-no-files-found: ignore
|
||||||
|
retention-days: 7
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
echo "🧹 清理工作空间..."
|
||||||
|
cd wrt
|
||||||
|
make clean || true
|
||||||
|
echo "✅ 清理完成"
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ This is a Openwrt build workflows.
|
|||||||
|
|
||||||
| 名称 | URL | SHORT |
|
| 名称 | URL | SHORT |
|
||||||
|--------------|------------------------------------------------------------|--------------------------|
|
|--------------|------------------------------------------------------------|--------------------------|
|
||||||
| x-wrt | https://github.com/x-wrt/x-wrt.git | x-wrt/x-wrt |
|
|
||||||
| openwrt | https://git.openwrt.org/openwrt/openwrt.git | openwrt/openwrt |
|
| openwrt | https://git.openwrt.org/openwrt/openwrt.git | openwrt/openwrt |
|
||||||
| lienol | https://github.com/Lienol/openwrt.git | Lienol/openwrt |
|
|
||||||
| lede | https://github.com/coolsnowwolf/lede.git | coolsnowwolf/lede |
|
|
||||||
| immortalwrt | https://github.com/immortalwrt/immortalwrt.git | immortalwrt/immortalwrt |
|
| immortalwrt | https://github.com/immortalwrt/immortalwrt.git | immortalwrt/immortalwrt |
|
||||||
|
| immortalwrt-mt798x | https://github.com/hanwckf/immortalwrt-mt798x.git | hanwckf/immortalwrt-mt798x |
|
||||||
|
| immortalwrt-mt798x-6.6 | https://github.com/padavanonly/immortalwrt-mt798x-6.6.git | padavanonly/immortalwrt-mt798x-6.6 |
|
||||||
|
|
||||||
|
|||||||
8290
config/nokia_ea0326gmp_config
Normal file
8290
config/nokia_ea0326gmp_config
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
92
diy.sh
92
diy.sh
@@ -14,15 +14,67 @@ echo "🚀 添加自定义 feed 源..."
|
|||||||
|
|
||||||
echo "✅ feeds 添加完成"
|
echo "✅ feeds 添加完成"
|
||||||
|
|
||||||
|
# 检测项目类型(OpenWrt 或 ImmortalWrt)
|
||||||
|
DETECT_TARGET_FILE="package/base-files/files/etc/openwrt_release"
|
||||||
|
if [ -f "$DETECT_TARGET_FILE" ]; then
|
||||||
|
if grep -qi "immortalwrt" "$DETECT_TARGET_FILE"; then
|
||||||
|
TARGET_TYPE="ImmortalWrt"
|
||||||
|
elif grep -qi "openwrt" "$DETECT_TARGET_FILE"; then
|
||||||
|
TARGET_TYPE="OpenWrt"
|
||||||
|
else
|
||||||
|
TARGET_TYPE="OpenWrt"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# 如果检测文件不存在,通过其他方式判断
|
||||||
|
if [ -d "feeds/packages" ]; then
|
||||||
|
TARGET_TYPE="ImmortalWrt"
|
||||||
|
else
|
||||||
|
TARGET_TYPE="OpenWrt"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "📋 检测到目标类型:$TARGET_TYPE"
|
||||||
|
|
||||||
# 1. 默认 hostname
|
# 1. 默认 hostname
|
||||||
sed -i 's/=ImmortalWrt/=Dwrt/' package/base-files/files/bin/config_generate
|
CONFIG_GEN_FILE="package/base-files/files/bin/config_generate"
|
||||||
|
if [ -f "$CONFIG_GEN_FILE" ]; then
|
||||||
|
if [ "$TARGET_TYPE" = "ImmortalWrt" ]; then
|
||||||
|
sed -i "s/ImmortalWrt/Dwrt/g" "$CONFIG_GEN_FILE"
|
||||||
|
else
|
||||||
|
sed -i "s/OpenWrt/Dwrt/g" "$CONFIG_GEN_FILE"
|
||||||
|
fi
|
||||||
|
echo "✅ Hostname 已修改为 Dwrt"
|
||||||
|
else
|
||||||
|
echo "⚠️ $CONFIG_GEN_FILE 不存在,跳过 hostname 修改"
|
||||||
|
fi
|
||||||
|
|
||||||
# 2. 默认 IP 地址
|
# 2. 默认 IP 地址
|
||||||
sed -i 's/192.168.1.1/192.168.1.1/' package/base-files/files/bin/config_generate
|
if [ -f "$CONFIG_GEN_FILE" ]; then
|
||||||
|
if grep -q "192.168.2.1" "$CONFIG_GEN_FILE"; then
|
||||||
|
sed -i 's/192.168.2.1/192.168.1.1/' "$CONFIG_GEN_FILE"
|
||||||
|
echo "✅ 默认 IP 已修改为 192.168.1.1"
|
||||||
|
elif grep -q "192.168.1.1" "$CONFIG_GEN_FILE"; then
|
||||||
|
echo "✅ 默认 IP 已经是 192.168.1.1"
|
||||||
|
else
|
||||||
|
echo "⚠️ $CONFIG_GEN_FILE 中未找到默认 IP 地址"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# 3. 默认 root 密码
|
# 3. 默认 root 密码
|
||||||
HASH=$(openssl passwd -1 'password')
|
SHADOW_FILE="package/base-files/files/etc/shadow"
|
||||||
sed -i "s|root::0:0:99999|root:${HASH}:0:0:99999|" package/base-files/files/etc/shadow
|
if [ -f "$SHADOW_FILE" ]; then
|
||||||
|
HASH=$(openssl passwd -1 'password')
|
||||||
|
if grep -q "^root::" "$SHADOW_FILE"; then
|
||||||
|
sed -i "s|root::0:0:99999|root:${HASH}:0:0:99999|" "$SHADOW_FILE"
|
||||||
|
echo "✅ root 密码已设置"
|
||||||
|
elif grep -q "^root:" "$SHADOW_FILE"; then
|
||||||
|
echo "⚠️ root 账户已设置密码,跳过"
|
||||||
|
else
|
||||||
|
echo "⚠️ $SHADOW_FILE 中未找到 root 账户"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ $SHADOW_FILE 不存在,跳过 root 密码设置"
|
||||||
|
fi
|
||||||
|
|
||||||
# 4. 设置默认 LuCI 主题为 argon
|
# 4. 设置默认 LuCI 主题为 argon
|
||||||
mkdir -p package/base-files/files/etc/uci-defaults
|
mkdir -p package/base-files/files/etc/uci-defaults
|
||||||
@@ -31,6 +83,7 @@ uci set luci.main.mediaurlbase=/luci-static/argon
|
|||||||
uci commit luci
|
uci commit luci
|
||||||
EOF
|
EOF
|
||||||
chmod +x package/base-files/files/etc/uci-defaults/99_set_theme
|
chmod +x package/base-files/files/etc/uci-defaults/99_set_theme
|
||||||
|
echo "✅ LuCI 主题已设置为 argon"
|
||||||
|
|
||||||
# 5. 默认加载 BBR 拥塞控制算法
|
# 5. 默认加载 BBR 拥塞控制算法
|
||||||
mkdir -p package/base-files/files/etc/sysctl.d
|
mkdir -p package/base-files/files/etc/sysctl.d
|
||||||
@@ -38,16 +91,28 @@ cat >package/base-files/files/etc/sysctl.d/99-bbr.conf <<'EOF'
|
|||||||
net.core.default_qdisc=fq_codel
|
net.core.default_qdisc=fq_codel
|
||||||
net.ipv4.tcp_congestion_control=bbr
|
net.ipv4.tcp_congestion_control=bbr
|
||||||
EOF
|
EOF
|
||||||
|
echo "✅ BBR 拥塞控制算法已启用"
|
||||||
|
|
||||||
# 6. 修改默认 shell 为 bash
|
# 6. 修改默认 shell 为 bash
|
||||||
sed -i "s|/bin/ash|/bin/bash|g" package/base-files/files/etc/passwd
|
PASSWD_FILE="package/base-files/files/etc/passwd"
|
||||||
# 你需要在 .config 中确保包含 bash,例如:
|
if [ -f "$PASSWD_FILE" ]; then
|
||||||
# echo 'CONFIG_PACKAGE_bash=y' >> .config
|
if grep -q "/bin/ash" "$PASSWD_FILE"; then
|
||||||
|
sed -i "s|/bin/ash|/bin/bash|g" "$PASSWD_FILE"
|
||||||
|
echo "✅ 默认 shell 已修改为 bash"
|
||||||
|
elif grep -q "/bin/bash" "$PASSWD_FILE"; then
|
||||||
|
echo "✅ 默认 shell 已经是 bash"
|
||||||
|
else
|
||||||
|
echo "⚠️ $PASSWD_FILE 中未找到 ash 或 bash"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ $PASSWD_FILE 不存在,跳过 shell 修改"
|
||||||
|
fi
|
||||||
|
|
||||||
# 7. 自定义 SSH 登录横幅
|
# 7. 自定义 SSH 登录横幅
|
||||||
mkdir -p package/base-files/files/etc
|
mkdir -p package/base-files/files/etc
|
||||||
if [ -f "scripts/custom-files/banner.txt" ]; then
|
if [ -f "scripts/custom-files/banner.txt" ]; then
|
||||||
cp scripts/custom-files/banner.txt package/base-files/files/etc/banner
|
cp scripts/custom-files/banner.txt package/base-files/files/etc/banner
|
||||||
|
echo "✅ 使用自定义 banner"
|
||||||
else
|
else
|
||||||
cat >package/base-files/files/etc/banner <<'EOF'
|
cat >package/base-files/files/etc/banner <<'EOF'
|
||||||
| | _____ _____ ____________/ |______ | |
|
| | _____ _____ ____________/ |______ | |
|
||||||
@@ -57,15 +122,16 @@ else
|
|||||||
\/ \/ By Dich \/
|
\/ \/ By Dich \/
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
EOF
|
EOF
|
||||||
|
echo "✅ 默认 banner 已设置"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 8. 自定义 LuCI 概览设备型号
|
# 8. 自定义 LuCI 概览设备型号
|
||||||
cat >package/base-files/files/etc/uci-defaults/99-model-fix <<'EOF'
|
#cat >package/base-files/files/etc/uci-defaults/99-model-fix <<'EOF'
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
mkdir -p /tmp/sysinfo
|
#mkdir -p /tmp/sysinfo
|
||||||
echo "Myrouter" > /tmp/sysinfo/model
|
#echo "Myrouter" > /tmp/sysinfo/model
|
||||||
exit 0
|
#exit 0
|
||||||
EOF
|
#EOF
|
||||||
chmod +x package/base-files/files/etc/uci-defaults/99-model-fix
|
#chmod +x package/base-files/files/etc/uci-defaults/99-model-fix
|
||||||
|
|
||||||
echo "✅ diy.sh 执行完毕"
|
echo "✅ diy.sh 执行完毕"
|
||||||
|
|||||||
Reference in New Issue
Block a user