From 24004d16f80219aefc1d7b18dee4269d6d6bf4fa Mon Sep 17 00:00:00 2001 From: for5million Date: Thu, 17 Nov 2022 22:37:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=A8pve=207.2x=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E4=B8=8D=E5=85=BC=E5=AE=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pvetools.sh | 57 ++++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/pvetools.sh b/pvetools.sh index 995157e..de9aa0a 100755 --- a/pvetools.sh +++ b/pvetools.sh @@ -1780,7 +1780,7 @@ Install complete,if everything ok ,it\'s showed sensors.Next, restart you web. " 20 60 rm /tmp/sensors cat << EOF > /usr/bin/s.sh -r=\`sensors|grep -E 'Package id 0|fan|Physical id 0|Core'|grep '^[a-zA-Z0-9].[[:print:]]*:.\s*\S*[0-9].\s*[A-Z].' -o|sed 's/:\ */:/g'|sed 's/:/":"/g'|sed 's/^/"/g' |sed 's/$/",/g'|sed 's/\ C\ /C/g'|sed 's/\ V\ /V/g'|sed 's/\ RP/RPM/g'|sed 's/\ //g'|awk 'BEGIN{ORS=""}{print \$0}'|sed 's/\,\$//g'|sed 's/°C/C/g'\` +r=\`sensors|grep -E 'Package id 0|fan|Physical id 0|Core'|grep '^[a-zA-Z0-9].[[:print:]]*:.\s*\S*[0-9].\s*[A-Z].' -o|sed 's/:\ */:/g'|sed 's/:/":"/g'|sed 's/^/"/g' |sed 's/$/",/g'|sed 's/\ C\ /C/g'|sed 's/\ V\ /V/g'|sed 's/\ RP/RPM/g'|sed 's/\ //g'|awk 'BEGIN{ORS=""}{print \$0}'|sed 's/\,\$//g'|sed 's/°C/\°C/g'\` c=\`lscpu|grep MHz|sed 's/CPU\ /CPU-/g'|sed 's/\ MHz/-MHz/g'|sed 's/\ //g'|sed 's/^/"/g'|sed 's/$/"\,/g'|sed 's/\:/\"\:\"/g'|awk 'BEGIN{ORS=""}{print \$0}'|sed 's/\,\$//g'\` r="{"\$r","\$c"}" echo \$r @@ -1920,6 +1920,21 @@ Uninstall complete. fi } +getIommu(){ + ppv=`/usr/bin/pveversion` + OS=`echo $ppv|awk -F'-' 'NR==1{print $1}'` + ver=`echo $ppv|awk -F'/' 'NR==1{print $2}'|awk -F'-' '{print $1}'` + bver=`echo $ppv|awk -F'/' 'NR==1{print $2}'|awk -F'.' '{print $1}'` + if [ `cat /proc/cpuinfo|grep Intel|wc -l` = 0 ];then + iommu="amd_iommu=on" + else + iommu="intel_iommu=on" + fi + if [ ${bver} -gt 6 ];then + iommu=$iommu" iommu=pt pcie_acs_override=downstream" + fi +} + chPassth(){ #--------------funcs-start---------------- @@ -1935,20 +1950,9 @@ Your hardware do not support PCI Passthrough(No IOMMU) " 10 60 chPassth fi - ppv=`/usr/bin/pveversion` - OS=`echo $ppv|awk -F'-' 'NR==1{print $1}'` - ver=`echo $ppv|awk -F'/' 'NR==1{print $2}'|awk -F'-' '{print $1}'` - bver=`echo $ppv|awk -F'/' 'NR==1{print $2}'|awk -F'.' '{print $1}'` - if [ `cat /proc/cpuinfo|grep Intel|wc -l` = 0 ];then - iommu="amd_iommu=on" - else - iommu="intel_iommu=on" - fi - if [ ${bver} -gt 6 ];then - iommu=$iommu" iommu=pt pcie_acs_override=downstream" - fi - if [ `grep $iommu /etc/default/grub|wc -l` = 0 ];then - sed -i.bak 's|quiet|quiet '$iommu'|' /etc/default/grub + getIommu + if [ `grep "$iommu" /etc/default/grub|wc -l` = 0 ];then + sed -i.bak "s|quiet|quiet $iommu|" /etc/default/grub update-grub if [ `grep "vfio" /etc/modules|wc -l` = 0 ];then cat <> /etc/modules @@ -1986,19 +1990,15 @@ Your hardware do not support PCI Passthrough(No IOMMU) " 10 60 chPassth fi - if [ `cat /proc/cpuinfo|grep Intel|wc -l` = 0 ];then - iommu='amd_iommu=on' - else - iommu='intel_iommu=on' - fi - if [ `grep $iommu /etc/default/grub|wc -l` = 0 ];then + getIommu + if [ `grep "$iommu" /etc/default/grub|wc -l` = 0 ];then whiptail --title "Warnning" --msgbox "not config yet. 您还没有配置过该项" 10 60 chPassth else update-grub { - sed -i 's/ '$iommu'//g' /etc/default/grub + sed -i "s/ $iommu//g" /etc/default/grub echo 30 echo 80 sed -i '/vfio/d' /etc/modules @@ -2062,18 +2062,18 @@ getVideo(){ n=`for i in $id;do lspci -n -d $i|awk -F "." '{print $1}';done|sort -u` for i in $n do - cards=`sed -n '/'$i'/ s/OFF/ON/p' cards` + sed -i "/${i}/s/OFF/ON/" cards done DISTROS=$(whiptail --title "Video cards:" --checklist \ "Choose cards to config(* mark means configed): 选择显卡(标*号为已经配置过的): " 15 90 4 \ -$(echo $cards) \ +$(cat cards) \ 3>&1 1>&2 2>&3) exitstatus=$? if [ $exitstatus = 0 ];then #--config-id--- - if [ $DISTROS ];then + if [ -n "$DISTROS" ];then rm cards* if(whiptail --title "Warnning" --yesno " Continue? @@ -2112,7 +2112,8 @@ Continue? #--iommu-groups-- if [ `find /sys/kernel/iommu_groups/ -type l|wc -l` = 0 ];then if [ `grep 'pcie_acs_override=downstream' /etc/default/grub|wc -l` = 0 ];then - sed -i.bak 's|iommu=on|iommu=on 'iommu=pt pcie_acs_override=downstream'|' /etc/default/grub + getIommu + sed -i.bak "s|quiet|quiet $iommu|" /etc/default/grub update-grub fi fi @@ -2675,7 +2676,9 @@ EOF if [ $L = "en" ];then alpineUrl='http://dl-cdn.alpinelinux.org/alpine/v3.10/releases/x86_64' else - alpineUrl='https://mirrors.aliyun.com/alpine/v3.10/releases/x86_64' + #alpineUrl='https://mirrors.aliyun.com/alpine/v3.10/releases/x86_64' + #change url + alpineUrl='https://mirrors.ustc.edu.cn/alpine/v3.10/releases/x86_64/' fi version=`wget $alpineUrl/ -q -O -|grep minirootfs|grep -o '[0-9]*\.[0-9]*\.[0-9]*'|sort -u -r|awk 'NR==1{print $1}'` echo $alpineUrl -- Gitee