generated from P3TERX/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diy-part1.sh
executable file
·91 lines (74 loc) · 3.3 KB
/
diy-part1.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
#!/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:/P3TERX/Actions-OpenWrt
# File name: diy-part1.sh
# Description: OpenWrt DIY script part 1 (Before Update feeds)
#
# Uncomment a feed source
#sed -i 's/^#\(.*helloworld\)/\1/' feeds.conf.default
# Add a feed source
#echo 'src-git helloworld https:/fw876/helloworld' >>feeds.conf.default
#echo 'src-git passwall https:/xiaorouji/openwrt-passwall' >>feeds.conf.default
# sed -i 's/Os/O3/g' include/target.mk
# 使用 O2 级别的优化
sed -i 's/Os/O3/g' include/target.mk
# sed -i 's/KERNEL_PATCHVER:=6.1/KERNEL_PATCHVER:=5.15/g' target/linux/x86/Makefile
# sed -i 's/KERNEL_PATCHVER:=6.1/KERNEL_PATCHVER:=5.4/g' target/linux/x86/Makefile
# sed -i 's/KERNEL_TESTING_PATCHVER:=6.6/KERNEL_TESTING_PATCHVER:=6.1/g' target/linux/x86/Makefile
# 交换 LAN/WAN 口
sed -i 's,"eth1" "eth0","eth0" "eth1",g' target/linux/rockchip/armv8/base-files/etc/board.d/02_network
sed -i "s,'eth1' 'eth0','eth0' 'eth1',g" target/linux/rockchip/armv8/base-files/etc/board.d/02_network
# 为版本号追加编译日期
date_version=$(date +"%Y.%m.%d")
orig_version=$(cat "package/lean/default-settings/files/zzz-default-settings" | grep DISTRIB_REVISION= | awk -F "'" '{print $2}')
sed -i "s/${orig_version}/${orig_version} [${date_version}]/g" package/lean/default-settings/files/zzz-default-settings
# 修改本地时间格式
sed -i 's/os.date()/os.date("%a %Y-%m-%d %H:%M:%S")/g' package/lean/autocore/files/*/index.htm
# 添加 xdp-sockets-diag 内核模块
echo '
define KernelPackage/xdp-sockets-diag
SUBMENU:=$(NETWORK_SUPPORT_MENU)
TITLE:=PF_XDP sockets monitoring interface support for ss utility
KCONFIG:= \
CONFIG_XDP_SOCKETS=y \
CONFIG_XDP_SOCKETS_DIAG
FILES:=$(LINUX_DIR)/net/xdp/xsk_diag.ko
AUTOLOAD:=$(call AutoLoad,31,xsk_diag)
endef
define KernelPackage/xdp-sockets-diag/description
Support for PF_XDP sockets monitoring interface used by the ss tool
endef
$(eval $(call KernelPackage,xdp-sockets-diag))
' >> package/kernel/linux/modules/netsupport.mk
# Git稀疏克隆,只克隆指定目录到本地
function git_sparse_clone() {
branch="$1" repourl="$2" && shift 2
git clone --depth=1 -b $branch --single-branch --filter=blob:none --sparse $repourl
repodir=$(echo $repourl | awk -F '/' '{print $(NF)}')
cd $repodir && git sparse-checkout set $@
mv -f $@ ../package
cd .. && rm -rf $repodir
}
# 定义一个函数,用来克隆指定的仓库和分支
function clone_repo() {
# 参数1是仓库地址,参数2是分支名,参数3是目标目录
repo_url=$1
branch_name=$2
target_dir=$3
# 克隆仓库到目标目录,并指定分支名和深度为1
git clone -b $branch_name --depth 1 $repo_url $target_dir
}
# 获取 immortalwrt 仓库
immortalwrt_pkg_repo="https:/immortalwrt/packages.git"
clone_repo $immortalwrt_pkg_repo master immortalwrt_pkg
cp -rf immortalwrt_pkg/net/dae packages
# 添加额外插件
git clone --depth=1 https:/kongfl888/luci-app-adguardhome package/luci-app-adguardhome
git clone --depth=1 https:/Jason6111/luci-app-netdata package/luci-app-netdata
# 科学上网插件
git_sparse_clone master https:/vernesong/OpenClash luci-app-openclash