forked from breeze303/openwrt-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diy-script.sh
166 lines (130 loc) · 6.78 KB
/
diy-script.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
#!/bin/bash
# 修改默认IP
#sed -i 's/192.168.10.1/10.0.0.1/g' package/base-files/files/bin/config_generate
sed -i "s/192\.168\.[0-9]*\.[0-9]*/192.168.10.1/g" package/base-files/files/bin/config_generate
# 更改默认 Shell 为 zsh
#sed -i 's/\/bin\/ash/\/usr\/bin\/zsh/g' package/base-files/files/etc/passwd
# TTYD 免登录
sed -i 's|/bin/login|/bin/login -f root|g' feeds/packages/utils/ttyd/files/ttyd.config
# 移除要替换的包
rm -rf feeds/packages/net/mosdns
rm -rf feeds/packages/net/msd_lite
rm -rf feeds/packages/net/smartdns
rm -rf feeds/luci/themes/luci-theme-argon
rm -rf feeds/luci/themes/luci-theme-netgear
rm -rf feeds/luci/applications/luci-app-mosdns
rm -rf feeds/luci/applications/luci-app-netdata
rm -rf feeds/luci/applications/luci-app-serverchan
rm -rf feeds/luci/applications/luci-app-alist
# 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
}
git_sparse_clone main https://github.com/Lienol/openwrt-package luci-app-filebrowser luci-app-ssr-mudb-server
#安装和更新软件包
UPDATE_PACKAGE() {
local PKG_NAME=$1
local PKG_REPO=$2
local PKG_BRANCH=$3
local PKG_SPECIAL=$4
local REPO_NAME=$(echo $PKG_REPO | cut -d '/' -f 2)
rm -rf $(find ../feeds/luci/ ../feeds/packages/ -maxdepth 3 -type d -iname "*$PKG_NAME*" -prune)
git clone --depth=1 --single-branch --branch $PKG_BRANCH "https://github.com/$PKG_REPO.git"
if [[ $PKG_SPECIAL == "pkg" ]]; then
cp -rf $(find ./$REPO_NAME/*/ -maxdepth 3 -type d -iname "*$PKG_NAME*" -prune) ./
rm -rf ./$REPO_NAME/
elif [[ $PKG_SPECIAL == "name" ]]; then
mv -f $REPO_NAME $PKG_NAME
fi
}
#UPDATE_PACKAGE "包名" "项目地址" "项目分支" "pkg/name,可选,pkg为从大杂烩中单独提取包名插件;name为重命名为包名" "对处理后的目录重命名"
UPDATE_PACKAGE "argon" "jerrykuku/luci-theme-argon" "master"
UPDATE_PACKAGE "design" "0x676e67/luci-theme-design" "js"
UPDATE_PACKAGE "kucat" "sirpdboy/luci-theme-kucat" "js"
UPDATE_PACKAGE "luci-app-unblockneteasemusic" "YunHair/luci-app-unblockneteasemusic" "js"
#UPDATE_PACKAGE "openclash" "vernesong/OpenClash" "dev" "pkg"
#UPDATE_PACKAGE "passwall" "xiaorouji/openwrt-passwall" "main"
#UPDATE_PACKAGE "ssr-plus" "fw876/helloworld" "master"
#UPDATE_PACKAGE "luci-app-unblockneteasemusic" "YunHair/luci-app-unblockneteasemusic" "js"
UPDATE_PACKAGE "advancedplus" "YunHair/luci-app-advancedplus" "main"
UPDATE_PACKAGE "gecoosac" "lwb1978/openwrt-gecoosac" "main"
UPDATE_PACKAGE "luci-app-tailscale" "asvow/luci-app-tailscale" "main"
UPDATE_PACKAGE "luci-app-multi-frpc" "YunHair/luci-app-multifrpc" "main"
UPDATE_PACKAGE "luci-app-wolplus" "YunHair/luci-app-wolplus" "main"
UPDATE_PACKAGE "luci-app-mosdns" "sbwml/luci-app-mosdns" "v5"
UPDATE_PACKAGE "luci-app-onliner" "YunHair/luci-app-onliner" "main"
#natmap或lucky
#UPDATE_PACKAGE "luci-app-natmapt" "muink/luci-app-natmapt" "master"
#UPDATE_PACKAGE "natmapt" "muink/openwrt-natmapt" "master"
UPDATE_PACKAGE "lucky" "gdy666/luci-app-lucky" "main"
#科学
#UPDATE_PACKAGE "homeproxy" "muink/luci-app-homeproxy" "master"
UPDATE_PACKAGE "homeproxy" "VIKINGYFY/homeproxy" "main"
#UPDATE_PACKAGE "mihomo" "morytyann/OpenWrt-mihomo" "main" "pkg"
#LiBwrt编译时需要
if [[ $WRT_REPO == *"LiBwrt"* ]]; then
UPDATE_PACKAGE "qmi-wwan" "immortalwrt/wwan-packages" "master" "pkg"
fi
#更新软件包版本
UPDATE_VERSION() {
local PKG_NAME=$1
local PKG_MARK=${2:-not}
local PKG_FILES=$(find ./ ../feeds/packages/ -maxdepth 3 -type f -wholename "*/$PKG_NAME/Makefile")
echo " "
if [ -z "$PKG_FILES" ]; then
echo "$PKG_NAME not found!"
return
fi
echo "$PKG_NAME version update has started!"
for PKG_FILE in $PKG_FILES; do
local PKG_REPO=$(grep -Pho 'PKG_SOURCE_URL:=https://.*github.com/\K[^/]+/[^/]+(?=.*)' $PKG_FILE | head -n 1)
local PKG_VER=$(curl -sL "https://api.github.com/repos/$PKG_REPO/releases" | jq -r "map(select(.prerelease|$PKG_MARK)) | first | .tag_name")
local NEW_VER=$(echo $PKG_VER | sed "s/.*v//g; s/_/./g")
local NEW_HASH=$(curl -sL "https://codeload.github.com/$PKG_REPO/tar.gz/$PKG_VER" | sha256sum | cut -b -64)
local OLD_VER=$(grep -Po "PKG_VERSION:=\K.*" "$PKG_FILE")
echo "$OLD_VER $PKG_VER $NEW_VER $NEW_HASH"
if [[ $NEW_VER =~ ^[0-9].* ]] && dpkg --compare-versions "$OLD_VER" lt "$NEW_VER"; then
sed -i "s/PKG_VERSION:=.*/PKG_VERSION:=$NEW_VER/g" "$PKG_FILE"
sed -i "s/PKG_HASH:=.*/PKG_HASH:=$NEW_HASH/g" "$PKG_FILE"
echo "$PKG_FILE version has been updated!"
else
echo "$PKG_FILE version is already the latest!"
fi
done
}
#UPDATE_VERSION "软件包名" "测试版,true,可选,默认为否"
UPDATE_VERSION "sing-box" "true"
UPDATE_VERSION "tailscale"
# x86 型号只显示 CPU 型号
#sed -i 's/${g}.*/${a}${b}${c}${d}${e}${f}${hydrid}/g' package/lean/autocore/files/x86/autocore
# 修改本地时间格式
sed -i 's/os.date()/os.date("%a %Y-%m-%d %H:%M:%S")/g' package/lean/autocore/files/*/index.htm
# 修改版本为编译日期
date_version=$(date +"%y.%m.%d_%H%M%S")
orig_version=$(cat "package/lean/default-settings/files/zzz-default-settings" | grep DISTRIB_REVISION= | awk -F "'" '{print $2}')
sed -i "s/${orig_version}/R${date_version} by Haiibo/g" package/lean/default-settings/files/zzz-default-settings
# 修复 hostapd 报错
cp -f $GITHUB_WORKSPACE/scripts/011-fix-mbo-modules-build.patch package/network/services/hostapd/patches/011-fix-mbo-modules-build.patch
# 修复 armv8 设备 xfsprogs 报错
sed -i 's/TARGET_CFLAGS.*/TARGET_CFLAGS += -DHAVE_MAP_SYNC -D_LARGEFILE64_SOURCE/g' feeds/packages/utils/xfsprogs/Makefile
# 修改 Makefile
find package/*/ -maxdepth 2 -path "*/Makefile" | xargs -i sed -i 's/..\/..\/luci.mk/$(TOPDIR)\/feeds\/luci\/luci.mk/g' {}
find package/*/ -maxdepth 2 -path "*/Makefile" | xargs -i sed -i 's/..\/..\/lang\/golang\/golang-package.mk/$(TOPDIR)\/feeds\/packages\/lang\/golang\/golang-package.mk/g' {}
find package/*/ -maxdepth 2 -path "*/Makefile" | xargs -i sed -i 's/PKG_SOURCE_URL:=@GHREPO/PKG_SOURCE_URL:=https:\/\/github.com/g' {}
find package/*/ -maxdepth 2 -path "*/Makefile" | xargs -i sed -i 's/PKG_SOURCE_URL:=@GHCODELOAD/PKG_SOURCE_URL:=https:\/\/codeload.github.com/g' {}
# 取消主题默认设置
#find package/luci-theme-*/* -type f -name '*luci-theme-*' -print -exec sed -i '/set luci.main.mediaurlbase/d' {} \;
#高通平台锁定512M内存
if [[ $FIRMWARE_TAG == *"IPQ"* ]]; then
echo "CONFIG_IPQ_MEM_PROFILE_1024=n" >> ./.config
echo "CONFIG_IPQ_MEM_PROFILE_512=y" >> ./.config
echo "CONFIG_ATH11K_MEM_PROFILE_1G=n" >> ./.config
echo "CONFIG_ATH11K_MEM_PROFILE_512M=y" >> ./.config
fi
./scripts/feeds update -a
./scripts/feeds install -a