-
Notifications
You must be signed in to change notification settings - Fork 9
/
fix.sh
316 lines (295 loc) · 10.2 KB
/
fix.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
#!/bin/sh
echo
echo
echo 1.去除登录时订阅提示
echo 2.修复PVE6.x 没有购买订阅,无法更新问题
echo 3.添加cpu温度/硬盘温度显示(只有一块硬盘)
echo 4.添加cpu温度/硬盘温度显示(有两块硬盘)
echo 5.添加硬盘温度插件自启动
echo
read -p "请选择:" M
echo
echo
#选择
if [ "$M" = "1" ]
then
cd /usr/share/javascript/proxmox-widget-toolkit
echo 备份proxmoxlib.js
cp proxmoxlib.js proxmoxlib.js.backup
echo 修改proxmoxlib.js
sed -i.bak "s/data.status !== 'Active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
echo 重启服务
systemctl restart pveproxy.service
echo 修改完毕
elif [ "$M" = "2" ]
then
#脚本提示
echo 正在修复Proxmox VE更新问题
#移动到脚本目录
cd /etc/apt
#备份文件
echo 正在备份文件
cp sources.list sources.backup.list
#删除文件
echo 正在备份文件
rm -rf sources.list
#下载修复文件
echo 正在下载新文件
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/sources.list
#设置权限
chmod -R 0755 sources.list
#延迟运行
ping 127.0.0.1 -c 2 > /dev/null
#空行
echo
#移动到脚本目录
cd /etc/apt/sources.list.d
#备份文件
rm -rf pve-enterprise.list
#下载修复文件
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/pve-enterprise.list
#设置权限
chmod -R 0755 pve-enterprise.list
#延迟运行
ping 127.0.0.1 -c 2 > /dev/null
#空行
echo 已修复完成升级一下试试吧
elif [ "$M" = "3" ]
then
#pve添加cpu温度显示
#----------------------------------------------------------------------------------
apt update
apt-get install lm-sensors hddtemp
grep -q "thermalstate" /usr/share/perl5/PVE/API2/Nodes.pm
if [ $? -eq 0 ]; then
echo thermalstate_Api已存在无需更新
else
sed -i.bak '/res->{ksm} = /i\ $res->{thermalstate} = `sensors`;' /usr/share/perl5/PVE/API2/Nodes.pm
echo 文件已更新
fi
grep -q "hddtemp" /usr/share/perl5/PVE/API2/Nodes.pm
if [ $? -eq 0 ]; then
echo hddtemp_Api已存在无需更新
else
sed -i.bak "/res->{ksm} = /i\ my @hddtemp = ('nc localhost 7634');" /usr/share/perl5/PVE/API2/Nodes.pm
sed -i.bak '/res->{ksm} = /i\ $res->{hddstat} = `@hddtemp`;' /usr/share/perl5/PVE/API2/Nodes.pm
echo 文件已更新
fi
hddtemp -d /dev/sd?
cp /usr/share/pve-manager/js/pvemanagerlib.js /usr/share/pve-manager/js/pvemanagerlib.js.backup
grep -q "minHeight: 340" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo 无需修改高度
else
sed -i 's/minHeight: 320,/minHeight: 340,/' /usr/share/pve-manager/js/pvemanagerlib.js
echo 高度已更新
fi
#判断JS文件是否存在
#!/bin/sh
cpucores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'|awk '{print int($0)}'`
if [ "$cpucores" = 1 ]
then
grep -q "CPU Thermal State" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo CPU为单核
echo CPU温度代码已存在无需更新
else
rm -rf CPU_Thermal_State
ping 127.0.0.1 -c 1 > /dev/null
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/CPU_Thermal_State
chmod -R 0755 CPU_Thermal_State
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i.bak '/pveversion/r CPU_Thermal_State' /usr/share/pve-manager/js/pvemanagerlib.js
echo cpu单核文件已更新
echo 正在重启完毕
hddtemp /dev/sd?
systemctl restart pveproxy
fi
elif [ "$cpucores" = 2 ]
then
#双核cpu写入代码判断
grep -q "CPU Thermal State" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo CPU为双核
echo CPU温度代码已存在无需更新
else
rm -rf CPU_Thermal_State2
ping 127.0.0.1 -c 1 > /dev/null
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/CPU_Thermal_State2
chmod -R 0755 CPU_Thermal_State2
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i.bak '/pveversion/r CPU_Thermal_State2' /usr/share/pve-manager/js/pvemanagerlib.js
echo cpu双核文件已更新
echo 正在重启完毕
hddtemp /dev/sd?
systemctl restart pveproxy
fi
elif [ "$cpucores" = 4 ]
then
grep -q "CPU Thermal State" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo CPU为四核
echo CPU温度代码已存在无需更新
else
rm -rf CPU_Thermal_State4
ping 127.0.0.1 -c 1 > /dev/null
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/CPU_Thermal_State4
chmod -R 0755 CPU_Thermal_State4
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i.bak '/pveversion/r CPU_Thermal_State4' /usr/share/pve-manager/js/pvemanagerlib.js
echo cpu四核文件已更新
echo 正在重启完毕
hddtemp /dev/sd?
systemctl restart pveproxy
fi
else
echo 您的cpu不在支持范围请联系作者
fi
elif [ "$M" = "4" ]
then
#pve添加cpu温度显示2
#----------------------------------------------------------------------------------
apt update
apt-get install lm-sensors hddtemp
grep -q "thermalstate" /usr/share/perl5/PVE/API2/Nodes.pm
if [ $? -eq 0 ]; then
echo thermalstate_Api已存在无需更新
else
sed -i.bak '/res->{ksm} = /i\ $res->{thermalstate} = `sensors`;' /usr/share/perl5/PVE/API2/Nodes.pm
echo 文件已更新
fi
grep -q "hddtemp" /usr/share/perl5/PVE/API2/Nodes.pm
if [ $? -eq 0 ]; then
echo hddtemp_Api已存在无需更新
else
sed -i.bak "/res->{ksm} = /i\ my @hddtemp = ('nc localhost 7634');" /usr/share/perl5/PVE/API2/Nodes.pm
sed -i.bak '/res->{ksm} = /i\ $res->{hddstat} = `@hddtemp`;' /usr/share/perl5/PVE/API2/Nodes.pm
echo 文件已更新
fi
hddtemp -d /dev/sd?
cp /usr/share/pve-manager/js/pvemanagerlib.js /usr/share/pve-manager/js/pvemanagerlib.js.backup
grep -q "minHeight: 340" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo 无需修改高度
else
sed -i 's/minHeight: 320,/minHeight: 340,/' /usr/share/pve-manager/js/pvemanagerlib.js
echo 高度已更新
fi
#判断JS文件是否存在
#!/bin/sh
cpucores=`cat /proc/cpuinfo | grep "cpu cores" | uniq | awk -F: '{print $2}'|awk '{print int($0)}'`
if [ "$cpucores" = 1 ]
then
grep -q "CPU Thermal State" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo CPU为单核
echo CPU温度代码已存在无需更新
else
rm -rf 2CPU_Thermal_State
ping 127.0.0.1 -c 1 > /dev/null
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/2CPU_Thermal_State
chmod -R 0755 2CPU_Thermal_State
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i.bak '/pveversion/r 2CPU_Thermal_State' /usr/share/pve-manager/js/pvemanagerlib.js
echo cpu单核文件已更新
echo 正在重启完毕
hddtemp /dev/sd?
systemctl restart pveproxy
fi
elif [ "$cpucores" = 2 ]
then
#双核cpu写入代码判断
grep -q "CPU Thermal State" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo CPU为双核
echo CPU温度代码已存在无需更新
else
rm -rf 2CPU_Thermal_State2
ping 127.0.0.1 -c 1 > /dev/null
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/2CPU_Thermal_State2
chmod -R 0755 2CPU_Thermal_State2
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i.bak '/pveversion/r 2CPU_Thermal_State2' /usr/share/pve-manager/js/pvemanagerlib.js
echo cpu双核文件已更新
echo 正在重启完毕
hddtemp /dev/sd?
systemctl restart pveproxy
fi
elif [ "$cpucores" = 4 ]
then
grep -q "CPU Thermal State" /usr/share/pve-manager/js/pvemanagerlib.js
if [ $? -eq 0 ]; then
echo CPU为四核
echo CPU温度代码已存在无需更新
else
rm -rf 2CPU_Thermal_State4
ping 127.0.0.1 -c 1 > /dev/null
wget -q --no-check-certificate https://raw.githubusercontent.com/pkpkgtr1/PVE-Fix/master/update/2CPU_Thermal_State4
chmod -R 0755 2CPU_Thermal_State4
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i -e '/pveversion/{n;d}' /usr/share/pve-manager/js/pvemanagerlib.js
ping 127.0.0.1 -c 1 > /dev/null
sed -i.bak '/pveversion/r 2CPU_Thermal_State4' /usr/share/pve-manager/js/pvemanagerlib.js
echo cpu四核文件已更新
echo 正在重启完毕
hddtemp /dev/sd?
systemctl restart pveproxy
fi
else
echo 您的cpu不在支持范围请联系作者
fi
elif [ "$M" = "5" ]
then
#脚本提示
echo 已创建开机启动
cat > /etc/systemd/system/rc-local.service <<EOF
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
EOF
cat > /etc/rc.local <<EOF
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
hddtemp -d /dev/sd?
exit 0
EOF
chmod +x /etc/rc.local&systemctl enable rc-local&systemctl start rc-local.service
#-----------------------------------------------------------------------------------
else
echo 请输入正确的序号
fi