This commit is contained in:
starry
2025-11-17 12:23:09 +00:00
parent 59e6cef27c
commit 2bf01c1fb0
4 changed files with 161 additions and 0 deletions

9
openwrt/README.md Normal file
View File

@@ -0,0 +1,9 @@
### immortalwrt的docker构建脚本
根据自己情况修改,修改后执行`docker-run.sh`脚本即可自动构建,构建出来的固件在当前的`bin`目录。
- 初始化脚本修改:`files/etc/uci-defaults/99-custom.sh`
- 内置软件包修改:`build.sh`
- 镜像版本修改:`docker-run.sh`,选择符合自己设备的系统架构。

22
openwrt/build.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
PACKAGES=""
PACKAGES="$PACKAGES curl"
PACKAGES="$PACKAGES luci-i18n-base-zh-cn"
PACKAGES="$PACKAGES luci-i18n-firewall-zh-cn"
PACKAGES="$PACKAGES luci-i18n-package-manager-zh-cn"
PACKAGES="$PACKAGES luci-theme-argon"
PACKAGES="$PACKAGES luci-app-homeproxy"
PACKAGES="$PACKAGES luci-i18n-homeproxy-zh-cn"
PACKAGES="$PACKAGES luci-app-ttyd"
PACKAGES="$PACKAGES luci-i18n-ttyd-zh-cn"
PACKAGES="$PACKAGES luci-app-diskman"
PACKAGES="$PACKAGES luci-i18n-diskman-zh-cn"
PACKAGES="$PACKAGES luci-app-filemanager"
PACKAGES="$PACKAGES luci-i18n-filemanager-zh-cn"
# docker(需要1G以上空间)
# PACKAGES="$PACKAGES luci-app-dockerman"
# PACKAGES="$PACKAGES luci-i18n-dockerman-zh-cn"
make image PACKAGES="$PACKAGES" FILES="/home/build/immortalwrt/files" ROOTFS_PARTSIZE="512"

12
openwrt/docker-run.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
mkdir -p bin
chmod -R 777 bin
chmod +x build.sh
chmod +x files/etc/uci-defaults/99-custom.sh
docker run --rm -it \
-v ./bin:/home/build/immortalwrt/bin \
-v ./files/etc/uci-defaults:/home/build/immortalwrt/files/etc/uci-defaults \
-v ./build.sh:/home/build/immortalwrt/build.sh \
immortalwrt/imagebuilder:x86-64-openwrt-24.10.4 /home/build/immortalwrt/build.sh

View File

@@ -0,0 +1,118 @@
#!/bin/sh
exec >/tmp/setup.log 2>&1
###########################################################
# 自 定 义 配 置 区 域
###########################################################
### LuCI 默认主题(需要固件中已下载该主题)
luci_theme="argon"
### 系统后台密码(为空则不修改)
root_password="root"
### LAN 的 IPv4 地址(也是后台地址,例如 192.168.2.1
lan_ip_address="192.168.56.2"
### LAN 的子网掩码(例如 255.255.255.0
# lan_netmask="255.255.255.0"
### LAN 的 IPv4 网关(可为空)
# lan_gateway="192.168.1.1"
### LAN 的 DNS多个 DNS 可空格分隔,如 "8.8.8.8 1.1.1.1"
# lan_dns="8.8.8.8 223.5.5.5"
### DHCP 是否开启1=开启0=关闭)
# lan_dhcp_enable="1"
### DHCP 起始地址
# lan_dhcp_start="100"
### DHCP 地址池数量
# lan_dhcp_limit="150"
### DHCP 租约时间
# lan_dhcp_leasetime="12h"
### WiFi 名称 SSID为空则不修改
# wlan_name="ImmortalWrt"
### WiFi 密码(≥ 8 位才生效)
# wlan_password="12345678"
### PPPoE 宽带账号(为空则跳过)
# pppoe_username=""
### PPPoE 宽带密码
# pppoe_password=""
###########################################################
# 正 式 配 置 流 程
###########################################################
# ------------ root 密码 ------------
if [ -n "$root_password" ]; then
(echo "$root_password"; sleep 1; echo "$root_password") | passwd >/dev/null
fi
# ------------ LAN 基础配置 ------------
if [ -n "$lan_ip_address" ]; then
uci set network.lan.ipaddr="$lan_ip_address"
fi
if [ -n "$lan_netmask" ]; then
uci set network.lan.netmask="$lan_netmask"
fi
if [ -n "$lan_gateway" ]; then
uci set network.lan.gateway="$lan_gateway"
fi
# DNS
if [ -n "$lan_dns" ]; then
uci delete network.lan.dns 2>/dev/null
for d in $lan_dns; do
uci add_list network.lan.dns="$d"
done
fi
uci commit network
# ------------ DHCP 设置 ------------
if [ -n "$lan_dhcp_enable" ]; then
uci set dhcp.lan.ignore=$([ "$lan_dhcp_enable" = "1" ] && echo 0 || echo 1)
fi
[ -n "$lan_dhcp_start" ] && uci set dhcp.lan.start="$lan_dhcp_start"
[ -n "$lan_dhcp_limit" ] && uci set dhcp.lan.limit="$lan_dhcp_limit"
[ -n "$lan_dhcp_leasetime" ] && uci set dhcp.lan.leasetime="$lan_dhcp_leasetime"
uci commit dhcp
# ------------ WIFI 配置 ------------
if [ -n "$wlan_name" ] && [ -n "$wlan_password" ] && [ ${#wlan_password} -ge 8 ]; then
uci set wireless.@wifi-device[0].disabled='0'
uci set wireless.@wifi-iface[0].disabled='0'
uci set wireless.@wifi-iface[0].encryption='psk2'
uci set wireless.@wifi-iface[0].ssid="$wlan_name"
uci set wireless.@wifi-iface[0].key="$wlan_password"
uci commit wireless
fi
# ------------ PPPoE 宽带拨号 ------------
if [ -n "$pppoe_username" ] && [ -n "$pppoe_password" ]; then
uci set network.wan.proto=pppoe
uci set network.wan.username="$pppoe_username"
uci set network.wan.password="$pppoe_password"
uci commit network
fi
# ------------ LuCI 主题设置 ------------
if [ -n "$luci_theme" ]; then
# 设置默认主题
uci set luci.main.mediaurlbase="/luci-static/$luci_theme"
uci commit luci
fi
echo "All done!"