generated from P3TERX/Actions-OpenWrt
-
Notifications
You must be signed in to change notification settings - Fork 7
/
diy-part2-router.sh
executable file
·159 lines (144 loc) · 4.96 KB
/
diy-part2-router.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
#!/bin/bash
#
# https://github.com/P3TERX/Actions-OpenWrt
# File name: diy-part2.sh
# Description: OpenWrt DIY script part 2 (After Update feeds)
#
# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
function config_del(){
yes="CONFIG_$1=y"
no="# CONFIG_$1 is not set"
sed -i "s/$yes/$no/" .config
}
function config_add(){
yes="CONFIG_$1=y"
no="# CONFIG_$1 is not set"
sed -i "s/${no}/${yes}/" .config
if ! grep -q "$yes" .config; then
echo "$yes" >> .config
fi
}
function config_package_del(){
package="PACKAGE_$1"
config_del $package
}
function config_package_add(){
package="PACKAGE_$1"
config_add $package
}
function drop_package(){
if [ "$1" != "golang" ];then
# feeds/base -> package
find package/ -follow -name $1 -not -path "package/custom/*" | xargs -rt rm -rf
find feeds/ -follow -name $1 -not -path "feeds/base/custom/*" | xargs -rt rm -rf
fi
}
function clean_packages(){
path=$1
dir=$(ls -l ${path} | awk '/^d/ {print $NF}')
for item in ${dir}
do
drop_package ${item}
done
}
# Add the default password for the 'root' user(Change the empty password to 'password')
sed -i 's/root:::0:99999:7:::/root:$1$V4UetPzk$CYXluq4wUazHjmCDBCqXF.::0:99999:7:::/g' package/base-files/files/etc/shadow
# Modify default IP
sed -i 's/192.168.1.1/192.168.3.1/g' package/base-files/files/bin/config_generate
# Modify default theme
sed -i 's/luci-theme-bootstrap/luci-theme-argon/g' feeds/luci/collections/luci/Makefile
# 删除
# Sound Support
config_package_del kmod-sound-core
config_package_del kmod-ac97
config_package_del kmod-sound-hda-core
config_package_del kmod-sound-hda-codec-hdmi
config_package_del kmod-sound-hda-codec-realtek
config_package_del kmod-sound-hda-codec-via
config_package_del kmod-sound-hda-intel
config_package_del kmod-sound-i8x0
config_package_del kmod-sound-mpu401
config_package_del kmod-sound-via82xx
config_package_del kmod-usb-audio
# 新增
# luci
config_package_add luci
config_package_add default-settings-chn
# bbr
config_package_add kmod-tcp-bbr
# coremark cpu 跑分
config_package_add coremark
# autocore + lm-sensors-detect: cpu 频率、温度
config_package_add autocore
config_package_add lm-sensors-detect
# nano 替代 vim
config_package_add nano
# upnp
config_package_add luci-app-upnp
# tty 终端
config_package_add luci-app-ttyd
# docker
config_package_add luci-app-dockerman
# kms
config_package_add luci-app-vlmcsd
# usb 2.0 3.0 支持
config_package_add kmod-usb2
config_package_add kmod-usb3
# usb 网络支持
config_package_add usbmuxd
config_package_add usbutils
config_package_add usb-modeswitch
config_package_add kmod-usb-serial
config_package_add kmod-usb-serial-option
config_package_add kmod-usb-net-rndis
config_package_add kmod-usb-net-ipheth
# 第三方软件包
mkdir -p package/custom
git clone --depth 1 https://github.com/217heidai/OpenWrt-Packages.git package/custom
clean_packages package/custom
# golang
rm -rf feeds/packages/lang/golang
mv package/custom/golang feeds/packages/lang/
# argon 主题
config_package_add luci-theme-argon
## passwall
config_package_add luci-app-passwall
config_package_add luci-app-passwall_Nftables_Transparent_Proxy
config_package_del luci-app-passwall_Iptables_Transparent_Proxy
config_package_del luci-app-passwall_INCLUDE_Shadowsocks_Libev_Client
config_package_del luci-app-passwall_INCLUDE_Shadowsocks_Libev_Server
config_package_del luci-app-passwall_INCLUDE_Shadowsocks_Rust_Client
config_package_del luci-app-passwall_INCLUDE_Shadowsocks_Rust_Server
config_package_del luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Client
config_package_del luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Server
## 定时任务。重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、MWAN3负载均衡检测重连、自定义脚本等10多个功能
config_package_add luci-app-autotimeset
config_package_add luci-lib-ipkg
## 分区扩容。一键自动格式化分区、扩容、自动挂载插件,专为OPENWRT设计,简化OPENWRT在分区挂载上烦锁的操作
config_package_add luci-app-partexp
## iStore 应用市场
config_package_add luci-app-store
## 4G/5G 支持:FM350-GL USB RNDIS
### Siriling/5G-Modem-Support
config_package_add luci-app-modem
config_package_add luci-app-sms-tool-js
### luci-app-modemband
config_package_add luci-app-modemband
### luci-app-3ginfo-lite
config_package_add luci-app-3ginfo-lite
# 镜像生成
# 修改分区大小
sed -i "/CONFIG_TARGET_KERNEL_PARTSIZE/d" .config
echo "CONFIG_TARGET_KERNEL_PARTSIZE=32" >> .config
sed -i "/CONFIG_TARGET_ROOTFS_PARTSIZE/d" .config
echo "CONFIG_TARGET_ROOTFS_PARTSIZE=2048" >> .config
# 调整 GRUB_TIMEOUT
sed -i "s/CONFIG_GRUB_TIMEOUT=\"3\"/CONFIG_GRUB_TIMEOUT=\"1\"/" .config
## 不生成 EXT4 硬盘格式镜像
config_del TARGET_ROOTFS_EXT4FS
## 不生成非 EFI 镜像
config_del GRUB_IMAGES