#!/bin/bash
# MacOS Catalina (10.15): Darwin 19.x.0
kernelver=`uname -a | awk '{print $3}'`
kernelver1=$(echo $kernelver | cut -d "." -f 1)
kernelver2=$(echo $kernelver | cut -d "." -f 2)
kernelver=$kernelver1.$kernelver2
echo "Check Mac OS kernel version: Darwin kernel version : $kernelver"
if [ $(echo "$kernelver >= 19.0" |bc) -eq 1 ]; then
echo " Mac OS version >= 10.15.x"
kernelpath=`sudo pwd`
if [ "$kernelpath" != "/Library/Extensions" ]; then
echo " In path $kernelpath"
if [ -d "/Library/Extensions/ACS6x.kext" ]; then
# 目錄 存在
echo " Directory /Library/Extensions/ACS6x.kext exists."
echo " Remove ACS6x.kext driver"
sudo rm -rf /Library/Extensions/ACS6x.kext
echo " Copy driver to system"
sudo cp -R ACS6x.kext /Library/Extensions/
sudo cd /Library/Extensions/
else
# 目錄 不存在
echo " Directory /Library/Extensions/ACS6x.kext does not exists."
echo " Copy driver to system"
sudo cp -R ACS6x.kext /Library/Extensions/
sudo cd /Library/Extensions/
fi
else
if [! -d "/Library/Extensions/ACS6x.kext" ]; then
# 目錄 不存在
echo " Error: Directory /Library/Extensions/ACS6x.kext does not exists."
exit 0
fi
fi
echo " Change ACS6x.kext driver owner"
sudo chmod -R 755 ACS6x.kext
sudo chown -R root:wheel ACS6x.kext
sudo xattr -d -r ACS6x.kext
driverstat=`sudo kextstat|grep Accusys`
if [ "$driverstat" != "" ]; then
echo " Kextunload ACS6x.kext driver"
sudo kextunload ACS6x.kext
sudo kextunload ACS6x.kext
fi
echo " Clear system cache"
sudo kextcache -clear-staging
echo " Loaded ACS6x.kext driver"
sudo kextload ACS6x.kext
echo " Rebiuld system cache"
#sudo kextcache -system-prelinked-kernel
#sudo kextcache -system-caches
sudo kextcache -i /
else
echo "Mac OS version < 10.15.x"
driverstat=`sudo kextstat|grep Accusys`
if [ "$driverstat" != "" ]; then
echo " Kextunload ACS6x.kext driver"
sudo kextunload ACS6x.kext
sudo kextunload ACS6x.kext
fi
echo "Kextload ACS6x.kext driver"
sudo chmod -R 755 ACS6x.kext
sudo chown -R root:wheel ACS6x.kext
sudo kextload ACS6x.kext
if [ $(echo "$kernelver >= 14.0" |bc) -eq 1 ]; then
sudo touch /Library/Extensions
else
sudo touch /System/Library/Extensions
fi
fi
沒有留言:
張貼留言