-
Notifications
You must be signed in to change notification settings - Fork 1
/
immortalwrt_openwrt.sh
659 lines (613 loc) · 26.8 KB
/
immortalwrt_openwrt.sh
1
2
3
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
#!/usr/bin/env bash
# sudo bash -c 'bash <(curl -s https://build-scripts.immortalwrt.eu.org/init_build_environment.sh)'
qBittorrent_version=$(curl -sL https://api.github.com/repos/userdocs/qbittorrent-nox-static/releases | grep -oP '(?<="browser_download_url": ").*?release-\K\d+\.\d+\.\d+' | sort -Vr | head -n 1 || "")
libtorrent_version=$(curl -sL https://api.github.com/repos/userdocs/qbittorrent-nox-static/releases | grep -oP '(?<="browser_download_url": ").*?release-\d+\.\d+\.\d+_v\K\d+\.\d+\.\d+' | sort -Vr | head -n 1 || "")
curl -sL https://raw.githubusercontent.com/klever1988/nanopi-openwrt/zstd-bin/zstd | sudo tee /usr/bin/zstd > /dev/null
curl -sL $GITHUB_API_URL/repos/$GITHUB_REPOSITORY/releases | grep -oP '"browser_download_url": "\K[^"]*cache[^"]*' >xa
curl -sL api.github.com/repos/hong0980/OpenWrt-Cache/releases | grep -oP '"browser_download_url": "\K[^"]*cache[^"]*' >xc
mkdir firmware output 2>/dev/null
color() {
case $1 in
cy) echo -e "\033[1;33m$2\033[0m" ;;
cr) echo -e "\033[1;31m$2\033[0m" ;;
cg) echo -e "\033[1;32m$2\033[0m" ;;
cb) echo -e "\033[1;34m$2\033[0m" ;;
esac
}
status() {
CHECK=$?
END_TIME=$(date '+%H:%M:%S')
_date=" ==>用时 $[$(date +%s -d "$END_TIME") - $(date +%s -d "$BEGIN_TIME")] 秒"
[[ $_date =~ [0-9]+ ]] || _date=""
if [ $CHECK = 0 ]; then
printf "%35s %s %s %s %s %s %s\n" \
`echo -e "[ $(color cg ✔)\033[0;39m ]${_date}"`
else
printf "%35s %s %s %s %s %s %s\n" \
`echo -e "[ $(color cr ✕)\033[0;39m ]${_date}"`
fi
}
git_apply() {
for z in $@; do
[[ $z =~ \# ]] || wget -qO- $z | git apply --reject --ignore-whitespace
done
}
_find() {
find $1 -maxdepth 5 -type d -name "$2" -print -quit 2>/dev/null
}
move_directory() {
[ -d "$1" ] && mv -f "$1" "$2"
}
_packages() {
for z in $@; do
[[ $z =~ ^# ]] || echo "CONFIG_PACKAGE_$z=y" >>.config
done
}
_delpackage() {
for z in $@; do
[[ $z =~ ^# ]] || sed -i -E "s/(CONFIG_PACKAGE_.*$z)=y/# \1 is not set/" .config
done
}
_pushd() {
if ! pushd "$@" &> /dev/null; then
printf '\n%b\n' "该目录不存在。"
fi
}
_popd() {
if ! popd &> /dev/null; then
printf '%b\n' "该目录不存在。"
fi
}
_printf() {
awk '{printf "%s %-40s %s %s %s\n" ,$1,$2,$3,$4,$5}'
}
clone_dir() {
local repo_url branch
if [[ "$1" == */* ]]; then
repo_url="$1"
shift
else
branch="-b $1 --single-branch"
repo_url="$2"
shift 2
fi
local temp_dir=$(mktemp -d)
git clone -q $branch --depth 1 "https://github.com/$repo_url" $temp_dir 2>/dev/null || {
echo -e "$(color cr 拉取) https://github.com/$repo_url [ $(color cr ✕) ]" | _printf
return 0
}
[[ $repo_url == coolsnowwolf/packages ]] && {
[[ $REPO_BRANCH =~ 23.05 ]] && set -- "$@" "golang" "bandwidthd"
[[ $REPO_BRANCH =~ 21.02 ]] && set -- "$@" "docker" "dockerd" "containerd" "runc" "btrfs-progs" "golang" "bandwidthd"
}
for target_dir in "$@"; do
local source_dir current_dir destination_dir
if [[ ${repo_url##*/} == ${target_dir} ]]; then
mv ${temp_dir} ${target_dir}
source_dir=${target_dir}
else
source_dir=$(_find "$temp_dir" "$target_dir")
fi
[[ -d "$source_dir" ]] || continue
current_dir=$(_find "package/ feeds/ target/" "$target_dir")
destination_dir="${current_dir:-package/A/$target_dir}"
[[ -d "$current_dir" ]] && mv -f "$current_dir" ../
if mv -f "$source_dir" "${destination_dir%/*}"; then
if [[ -d "$current_dir" ]]; then
echo -e "$(color cg 替换) $target_dir [ $(color cg ✔) ]" | _printf
else
echo -e "$(color cb 添加) $target_dir [ $(color cb ✔) ]" | _printf
fi
fi
done
rm -rf "$temp_dir"
}
clone_url() {
for url in $@; do
name="${url##*/}"
if grep "^https" <<<"$url" | egrep -qv "openwrt_helloworld$|helloworld$|build$|openwrt-passwall-packages$"; then
local destination
local existing_path=$(_find "package/ target/ feeds/" "$name" | grep "/${name}$")
if [[ -d $existing_path ]]; then
mv -f $existing_path ../ && destination="$existing_path"
else
destination="package/A/$name"
fi
if git clone -q --depth 1 "$url" "$destination"; then
if [[ $destination = $existing_path ]]; then
echo -e "$(color cg 替换) $name [ $(color cg ✔) ]" | _printf
else
echo -e "$(color cb 添加) $name [ $(color cb ✔) ]" | _printf
fi
else
echo -e "$(color cr 拉取) $name [ $(color cr ✕) ]" | _printf
if [[ $destination = $existing_path ]]; then
mv -f ../${existing_path##*/} ${existing_path%/*}/ && \
echo -e "$(color cy 回退) ${existing_path##*/} [ $(color cy ✔) ]" | _printf
fi
fi
else
grep "^https" <<< "$url" | while IFS= read -r single_url; do
local temp_dir=$(mktemp -d) destination existing_sub_path
git clone -q --depth 1 "$single_url" $temp_dir && {
for sub_dir in $(ls -l $temp_dir | awk '/^d/{print $NF}' | grep -Ev 'dump$|dtest$'); do
existing_sub_path=$(_find "package/ feeds/ target/" "$sub_dir")
if [[ -d $existing_sub_path ]]; then
rm -rf $existing_sub_path && destination="$existing_sub_path"
else
destination="package/A"
fi
if mv -f $temp_dir/$sub_dir $destination; then
if [[ $destination = $existing_sub_path ]]; then
echo -e "$(color cg 替换) $sub_dir [ $(color cg ✔) ]" | _printf
else
echo -e "$(color cb 添加) $sub_dir [ $(color cb ✔) ]" | _printf
fi
fi
done
}
rm -rf $temp_dir
done
fi
done
}
config (){
case "$TARGET_DEVICE" in
"x86_64")
cat >.config<<-EOF
CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_64=y
CONFIG_TARGET_x86_64_DEVICE_generic=y
CONFIG_TARGET_ROOTFS_PARTSIZE=$PARTSIZE
CONFIG_TARGET_KERNEL_PARTSIZE=16
CONFIG_BUILD_NLS=y
CONFIG_BUILD_PATENTED=y
CONFIG_TARGET_IMAGES_GZIP=y
CONFIG_GRUB_IMAGES=y
# CONFIG_GRUB_EFI_IMAGES is not set
# CONFIG_VMDK_IMAGES is not set
EOF
;;
"r1-plus-lts"|"r1-plus"|"r4s"|"r2c"|"r2s")
cat >.config<<-EOF
CONFIG_TARGET_rockchip=y
CONFIG_TARGET_rockchip_armv8=y
CONFIG_TARGET_ROOTFS_PARTSIZE=$PARTSIZE
CONFIG_BUILD_NLS=y
CONFIG_BUILD_PATENTED=y
CONFIG_DRIVER_11AC_SUPPORT=y
CONFIG_DRIVER_11N_SUPPORT=y
CONFIG_DRIVER_11W_SUPPORT=y
EOF
case "$TARGET_DEVICE" in
"r1-plus-lts"|"r1-plus")
echo "CONFIG_TARGET_rockchip_armv8_DEVICE_xunlong_orangepi-$TARGET_DEVICE=y" >>.config ;;
"r4s"|"r2c"|"r2s")
echo "CONFIG_TARGET_rockchip_armv8_DEVICE_friendlyarm_nanopi-$TARGET_DEVICE=y" >>.config ;;
esac
;;
"newifi-d2")
cat >.config<<-EOF
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_d-team_newifi-d2=y
EOF
;;
"phicomm_k2p")
cat >.config<<-EOF
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_phicomm_k2p=y
EOF
;;
"asus_rt-n16")
if [[ "${REPO_BRANCH#*-}" = "18.06" ]]; then
cat >.config<<-EOF
CONFIG_TARGET_brcm47xx=y
CONFIG_TARGET_brcm47xx_mips74k=y
CONFIG_TARGET_brcm47xx_mips74k_DEVICE_asus_rt-n16=y
EOF
else
cat >.config<<-EOF
CONFIG_TARGET_bcm47xx=y
CONFIG_TARGET_bcm47xx_mips74k=y
CONFIG_TARGET_bcm47xx_mips74k_DEVICE_asus_rt-n16=y
EOF
fi
;;
"armvirt-64-default")
cat >.config<<-EOF
CONFIG_TARGET_armvirt=y
CONFIG_TARGET_armvirt_64=y
CONFIG_TARGET_armvirt_64_Default=y
EOF
;;
esac
}
min() {
echo VERSION="" >>$GITHUB_ENV
echo "FETCH_CACHE=true" >>$GITHUB_ENV
sed -i 's/luci-app-[^ ]* //g' {include/target.mk,$(find target/ -type f -name Makefile)}
echo -e "$(color cy '更新配置....')\c"; BEGIN_TIME=$(date '+%H:%M:%S')
make defconfig 1>/dev/null 2>&1
status
}
REPO_URL="https://github.com/immortalwrt/immortalwrt"
echo -e "$(color cy '拉取源码....')\c"; BEGIN_TIME=$(date '+%H:%M:%S')
[ "$REPO_BRANCH" -a "$REPO_BRANCH" != "master" ] && cmd="-b $REPO_BRANCH --single-branch"
git clone -q $cmd $REPO_URL $REPO_FLODER # --depth 1
status
[[ -d $REPO_FLODER ]] && cd $REPO_FLODER || exit
case "$TARGET_DEVICE" in
"x86_64") export NAME="x86_64";;
"asus_rt-n16") export NAME="bcm47xx_mips74k";;
"armvirt-64-default") export NAME="armvirt_64";;
"newifi-d2"|"phicomm_k2p") export NAME="ramips_mt7621";;
"r1-plus-lts"|"r1-plus"|"r4s"|"r2c"|"r2s") export NAME="rockchip_armv8";;
esac
SOURCE_NAME=$(basename $(dirname $REPO_URL))
export TOOLS_HASH=`git log --pretty=tformat:"%h" -n1 tools toolchain`
export CACHE_NAME="$SOURCE_NAME-${REPO_BRANCH#*-}-$TOOLS_HASH-$NAME"
echo "CACHE_NAME=$CACHE_NAME" >>$GITHUB_ENV
if (grep -q "$CACHE_NAME" ../xa || grep -q "$CACHE_NAME" ../xc); then
echo -e "$(color cy '下载tz-cache')\c"; BEGIN_TIME=$(date '+%H:%M:%S')
grep -q "$CACHE_NAME" ../xa && \
wget -qc -t=3 $(grep "$CACHE_NAME" ../xa) || wget -qc -t=3 $(grep "$CACHE_NAME" ../xc)
[ -e *.tzst ]; status
[ -e *.tzst ] && {
echo -e "$(color cy '部署tz-cache')\c"; BEGIN_TIME=$(date '+%H:%M:%S')
(tar -I unzstd -xf *.tzst || tar -xf *.tzst) && {
if ! grep -q "$CACHE_NAME-cache.tzst" ../xa; then
cp *.tzst ../output
echo "OUTPUT_RELEASE=true" >> $GITHUB_ENV
fi
sed -i 's/ $(tool.*\/stamp-compile)//' Makefile
}
[ -d staging_dir ]; status
}
else
echo "CACHE_ACTIONS=true" >>$GITHUB_ENV
fi
echo -e "$(color cy '更新软件....')\c"; BEGIN_TIME=$(date '+%H:%M:%S')
./scripts/feeds update -a 1>/dev/null 2>&1
./scripts/feeds install -a 1>/dev/null 2>&1
status
config
cat >>.config <<-EOF
CONFIG_KERNEL_BUILD_USER="win3gp"
CONFIG_KERNEL_BUILD_DOMAIN="OpenWrt"
CONFIG_PACKAGE_automount=y
CONFIG_PACKAGE_autosamba=y
CONFIG_PACKAGE_luci-app-accesscontrol=y
CONFIG_PACKAGE_luci-app-appfilter=y
CONFIG_PACKAGE_luci-app-arpbind=y
CONFIG_PACKAGE_luci-app-bridge=y
CONFIG_PACKAGE_luci-app-cowb-speedlimit=y
CONFIG_PACKAGE_luci-app-cowbping=y
CONFIG_PACKAGE_luci-app-cpulimit=y
CONFIG_PACKAGE_luci-app-ddnsto=y
CONFIG_PACKAGE_luci-app-diskman=y
CONFIG_PACKAGE_luci-app-filebrowser=y
CONFIG_PACKAGE_luci-app-filetransfer=y
CONFIG_PACKAGE_luci-app-ikoolproxy=y
CONFIG_PACKAGE_luci-app-luci-app-commands=y
CONFIG_PACKAGE_luci-app-oaf=y
CONFIG_PACKAGE_luci-app-opkg=y
CONFIG_PACKAGE_luci-app-passwall=y
CONFIG_PACKAGE_luci-app-ssr-plus=y
CONFIG_PACKAGE_luci-app-timedtask=y
CONFIG_PACKAGE_luci-app-tinynote=y
CONFIG_PACKAGE_luci-app-ttyd=y
CONFIG_PACKAGE_luci-app-upnp=y
CONFIG_PACKAGE_luci-app-vlmcsd=y
CONFIG_PACKAGE_luci-app-wifischedule=y
CONFIG_PACKAGE_luci-app-wizard=y
CONFIG_PACKAGE_default-settings-chn=y
CONFIG_DEFAULT_SETTINGS_OPTIMIZE_FOR_CHINESE=y
# CONFIG_LUCI_SRCDIET is not set #压缩 Lua 源代码
## CONFIG_LUCI_JSMIN is not set #压缩 JavaScript 源代码
# CONFIG_LUCI_CSSTIDY is not set #压缩 CSS 文件
EOF
config_generate="package/base-files/files/bin/config_generate"
color cy "自定义设置.... "
wget -qO package/base-files/files/etc/banner git.io/JoNK8
sed -i "/DISTRIB_DESCRIPTION/ {s/'$/-$SOURCE_NAME-$(TZ=UTC-8 date +%Y年%m月%d日)'/}" package/*/*/*/openwrt_release
sed -i "/VERSION_NUMBER/ s/if.*/if \$(VERSION_NUMBER),\$(VERSION_NUMBER),${REPO_BRANCH#*-}-SNAPSHOT)/" include/version.mk
sed -i "s/ImmortalWrt/OpenWrt/g" {$config_generate,include/version.mk}
sed -i "/listen_https/ {s/^/#/g}" package/*/*/*/files/uhttpd.config
sed -i "\$i uci -q set luci.main.mediaurlbase=\"/luci-static/bootstrap\" && uci -q commit luci\nuci -q set upnpd.config.enabled=\"1\" && uci -q commit upnpd\nsed -i 's/root::.*:::/root:\$1\$pn1ABFaI\$vt5cmIjlr6M7Z79Eds2lV0:16821:0:99999:7:::/g' /etc/shadow" $(find package/emortal/ -type f -regex '.*default-settings$')
# git diff ./ >> ../output/t.patch || true
clone_url "
https://github.com/hong0980/build
#https://github.com/sbwml/openwrt_helloworld
https://github.com/xiaorouji/openwrt-passwall-packages
https://github.com/fw876/helloworld
"
clone_dir vernesong/OpenClash luci-app-openclash
clone_dir sbwml/openwrt_helloworld shadowsocks-rust
clone_dir xiaorouji/openwrt-passwall luci-app-passwall
clone_dir xiaorouji/openwrt-passwall2 luci-app-passwall2
clone_dir coolsnowwolf/packages qtbase qttools qBittorrent qBittorrent-static
clone_dir master UnblockNeteaseMusic/luci-app-unblockneteasemusic luci-app-unblockneteasemusic
clone_dir kiddin9/kwrt-packages luci-lib-taskd luci-lib-xterm lua-maxminddb \
luci-app-bypass luci-app-store luci-app-pushbot taskd
[[ "$TARGET_DEVICE" =~ phicomm|newifi|asus ]] || {
_packages "
axel lscpu lsscsi patch diffutils htop lscpu
brcmfmac-firmware-43430-sdio brcmfmac-firmware-43455-sdio kmod-brcmfmac
kmod-brcmutil kmod-mt7601u kmod-mt76x0u kmod-mt76x2u kmod-r8125
kmod-rt2500-usb kmod-rt2800-usb kmod-rtl8187 kmod-rtl8723bs
kmod-rtl8723au kmod-rtl8723bu kmod-rtl8812au-ac kmod-rtl8812au-ct
kmod-rtl8821ae kmod-rtl8821cu kmod-rtl8xxxu kmod-usb-net-asix-ax88179
kmod-usb-net-rtl8150 kmod-usb-net-rtl8152 mt7601u-firmware #rtl8188eu-firmware #kmod-rtl8188eu
rtl8723au-firmware rtl8723bu-firmware rtl8821ae-firmware
luci-app-aria2
luci-app-bypass
#luci-app-cifs-mount
luci-app-commands
luci-app-hd-idle
luci-app-cupsd
luci-app-openclash
luci-app-pushbot
luci-app-softwarecenter
#luci-app-syncdial
#luci-app-transmission
luci-app-usb-printer
luci-app-vssr
luci-app-wol
#luci-app-bandwidthd
luci-app-store
luci-app-log
#luci-app-alist
luci-app-weburl
luci-app-wrtbwmon
luci-theme-material
luci-theme-opentomato
luci-app-pwdHackDeny
luci-app-uhttpd
luci-app-control-webrestriction
luci-app-cowbbonding
"
trv=`awk -F= '/PKG_VERSION:/{print $2}' feeds/packages/net/transmission/Makefile`
[[ $trv ]] && wget -qO feeds/packages/net/transmission/patches/tr$trv.patch \
raw.githubusercontent.com/hong0980/diy/master/files/transmission/tr$trv.patch
cat <<-\EOF >feeds/packages/lang/python/python3/files/python3-package-uuid.mk
define Package/python3-uuid
$(call Package/python3/Default)
TITLE:=Python $(PYTHON3_VERSION) UUID module
DEPENDS:=+python3-light +libuuid
endef
$(eval $(call Py3BasePackage,python3-uuid, \
/usr/lib/python$(PYTHON3_VERSION)/uuid.py \
/usr/lib/python$(PYTHON3_VERSION)/lib-dynload/_uuid.$(PYTHON3_SO_SUFFIX) \
))
EOF
clone_url "
https://github.com/destan19/OpenAppFilter
https://github.com/yaof2/luci-app-ikoolproxy
https://github.com/AlexZhuo/luci-app-bandwidthd
"
rm -rf feeds/*/*/{luci-app-appfilter,open-app-filter}
mwan3=feeds/packages/net/mwan3/files/etc/config/mwan3
grep -q "8.8" $mwan3 && sed -i '/8.8/d' $mwan3
grep -q "rblibtorrent" package/A/qBittorrent/Makefile && \
sed -i 's/+rblibtorrent/+libtorrent-rasterbar/' package/A/qBittorrent/Makefile
[[ "$REPO_BRANCH" =~ 2.*0 ]] && {
sed -i 's/^ping/-- ping/g' package/*/*/*/*/*/bridge.lua
} || {
_packages "luci-app-argon-config"
sed -i "s/argonv3/argon/" feeds/luci/applications/luci-app-argon-config/Makefile
for d in $(find feeds/ package/ -type f -name "index.htm" 2>/dev/null); do
if grep -q "Kernel Version" $d; then
# echo $d
sed -i 's|os.date(.*|os.date("%F %X") .. " " .. translate(os.date("%A")),|' $d
sed -i '/<%+footer%>/i<%-\n\tlocal incdir = util.libpath() .. "/view/admin_status/index/"\n\tif fs.access(incdir) then\n\t\tlocal inc\n\t\tfor inc in fs.dir(incdir) do\n\t\t\tif inc:match("%.htm$") then\n\t\t\t\tinclude("admin_status/index/" .. inc:gsub("%.htm$", ""))\n\t\t\tend\n\t\tend\n\t\end\n-%>\n' $d
# sed -i '/<%+footer%>/i<fieldset class="cbi-section">\n\t<legend><%:天气%></legend>\n\t<table width="100%" cellspacing="10">\n\t\t<tr><td width="10%"><%:本地天气%></td><td > <iframe width="900" height="120" frameborder="0" scrolling="no" hspace="0" src="//i.tianqi.com/?c=code&a=getcode&id=22&py=xiaoshan&icon=1"></iframe>\n\t\t<tr><td width="10%"><%:柯桥天气%></td><td > <iframe width="900" height="120" frameborder="0" scrolling="no" hspace="0" src="//i.tianqi.com/?c=code&a=getcode&id=22&py=keqiaoqv&icon=1"></iframe>\n\t\t<tr><td width="10%"><%:指数%></td><td > <iframe width="400" height="270" frameborder="0" scrolling="no" hspace="0" src="https://i.tianqi.com/?c=code&a=getcode&id=27&py=xiaoshan&icon=1"></iframe><iframe width="400" height="270" frameborder="0" scrolling="no" hspace="0" src="https://i.tianqi.com/?c=code&a=getcode&id=27&py=keqiaoqv&icon=1"></iframe>\n\t</table>\n</fieldset>\n' $d
fi
done
}
# xa=$(_find "package/A/ feeds/luci/applications/" "luci-app-vssr")
# [[ -d $xa ]] && sed -i "/dports/s/1/2/;/ip_data_url/s|'.*'|'https://ispip.clang.cn/all_cn.txt'|" $xa/root/etc/config/vssr
xb=$(_find "package/A/ feeds/luci/applications/" "luci-app-bypass")
[[ -d $xb ]] && sed -i 's/default y/default n/g' $xb/Makefile
#https://github.com/userdocs/qbittorrent-nox-static/releases
xc=$(_find "package/A/ feeds/" "qBittorrent-static")
[[ -d $xc ]] && {
# [[ $qBittorrent_version ]] && sed -i "s/userdocs/hong0980/" $xc/Makefile
sed -i "s/PKG_VERSION:=.*/PKG_VERSION:=${qBittorrent_version:-4.6.5}_v${libtorrent_version:-2.0.10}/" $xc/Makefile
}
xd=$(_find "package/A/ feeds/luci/applications/" "luci-app-turboacc")
[[ -d $xd ]] && sed -i '/hw_flow/s/1/0/;/sfe_flow/s/1/0/;/sfe_bridge/s/1/0/' $xd/root/etc/config/turboacc
xe=$(_find "package/A/ feeds/luci/applications/" "luci-app-ikoolproxy")
[[ -f $xe/luasrc/model/cbi/koolproxy/basic.lua ]] && sed -i \
'/^local.*sys.exec/ s/$/ or 0/g; /^local.*sys.exec/ s/.txt/.txt 2>\/dev\/null/g' $xe/luasrc/model/cbi/koolproxy/basic.lua
xg=$(_find "package/A/ feeds/luci/applications/" "luci-app-pushbot")
[[ -d $xg ]] && {
sed -i "s|-c pushbot|/usr/bin/pushbot/pushbot|" $xg/luasrc/controller/pushbot.lua
sed -i '/start()/a[ "$(uci get pushbot.@pushbot[0].pushbot_enable)" -eq "0" ] && return 0' $xg/root/etc/init.d/pushbot
}
}
case "$TARGET_DEVICE" in
"r4s"|"r2c"|"r2s"|"r1-plus-lts"|"r1-plus")
DEVICE_NAME="$TARGET_DEVICE"
FIRMWARE_TYPE="sysupgrade"
[[ -n $IP ]] && \
sed -i '/n) ipad/s/".*"/"'"$IP"'"/' $config_generate || \
sed -i '/n) ipad/s/".*"/"192.168.2.1"/' $config_generate
_packages "
luci-app-dockerman
luci-app-turboacc
luci-app-qbittorrent
luci-app-passwall2
luci-app-netdata
luci-app-cpufreq
#luci-app-adguardhome
#luci-app-amule
luci-app-deluge
#luci-app-smartdns
#luci-app-adbyby-plus
luci-app-unblockneteasemusic
#htop lscpu lsscsi #nano screen #zstd pv ethtool
"
[[ "${REPO_BRANCH#*-}" =~ ^2 ]] && sed -i '/bridge/d' .config
wget -qO package/base-files/files/bin/bpm git.io/bpm && chmod +x package/base-files/files/bin/bpm
wget -qO package/base-files/files/bin/ansi git.io/ansi && chmod +x package/base-files/files/bin/ansi
_packages "kmod-rt2800-usb kmod-rtl8187 kmod-rtl8812au-ac kmod-rtl8812au-ct kmod-rtl8821ae
kmod-rtl8821cu ethtool kmod-usb-wdm kmod-usb2 kmod-usb-ohci kmod-usb-uhci kmod-mt76x2u kmod-mt76x0u
kmod-gpu-lima luci-app-cpufreq luci-app-pushbot luci-app-wrtbwmon luci-app-vssr"
echo -e "CONFIG_DRIVER_11AC_SUPPORT=y\nCONFIG_DRIVER_11N_SUPPORT=y\nCONFIG_DRIVER_11W_SUPPORT=y" >>.config
[[ $TARGET_DEVICE =~ r1-plus-lts ]] && sed -i "/lan_wan/s/'.*' '.*'/'eth0' 'eth1'/" target/*/rockchip/*/*/*/*/02_network
;;
"newifi-d2")
DEVICE_NAME="Newifi-D2"
FIRMWARE_TYPE="sysupgrade"
[[ -n $IP ]] && \
sed -i '/n) ipad/s/".*"/"'"$IP"'"/' $config_generate || \
sed -i '/n) ipad/s/".*"/"192.168.2.1"/' $config_generate
;;
"phicomm_k2p")
DEVICE_NAME="Phicomm-K2P"
_packages "luci-app-wifischedule"
FIRMWARE_TYPE="sysupgrade"
sed -i '/diskman/d;/autom/d;/ikoolproxy/d;/autos/d' .config
[[ -n $IP ]] && \
sed -i '/n) ipad/s/".*"/"'"$IP"'"/' $config_generate || \
sed -i '/n) ipad/s/".*"/"192.168.1.1"/' $config_generate
;;
"asus_rt-n16")
DEVICE_NAME="Asus-RT-N16"
FIRMWARE_TYPE="n16"
[[ -n $IP ]] && \
sed -i '/n) ipad/s/".*"/"'"$IP"'"/' $config_generate || \
sed -i '/n) ipad/s/".*"/"192.168.2.130"/' $config_generate
;;
"x86_64")
DEVICE_NAME="x86_64"
FIRMWARE_TYPE="squashfs-combined"
[[ -n $IP ]] && \
sed -i '/n) ipad/s/".*"/"'"$IP"'"/' $config_generate || \
sed -i '/n) ipad/s/".*"/"192.168.2.150"/' $config_generate
_packages "
luci-app-adbyby-plus
#luci-app-adguardhome
luci-app-passwall2
#luci-app-amule
luci-app-dockerman
luci-app-netdata
luci-app-poweroff
luci-app-qbittorrent
#luci-app-smartdns
luci-app-ikoolproxy
luci-app-deluge
#luci-app-godproxy
#luci-app-frpc
luci-app-unblockneteasemusic
#AmuleWebUI-Reloaded htop lscpu lsscsi lsusb nano pciutils screen webui-aria2 zstd pv
#subversion-client #unixodbc #git-http
"
# [[ $REPO_BRANCH = "openwrt-18.06-k5.4" ]] && sed -i '/KERNEL_PATCHVER/s/=.*/=5.10/' target/linux/x86/Makefile
wget -qO package/base-files/files/bin/bpm git.io/bpm && chmod +x package/base-files/files/bin/bpm
wget -qO package/base-files/files/bin/ansi git.io/ansi && chmod +x package/base-files/files/bin/ansi
[[ $REPO_BRANCH == master ]] && rm -rf package/kernel/rt*
;;
"armvirt-64-default")
DEVICE_NAME="$TARGET_DEVICE"
FIRMWARE_TYPE="$TARGET_DEVICE"
[[ -n $IP ]] && \
sed -i '/n) ipad/s/".*"/"'"$IP"'"/' $config_generate || \
sed -i '/n) ipad/s/".*"/"192.168.2.110"/' $config_generate
echo "CONFIG_PERL_NOCOMMENT=y" >>.config
sed -i -E '/easymesh/d' .config
sed -i "s/default 160/default $PARTSIZE/" config/Config-images.in
sed -i 's/@arm/@TARGET_armvirt_64/g' $(_find "package/A/ feeds/" "luci-app-cpufreq")/Makefile
;;
esac
[[ "$REPO_BRANCH" =~ 21.02|18.06 ]] && {
# [[ $TARGET_DEVICE =~ ^r ]] && \
# sed -i "s|VERSION.*|VERSION-5.4 = .273|; s|HASH.*|HASH-5.4.273 = 8ba0cfd3faa7222542b30791def49f426d7b50a07217366ead655a5687534743|" include/kernel-5.4
clone_dir immortalwrt/packages nghttp3 ngtcp2 bash
clone_dir openwrt-23.05 immortalwrt/immortalwrt busybox ppp automount openssl \
dnsmasq nftables libnftnl sonfilter opkg fullconenat \
#fstools odhcp6c iptables ipset dropbear usbmode
clone_dir openwrt-23.05 immortalwrt/packages samba4 nginx-util htop pciutils libwebsockets gawk mwan3 \
lua-openssl smartdns bluez curl #miniupnpc miniupnpd
clone_dir openwrt-23.05 immortalwrt/luci luci-app-syncdial luci-app-mwan3
cat <<-\EOF >>package/kernel/linux/modules/netfilter.mk
define KernelPackage/nft-tproxy
SUBMENU:=$(NF_MENU)
TITLE:=Netfilter nf_tables tproxy support
DEPENDS:=+kmod-nft-core +kmod-nf-tproxy +kmod-nf-conntrack
FILES:=$(foreach mod,$(NFT_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko)
AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_TPROXY-m)))
KCONFIG:=$(KCONFIG_NFT_TPROXY)
endef
$(eval $(call KernelPackage,nft-tproxy))
define KernelPackage/nf-tproxy
SUBMENU:=$(NF_MENU)
TITLE:=Netfilter tproxy support
KCONFIG:= $(KCONFIG_NF_TPROXY)
FILES:=$(foreach mod,$(NF_TPROXY-m),$(LINUX_DIR)/net/$(mod).ko)
AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_TPROXY-m)))
endef
$(eval $(call KernelPackage,nf-tproxy))
define KernelPackage/nft-compat
SUBMENU:=$(NF_MENU)
TITLE:=Netfilter nf_tables compat support
DEPENDS:=+kmod-nft-core +kmod-nf-ipt
FILES:=$(foreach mod,$(NFT_COMPAT-m),$(LINUX_DIR)/net/$(mod).ko)
AUTOLOAD:=$(call AutoProbe,$(notdir $(NFT_COMPAT-m)))
KCONFIG:=$(KCONFIG_NFT_COMPAT)
endef
$(eval $(call KernelPackage,nft-compat))
define KernelPackage/ipt-socket
TITLE:=Iptables socket matching support
DEPENDS+=+kmod-nf-socket +kmod-nf-conntrack
KCONFIG:=$(KCONFIG_IPT_SOCKET)
FILES:=$(foreach mod,$(IPT_SOCKET-m),$(LINUX_DIR)/net/$(mod).ko)
AUTOLOAD:=$(call AutoProbe,$(notdir $(IPT_SOCKET-m)))
$(call AddDepends/ipt)
endef
define KernelPackage/ipt-socket/description
Kernel modules for socket matching
endef
$(eval $(call KernelPackage,ipt-socket))
define KernelPackage/nf-socket
SUBMENU:=$(NF_MENU)
TITLE:=Netfilter socket lookup support
KCONFIG:= $(KCONFIG_NF_SOCKET)
FILES:=$(foreach mod,$(NF_SOCKET-m),$(LINUX_DIR)/net/$(mod).ko)
AUTOLOAD:=$(call AutoProbe,$(notdir $(NF_SOCKET-m)))
endef
$(eval $(call KernelPackage,nf-socket))
EOF
curl -sSo include/openssl-module.mk https://raw.githubusercontent.com/immortalwrt/immortalwrt/master/include/openssl-module.mk
}
sed -i \
-e 's|\.\./\.\./luci.mk|$(TOPDIR)/feeds/luci/luci.mk|' \
-e 's?include \.\./\.\./\(lang\|devel\)?include $(TOPDIR)/feeds/packages/\1?' \
-e "s/\(\(^\| \| \)\(PKG_HASH\|PKG_MD5SUM\|PKG_MIRROR_HASH\|HASH\):=\).*/\1skip/" \
package/A/*/Makefile 2>/dev/null
for p in package/A/luci-app*/po feeds/luci/applications/luci-app*/po; do
[[ -L $p/zh_Hans || -L $p/zh-cn ]] || (ln -s zh-cn $p/zh_Hans 2>/dev/null || ln -s zh_Hans $p/zh-cn 2>/dev/null)
done
# mv -f package/A/luci-app* feeds/luci/applications/
[[ "$REPO_BRANCH" =~ master ]] && sed -i '/deluge/d' .config
sed -i '/bridge\|vssr\|deluge/d' .config
echo -e "$(color cy '更新配置....')\c"; BEGIN_TIME=$(date '+%H:%M:%S')
make defconfig 1>/dev/null 2>&1
status
LINUX_VERSION=$(grep 'CONFIG_LINUX.*=y' .config | sed -r 's/CONFIG_LINUX_(.*)=y/\1/' | tr '_' '.')
echo -e "$(color cy 当前机型) $(color cb $SOURCE_NAME-${REPO_BRANCH#*-}-$LINUX_VERSION-${DEVICE_NAME}${VERSION:+-$VERSION})"
sed -i "/IMG_PREFIX:/ {s/=/=$SOURCE_NAME-${REPO_BRANCH#*-}-$LINUX_VERSION-\$(shell TZ=UTC-8 date +%m%d-%H%M)-/}" include/image.mk
# sed -i -E 's/# (CONFIG_.*_COMPRESS_UPX) is not set/\1=y/' .config && make defconfig 1>/dev/null 2>&1
# echo "SSH_ACTIONS=true" >>$GITHUB_ENV #SSH后台
# echo "UPLOAD_PACKAGES=false" >>$GITHUB_ENV
# echo "UPLOAD_SYSUPGRADE=false" >>$GITHUB_ENV
echo "UPLOAD_BIN_DIR=false" >>$GITHUB_ENV
# echo "UPLOAD_FIRMWARE=false" >>$GITHUB_ENV
echo "UPLOAD_COWTRANSFER=false" >>$GITHUB_ENV
echo "UPLOAD_WETRANSFER=false" >>$GITHUB_ENV
echo "CLEAN=false" >>$GITHUB_ENV
echo "FIRMWARE_TYPE=$FIRMWARE_TYPE" >>$GITHUB_ENV
echo "VERSION=$VERSION" >>$GITHUB_ENV
echo -e "\e[1;35m脚本运行完成!\e[0m"