Skip to content

Instantly share code, notes, and snippets.

@xorl
Created September 29, 2012 06:58
Show Gist options
  • Save xorl/3803389 to your computer and use it in GitHub Desktop.
Save xorl/3803389 to your computer and use it in GitHub Desktop.
#!/bin/bash
#######################################
# Natit & Titan Installer
# Simple Plist Editor. Auto Generates the device/venderID combo for your card.
#
# V: .02 -- By xorl #scripts
# Made this version a little more Sane with functions
######################################
### Variables ###
VE=$( system_profiler SPDisplaysDataType | grep -a 'Vendor:' | cut -d: -f2 | sed -e 's/\ nVIDIA (0x//' -e 's/)$//' )
DE=$( system_profiler SPDisplaysDataType | grep -e 'Device ID:' | cut -d: -f2 | sed -e 's/\ 0x//g' )
NV40='/System/Library/Extensions/NVDANV40Hal.kext/Contents/Info.plist'
NV30='/System/Library/Extensions/NVDANV30Hal.kext/Contents/Info.plist'
RES="/System/Library/Extensions/NVDAResman.kext/Contents/Info.plist"
GEF="/System/Library/Extensions/GeForce.kext/Contents/Info.plist"
RED='\e[0;31m'
NC='\e[0m'
### Functions ###
function bplist {
echo "Backing up PLISTS"
(cat "$GEF" > /tmp/NVKextED/Gef.plist)
(cat "$NV40" > /tmp/NVKextED/NV40.plist)
(cat "$NV30" > /tmp/NVKextED/NV30.plist)
(cat "$RES" > /tmp/NVKextED/Res.plist)
}
function edplist {
echo "Editing Plists"
(cat "$GEF" | sed "41s/\([^>]*>\)[^<]*\(<[^>]*>\)/\10x${DE}${VE}\2/" > $GEF)
(cat "$NV40" | sed "36s/\([^>]*>\)[^<]*\(<[^>]*>\)/\10x${DE}${VE}\2/" > $NV40)
(cat "$NV30" | sed "36s/\([^>]*>\)[^<]*\(<[^>]*>\)/\10x${DE}${VE}\2/" > $NV30)
(cat "$RES" | sed "58s/\([^>]*>\)[^<]*\(<[^>]*>\)/\10x${DE}${VE}\2/" > $RES)
}
function kclean {
rm -rf /System/Library/Extensions.mkext
rm -rf /System/Library/Extensions.kextcache
}
function repair {
echo "Repairing Permissions"
diskutil repairPermissions /
echo "Done. Now you can reboot."
}
function ogl {
echo "Copying OpenGL.framework into place."
cp -rf ./OpenGL.framework /System/Library/Frameworks/
echo "Done Copying OpenGL.framework"
}
function remove {
echo -e "${RED}Copying back original Plists."
cp -rf /tmp/NVKextED/Gef.plist $GEF
cp -rf /tmp/NVKextED/NV40.plist $NV40
cp -rf /tmp/NVKextED/NV30.plist $NV30
cp -rf /tmp/NVKextED/Res.plist $RES
}
### Defining if user is UID 0 if not exit with error. ###
if [ $UID -eq 0 ]
then
case "$1" in
"--Titan")
echo "You have chosen titan, we are installing it now";
# Checking to make sure natit is not installed!
if [ -d /System/Library/Extensions/Natit.kext ]
then
mkdir /tmp/NVKextED/
mv /Sytem/Library/Extensions/Natit.kext /tmp/NVKextED/
echo -e "${RED}You had Natit installed, moving to /tmp/NVKextED/";
fi
cp -rf ./Titan.kext /System/Library/Extensions/
echo "Titan Copied -- Removing kextcache and mkext";
kclean
ogl
bplist
edplist
repair
;;
"--Natit")
echo "You have chosen Natit, we are installing it now";
# Checking to make sure Titan is not installed!
if [ -d /System/Library/Extensions/Titan.kext ]
then
mkdir /tmp/NVKextED/
mv /Sytem/Library/Extensions/Titan.kext /tmp/NVKextED/
echo -e "${RED}You had Titan installed, moving to /tmp/NVKextED/";
fi
cp -rf ./Natit.kext /System/Library/Extensions/
echo "Titan Copied -- Removing kextcache and mkext";
kclean
ogl
bplist
edplist
repair
;;
"--RTitan")
echo "Removing Titan."
remove
echo -e "${RED}Removing Titan.kext"
mv /System/Library/Extensions/Titan.kext /tmp/NVKextED/
echo "Done, you can now reboot"
;;
"--RNatit")
echo -e "${RED}Removing Natit."
remove
mv /System/Library/Extensions/Natit.kext /tmp/NVKextED/
echo "Done, you can now reboot"
;;
*)
echo "Usage:"
echo "--Titan Switch Installs With Titan."
echo "--Natit Switch Install with Natit."
echo "--RTitan Removes Titan."
echo "--RNatit Removes Natit."
echo -e "Requirements: ${RED}Natit.kext${NC} or ${RED}Titan.kext${NC} in the same directory."
echo -e "As well as ${RED}OpenGL.framework${NC} from the official intel"
echo "Combo Update."
;;
esac
else
echo "You must be root to run this script, exiting."
fi
23:57:15 ~>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment