generated from LemonCrab666/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdiy-part2.sh
executable file
·130 lines (112 loc) · 4.97 KB
/
diy-part2.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
#!/bin/bash
#
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
# https://github.com/P3TERX/Actions-OpenWrt
# File name: diy-part2.sh
# Description: OpenWrt DIY script part 2 (After Update feeds)
#
# 更改默认IP
#sed -i 's/192.168.1.1/192.168.50.5/g' package/base-files/files/bin/config_generate
#添加软件包
#OpenClash
rm -rf feeds/luci/applications/luci-app-openclash
git clone -b master --single-branch --filter=blob:none https://github.com/vernesong/OpenClash.git feeds/luci/applications/luci-app-openclash
#AdguardHome
git clone https://github.com/rufengsuixing/luci-app-adguardhome package/luci-app-adguardhome
#Mihomo
git clone -b main --single-branch --filter=blob:none https://github.com/morytyann/OpenWrt-mihomo
mv OpenWrt-mihomo/luci-app-mihomo package/
mv OpenWrt-mihomo/mihomo package/
#添加qosmate
#git clone https://github.com/hudra0/qosmate.git package/qosmate
#git clone https://github.com/LemonCrab666/luci-app-qosmate.git package/luci-app-qosmate
#修改nginx默认http
mkdir -p files/etc/config
cat <<EOF > files/etc/config/nginx
config main global
option uci_enable 'true'
config server '_lan'
list listen '80 default_server'
list listen '[::]:80 default_server'
option server_name '_lan'
#list include 'restrict_locally'
list include 'conf.d/*.locations'
EOF
chmod 0600 files/etc/config/nginx
#修改sysguarde备份列表
mkdir -p files/etc
cat <<EOF > files/etc/sysupgrade.conf
## This file contains files and directories that should
## be preserved during an upgrade.
# /etc/example.conf
# /etc/openvpn/
/etc/collectd/
/www/luci-static/argon/background/
/usr/share/wechatpush/api/OpenWrt.jpg
EOF
chmod 0644 files/etc/sysupgrade.conf
#将clash内核、TUN内核、Meta内核编译进目录
#mkdir -p files/etc/openclash/core
#Dev内核
#curl -L https://raw.githubusercontent.com/vernesong/OpenClash/core/master/dev/clash-linux-amd64.tar.gz | tar -xz -C /tmp
#mv /tmp/clash files/etc/openclash/core/clash
#chmod 0755 files/etc/openclash/core/clash
#tun内核
#curl -L https://raw.githubusercontent.com/vernesong/OpenClash/core/master/premium/clash-linux-amd64-2023.08.17-13-gdcc8d87.gz | gunzip -c > /tmp/clash_tun
#mv /tmp/clash_tun files/etc/openclash/core/clash_tun
#chmod 0755 files/etc/openclash/core/clash_tun
#meta内核
#curl -L https://raw.githubusercontent.com/vernesong/OpenClash/core/master/meta/clash-linux-amd64.tar.gz | tar -xz -C /tmp
#mv /tmp/clash files/etc/openclash/core/clash_meta
#chmod 0755 files/etc/openclash/core/clash_meta
#将AdGuardHome核心文件编译进目录
#curl -s https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest \
#| grep "browser_download_url.*AdGuardHome_linux_amd64.tar.gz" \
#| cut -d : -f 2,3 \
#| tr -d \" \
#| xargs curl -L -o /tmp/AdGuardHome_linux_amd64.tar.gz && \
#tar -xzvf /tmp/AdGuardHome_linux_amd64.tar.gz -C /tmp/ --strip-components=1 && \
#mkdir -p files/usr/bin/AdGuardHome && \
#mv /tmp/AdGuardHome/AdGuardHome files/usr/bin/AdGuardHome/
#chmod 0755 files/usr/bin/AdGuardHome/AdGuardHome
# 修改固件MD5值
# 生成VerMagic文件
echo "10d7a0d386bdad3f3ac1aef05275283f" > vermagic
# 检查VerMagic文件是否生成成功
if [ ! -f "vermagic" ]; then
echo "VerMagic文件生成失败!"
exit 1
fi
# 修改include/kernel-defaults.mk
# 设置变量
pattern="grep '=[ym]' \$(LINUX_DIR)/.config.set | LC_ALL=C sort | \$(MKHASH) md5 > \$(LINUX_DIR)/.vermagic"
replacement="cp \$(TOPDIR)/vermagic \$(LINUX_DIR)/.vermagic"
# 对pattern中的特殊字符进行转义处理
escaped_pattern=$(printf '%s\n' "$pattern" | sed -e 's/[][\/$*.^|[]/\\&/g')
# 使用sed命令替换整段语句
sed -i "s|$escaped_pattern|$replacement|g" include/kernel-defaults.mk
# 检查替换是否成功
if [ $? -ne 0 ]; then
echo "include/kernel-defaults.mk 替换失败!"
exit 1
fi
# 修改package/kernel/linux/Makefile
sed -i 's/STAMP_BUILT:=$(STAMP_BUILT)_$(shell $(SCRIPT_DIR)\/kconfig.pl $(LINUX_DIR)\/.config | $(MKHASH) md5)/STAMP_BUILT:=$(STAMP_BUILT)_$(shell cat $(LINUX_DIR)\/.vermagic)/g' package/kernel/linux/Makefile
# 检查替换是否成功
if [ $? -ne 0 ]; then
echo "package/kernel/linux/Makefile 替换失败!"
exit 1
fi
# 输出成功信息
echo "替换成功!"
#将nlbwmon从服务目录移动到菜单栏
#sed -i -e '/"path": "admin\/services\/nlbw\/display"/d' -e 's/services\///g' -e 's/"type": "alias"/"type": "firstchild"/' package/feeds/luci/luci-app-nlbwmon/root/usr/share/luci/menu.d/luci-app-nlbwmon.json
#sed -i 's|admin/services/nlbw/backup|admin/nlbw/backup|g' package/feeds/luci/luci-app-nlbwmon/htdocs/luci-static/resources/view/nlbw/config.js
#由于内核参数 net.core.rmem_max 的限制,缓冲区大小被限制为 212992 字节,永久设置 Netlink 接收缓冲区大小为 524288 字节。
#mkdir -p files/etc
#echo "# Defaults are configured in /etc/sysctl.d/* and can be customized in this file" > files/etc/sysctl.conf
#echo "net.core.rmem_max=524288" >> files/etc/sysctl.conf