build.sh 4.26 KB
Newer Older
wukongdaily's avatar
wukongdaily committed
1
#!/bin/bash
2
3
4
# Log file for debugging
LOGFILE="/tmp/uci-defaults-log.txt"
echo "Starting 99-custom.sh at $(date)" >> $LOGFILE
wukongdaily's avatar
wukongdaily committed
5
6
7
8
9
# yml 传入的路由器型号 PROFILE
echo "Building for profile: $PROFILE"
# yml 传入的固件大小 ROOTFS_PARTSIZE
echo "Building for ROOTFS_PARTSIZE: $ROOTFS_PARTSIZE"

10
11
12
13
14
15
16
17
18
19
20
21
echo "Create pppoe-settings"
mkdir -p  /home/build/immortalwrt/files/etc/config

# 创建pppoe配置文件 yml传入环境变量ENABLE_PPPOE等 写入配置文件 供99-custom.sh读取
cat << EOF > /home/build/immortalwrt/files/etc/config/pppoe-settings
enable_pppoe=${ENABLE_PPPOE}
pppoe_account=${PPPOE_ACCOUNT}
pppoe_password=${PPPOE_PASSWORD}
EOF

echo "cat pppoe-settings"
cat /home/build/immortalwrt/files/etc/config/pppoe-settings
wukongdaily's avatar
wukongdaily committed
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 下载 run 文件仓库
echo "🔄 Cloning run file repo..."
git clone --depth=1 https://github.com/wukongdaily/store.git /tmp/store-run-repo

# 拷贝 run/arm64 下所有 run 文件和ipk文件 到 extra-packages 目录
mkdir -p /home/build/immortalwrt/extra-packages
cp -r /tmp/store-run-repo/run/arm64/* /home/build/immortalwrt/extra-packages/

echo "✅ Run files copied to extra-packages:"
ls -lh /home/build/immortalwrt/extra-packages/*.run
# 解压并拷贝ipk到packages目录
sh prepare-packages.sh
ls -lah /home/build/immortalwrt/packages/
# 添加架构优先级信息
sed -i '1i\
arch aarch64_generic 10\n\
arch aarch64_cortex-a53 15' repositories.conf
wukongdaily's avatar
wukongdaily committed
40
41
42
43
44

# 输出调试信息
echo "$(date '+%Y-%m-%d %H:%M:%S') - Starting build process..."


45
# 定义所需安装的包列表 23.05.4 下列插件你都可以自行删减
wukongdaily's avatar
wukongdaily committed
46
47
48
49
50
51
52
53
54
55
56
57
PACKAGES=""
PACKAGES="$PACKAGES curl"
PACKAGES="$PACKAGES luci-i18n-diskman-zh-cn"
PACKAGES="$PACKAGES luci-i18n-opkg-zh-cn"
PACKAGES="$PACKAGES luci-i18n-firewall-zh-cn"
PACKAGES="$PACKAGES luci-i18n-filebrowser-zh-cn"
PACKAGES="$PACKAGES luci-app-argon-config"
PACKAGES="$PACKAGES luci-i18n-argon-config-zh-cn"
PACKAGES="$PACKAGES luci-i18n-ttyd-zh-cn"
PACKAGES="$PACKAGES luci-i18n-homeproxy-zh-cn"
PACKAGES="$PACKAGES openssh-sftp-server"
PACKAGES="$PACKAGES luci-i18n-dockerman-zh-cn"
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# 代理工具
PACKAGES="$PACKAGES luci-i18n-passwall-zh-cn"
PACKAGES="$PACKAGES luci-app-openclash"
# docker
PACKAGES="$PACKAGES luci-i18n-dockerman-zh-cn"
# 静态文件服务器dufs(推荐)
PACKAGES="$PACKAGES luci-i18n-dufs-zh-cn"

# ============= imm仓库外的第三方插件===============
# ===== 若启用 请打开PACKAGES前面的注释==============
# istore商店
#PACKAGES="$PACKAGES luci-app-store"
# 首页和网络向导
#PACKAGES="$PACKAGES luci-i18n-quickstart-zh-cn"
# 去广告adghome
#PACKAGES="$PACKAGES luci-app-adguardhome"
# 代理相关
#PACKAGES="$PACKAGES luci-app-ssr-plus"
#PACKAGES="$PACKAGES luci-app-passwall2"
#PACKAGES="$PACKAGES luci-i18n-nikki-zh-cn"
# VPN
#PACKAGES="$PACKAGES luci-app-tailscale"
#PACKAGES="$PACKAGES luci-i18n-tailscale-zh-cn"
# 分区扩容 by sirpdboy 
#PACKAGES="$PACKAGES luci-app-partexp"
#PACKAGES="$PACKAGES luci-i18n-partexp-zh-cn"
# 酷猫主题 by sirpdboy 
#PACKAGES="$PACKAGES luci-theme-kucat"
# 网络测速 by sirpdboy 
#PACKAGES="$PACKAGES luci-app-netspeedtest"
#PACKAGES="$PACKAGES luci-i18n-netspeedtest-zh-cn"
wukongdaily's avatar
wukongdaily committed
89

90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

# 若构建openclash 则添加内核
if echo "$PACKAGES" | grep -q "luci-app-openclash"; then
    echo "✅ 已选择 luci-app-openclash,添加 openclash core"
    mkdir -p files/etc/openclash/core
    # Download clash_meta
    META_URL="https://raw.githubusercontent.com/vernesong/OpenClash/core/master/meta/clash-linux-arm64.tar.gz"
    wget -qO- $META_URL | tar xOvz > files/etc/openclash/core/clash_meta
    chmod +x files/etc/openclash/core/clash_meta
    # Download GeoIP and GeoSite
    wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat -O files/etc/openclash/GeoIP.dat
    wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat -O files/etc/openclash/GeoSite.dat
else
    echo "⚪️ 未选择 luci-app-openclash"
fi


wukongdaily's avatar
wukongdaily committed
107
108
109
110
111
112
113
114
115
116
117
118
# 构建镜像
echo "$(date '+%Y-%m-%d %H:%M:%S') - Building image with the following packages:"
echo "$PACKAGES"

make image PROFILE=$PROFILE PACKAGES="$PACKAGES" FILES="/home/build/immortalwrt/files" ROOTFS_PARTSIZE=$ROOTFS_PARTSIZE

if [ $? -ne 0 ]; then
    echo "$(date '+%Y-%m-%d %H:%M:%S') - Error: Build failed!"
    exit 1
fi

echo "$(date '+%Y-%m-%d %H:%M:%S') - Build completed successfully."