forked from mofeng-git/One-KVM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·84 lines (71 loc) · 3.71 KB
/
install.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
PYVER=$(python3 -V)
ARCH=$(uname -m)
CURRENTWD=$PWD
echo $PYVER
echo $ARCH
update-alternative(){
counter=2
for i in {1..9}
do
bindir=$(which python3.$i)
if [[ $bindir == *"bin"* ]]; then
echo $i $bindir
update-alternatives --install /usr/bin/python3 python3 $bindir $counter
let counter++
fi
done
update-alternatives --install /usr/bin/python3 python3 $(which python3.10) 1
update-alternatives --set python3 $(which python3.10)
}
if [[ "$PYVER" != *"3.10"* && $(which python3.10) != *"python"* ]]; then
echo "您似乎没有安装 Python 3.10!"
exit
else
update-alternative
fi
cp ./patch/meson8b-onecloud.dtb /boot/dtb/meson8b-onecloud.dtb && echo "设备树文件覆盖成功!"
if [ -f "./installed.txt" ]; then
echo "检测到存在安装One-KVM记录!"
else
#此为危险操作,会覆盖MBR分区,请在没有自行分区前执行,否则会丢失分区数据系统无法启动!
gzip -dc ./patch/Boot_SkipUSBBurning.gz | dd of=/dev/mmcblk1 && echo "One-KVM V0.4" >> installed.txt && echo "覆盖引导成功!"
echo kvmd ALL=\(ALL\) NOPASSWD: /usr/bin/long_press_gpio420,/usr/bin/short_press_gpio420 >> /etc/sudoers
fi
if [ -f "./installed.txt" ]; then
echo "您似乎已经安装fruity-pikvm_0.2_armhf.deb,是否覆盖安装,此操作不会影响后续文件修改操作(Y/N)?"
read USERYN
case $USERYN in
N | n)
echo "跳过安装fruity-pikvm_0.2_armhf.deb!"
;;
*)
rm /etc/kvmd/nginx/ssl/server.crt
rm /etc/kvmd/nginx/ssl/server.key
echo "正在安装PiKVM......"
dpkg -i ./fruity-pikvm_0.2_armhf.deb >> ./log.txt && systemctl enable kvmd-vnc && echo "PiKVM安装成功!"
cp ./patch/chinese.patch /usr/share/kvmd/web/ && cd /usr/share/kvmd/web/ && patch -s -p0 < chinese.patch
cd $CURRENTWD
cp ./patch/3.198msd.patch /usr/local/lib/python3.10/kvmd-packages/ && cd /usr/local/lib/python3.10/kvmd-packages/ && patch -s -p0 < 3.198msd.patch
echo "补丁应用成功!"
;;
esac
else
bash <(curl -sSL https://gitee.com/SuperManito/LinuxMirrors/raw/main/ChangeMirrors.sh) --source mirrors.tuna.tsinghua.edu.cn --updata-software false --web-protocol http && echo "换源成功!"
echo "正在安装依赖软件nginx tesseract-ocr tesseract-ocr-eng janus libevent-dev libgpiod-dev tesseract-ocr-chi-sim......"
apt install -y nginx tesseract-ocr tesseract-ocr-eng janus libevent-dev libgpiod-dev tesseract-ocr-chi-sim >> ./log.txt
echo "正在安装PiKVM......"
dpkg -i ./fruity-pikvm_0.2_armhf.deb >> ./log.txt && systemctl enable kvmd-vnc && echo "PiKVM安装成功!"
cd $CURRENTWD
cp ./patch/chinese.patch /usr/share/kvmd/web/ && cd /usr/share/kvmd/web/ && patch -s -p0 < chinese.patch
cd $CURRENTWD
cp ./patch/3.198msd.patch /usr/local/lib/python3.10/kvmd-packages/ && cd /usr/local/lib/python3.10/kvmd-packages/ && patch -s -p0 < 3.198msd.patch
echo "补丁应用成功!"
fi
cd $CURRENTWD && cp -f ./patch/long_press_gpio420 /usr/bin && cp -f ./patch/short_press_gpio420 /usr/bin && chmod +x /usr/bin/long_press_gpio420 && chmod +x /usr/bin/short_press_gpio420 && echo "GPIO-420脚本移动成功!"
cp -f ./patch/hw.py /usr/local/lib/python3.10/kvmd-packages/kvmd/apps/kvmd/info/ && chmod +x /usr/local/lib/python3.10/kvmd-packages/kvmd/apps/kvmd/info/hw.py
cp -f ./config/main.yaml /etc/kvmd/ && cp -f ./config/override.yaml /etc/kvmd/ && echo "文件修改成功!"
kvmd -m >> ./log.txt
ipaddr=`ip addr | grep "scope global" | awk '{print $2}' |awk -F/ '{print $1}'`
echo -e "内网访问地址为:\nhttp://$ipaddr\nhttps://$ipaddr"
echo "机器已执行重启命令,请手动给玩客云重新上电(拔插电源),然后就可以开始使用One-KVM了!"
reboot