build.sh 3.76 KB
Newer Older
wukongdaily's avatar
wukongdaily committed
1
#!/bin/bash
2
# Log file for debugging
3
4
source shell/custom-packages.sh
echo "第三方软件包: $CUSTOM_PACKAGES"
5
6
LOGFILE="/tmp/uci-defaults-log.txt"
echo "Starting 99-custom.sh at $(date)" >> $LOGFILE
wukongdaily's avatar
wukongdaily committed
7
echo "编译固件大小为: $PROFILE MB"
wukongdaily's avatar
wukongdaily committed
8
echo "Include Docker: $INCLUDE_DOCKER"
wukongdaily's avatar
wukongdaily committed
9

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
if [ -z "$CUSTOM_PACKAGES" ]; then
  echo "⚪️ 未选择 任何第三方软件包"
else
  # ============= 同步第三方插件库==============
  # 正在同步第三方软件仓库
  echo "🔄 正在同步第三方软件仓库 Cloning run file repo..."
  git clone --depth=1 https://github.com/wukongdaily/store.git /tmp/store-run-repo
30

31
32
33
  # 拷贝 run/x86 下所有 run 文件和ipk文件 到 extra-packages 目录
  mkdir -p /home/build/immortalwrt/extra-packages
  cp -r /tmp/store-run-repo/run/x86/* /home/build/immortalwrt/extra-packages/
wukongdaily's avatar
wukongdaily committed
34

35
36
37
38
39
40
  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/
fi
wukongdaily's avatar
wukongdaily committed
41

42
43
# 输出调试信息
echo "$(date '+%Y-%m-%d %H:%M:%S') - 开始构建..."
44
# 定义所需安装的包列表 下列插件你都可以自行删减
wukongdaily's avatar
wukongdaily committed
45
46
PACKAGES=""
PACKAGES="$PACKAGES curl"
wukongdaily's avatar
wukongdaily committed
47
PACKAGES="$PACKAGES luci-i18n-diskman-zh-cn"
wukongdaily's avatar
wukongdaily committed
48
49
PACKAGES="$PACKAGES luci-i18n-firewall-zh-cn"
PACKAGES="$PACKAGES luci-i18n-filebrowser-zh-cn"
50
PACKAGES="$PACKAGES luci-theme-argon"
wukongdaily's avatar
wukongdaily committed
51
52
53
54
55
56
57
58
PACKAGES="$PACKAGES luci-app-argon-config"
PACKAGES="$PACKAGES luci-i18n-argon-config-zh-cn"
PACKAGES="$PACKAGES luci-i18n-opkg-zh-cn"
PACKAGES="$PACKAGES luci-i18n-ttyd-zh-cn"
PACKAGES="$PACKAGES luci-i18n-passwall-zh-cn"
PACKAGES="$PACKAGES luci-app-openclash"
PACKAGES="$PACKAGES luci-i18n-homeproxy-zh-cn"
PACKAGES="$PACKAGES openssh-sftp-server"
59
PACKAGES="$PACKAGES luci-i18n-samba4-zh-cn"
60
61
# 静态文件服务器dufs(推荐)
PACKAGES="$PACKAGES luci-i18n-dufs-zh-cn"
62
63
64
# ======== shell/custom-packages.sh =======
# 合并imm仓库以外的第三方插件
PACKAGES="$PACKAGES $CUSTOM_PACKAGES"
wukongdaily's avatar
wukongdaily committed
65
66
67
68
69
70

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

72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 若构建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-amd64.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
87
88
89
90
# 构建镜像
echo "$(date '+%Y-%m-%d %H:%M:%S') - Building image with the following packages:"
echo "$PACKAGES"

wukongdaily's avatar
wukongdaily committed
91
make image PROFILE="generic" PACKAGES="$PACKAGES" FILES="/home/build/immortalwrt/files" ROOTFS_PARTSIZE=$PROFILE
wukongdaily's avatar
wukongdaily committed
92
93
94
95
96
97
98

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."