build.sh 4.17 KB
Newer Older
wukongdaily's avatar
wukongdaily committed
1
#!/bin/bash
2
source shell/custom-packages.sh
wukongdaily's avatar
wukongdaily committed
3
# 该文件实际为imagebuilder容器内的build.sh
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

if [ -n "$CUSTOM_PACKAGES" ]; then
  echo "✅ 你选择了第三方软件包:$CUSTOM_PACKAGES"
  if [ "$PROFILE" = "glinet_gl-mt3000" ]; then
    echo "❌ 检查到您集成了第三方软件包 由于mt3000闪存空间较小 不支持此操作"
    echo "✅ 系统将自动帮你注释掉shell/custom-packages.sh中的插件 目前支持第三方插件集成的机型是mt2500/mt6000等大闪存机型"
    CUSTOM_PACKAGES=""
  else
    # 下载 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 shell/prepare-packages.sh
    ls -lah /home/build/immortalwrt/packages/
    # 添加架构优先级信息
    sed -i '1i\
    arch aarch64_generic 10\n\
    arch aarch64_cortex-a53 15' repositories.conf
  fi
else
  echo "⚪️ 未选择任何第三方软件包"
fi
wukongdaily's avatar
wukongdaily committed
33
34
# yml 传入的路由器型号 PROFILE
echo "Building for profile: $PROFILE"
35
echo "Include Docker: $INCLUDE_DOCKER"
wukongdaily's avatar
wukongdaily committed
36
37
38
39
40
41
42
43
44
45
46
47
echo "Create pppoe-settings"
mkdir -p  /home/build/immortalwrt/files/etc/config

# 创建pppoe配置文件 yml传入pppoe变量————>pppoe-settings文件
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
48
49
50
51
52

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


53
# 定义所需安装的包列表 下列插件你都可以自行删减
wukongdaily's avatar
wukongdaily committed
54
55
56
57
PACKAGES=""
PACKAGES="$PACKAGES curl"
PACKAGES="$PACKAGES luci-i18n-firewall-zh-cn"
PACKAGES="$PACKAGES luci-i18n-filebrowser-zh-cn"
58
PACKAGES="$PACKAGES luci-theme-argon"
wukongdaily's avatar
wukongdaily committed
59
60
PACKAGES="$PACKAGES luci-app-argon-config"
PACKAGES="$PACKAGES luci-i18n-argon-config-zh-cn"
61
PACKAGES="$PACKAGES luci-i18n-diskman-zh-cn"
wukongdaily's avatar
wukongdaily committed
62
#23.05
wukongdaily's avatar
wukongdaily committed
63
PACKAGES="$PACKAGES luci-i18n-opkg-zh-cn"
wukongdaily's avatar
wukongdaily committed
64
PACKAGES="$PACKAGES luci-i18n-ttyd-zh-cn"
65
PACKAGES="$PACKAGES luci-i18n-passwall-zh-cn"
wukongdaily's avatar
wukongdaily committed
66
PACKAGES="$PACKAGES luci-app-openclash"
67
PACKAGES="$PACKAGES luci-i18n-homeproxy-zh-cn"
wukongdaily's avatar
wukongdaily committed
68
PACKAGES="$PACKAGES openssh-sftp-server"
69
70
71
72
# 增加几个必备组件 方便用户安装iStore
PACKAGES="$PACKAGES fdisk"
PACKAGES="$PACKAGES script-utils"
PACKAGES="$PACKAGES luci-i18n-samba4-zh-cn"
73
74
75
# 第三方软件包 合并
# ======== shell/custom-packages.sh =======
PACKAGES="$PACKAGES $CUSTOM_PACKAGES"
76
77
78
79
80
81
82

# 判断是否需要编译 Docker 插件
if [ "$INCLUDE_DOCKER" = "yes" ]; then
    PACKAGES="$PACKAGES luci-i18n-dockerman-zh-cn"
    echo "Adding package: luci-i18n-dockerman-zh-cn"
fi

83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# 若构建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
98
99
100
101
102
103
104
105
106
107
108
109

# 构建镜像
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"

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

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