#!/bin/sh
# The Getty xProtect over-ride script, ©2013 David Koff
# Please use freely as long as you include both of these commented lines.
#----------------------------------------------------------
# Variables
#----------------------------------------------------------
SCRIPTNAME=$0
#-----Logging
exec >> "/Library/Logs/Getty Installations.log" 2>&1
#-----Directories & Files
xProtectPlist="/System/Library/LaunchDaemons/com.apple.xprotectupdater.plist"
xProtectInitPlist="/System/Library/LaunchDaemons/com.apple.xprotectupdaterinit.plist"
xProtectMetaPlist="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist"
LaunchDaemons="/System/Library/LaunchDaemons"
LaunchDaemonsDisabled="/System/Library/LaunchDaemonsDisabled"
#----------------------------------------------------------
# Timestamp
#----------------------------------------------------------
echo " "
echo "###################################"
echo "##### $SCRIPTNAME"
echo "##### `date "+%A %m/%d/%Y %H:%M"`"
echo "###################################"
echo " "
echo ""
echo "### ----- DISABLE XPROTECT ----- ###"
echo ""
echo "### ----- find & rename meta plist"
if [ -f $xProtectMetaPlist ]; then
zip -r $xProtectMetaPlist.zip $xProtectMetaPlist
rm -f $xProtectMetaPlist
echo "The xProtectMetaPlist has been renamed, disabled & left in its original location:"
echo "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/"
elif [ -f $xProtectMetaPlist.zip ]; then
echo "The xProtectMetaPlist has already been zipped & stored at:"
echo "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/"
fi
#### to put it back to it\'s original state
# unzip -j /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/XProtect.meta.plist.zip
# rm -f $xProtectMetaPlist.zip
echo ""
echo "### ----- check for disabled launchdaemons directory"
if [ ! -d $LaunchDaemonsDisabled ]; then
mkdir -v $LaunchDaemonsDisabled
else
echo "$LaunchDaemonsDisabled/ directory has already been created."
rm -fv $LaunchDaemonsDisabled/*
echo "Now it has also been emptied."
fi
echo ""
echo "### ----- unload any active xProtect process"
launchctl unload -w com.apple.xprotectupdater-init
launchctl unload -w "$xProtectPlist"
echo ""
echo "### ----- move any xProtect plists to new location"
cd $LaunchDaemons
mv -v com.apple.xprotect* $LaunchDaemonsDisabled
echo ""
echo "### ----- contents of $LaunchDaemonsDisabled now includes:"
ls $LaunchDaemonsDisabled
#----------------------------------------------------------
# Timestamp
#----------------------------------------------------------
echo " "
echo "###################################"
echo "##### END LOG"
echo "##### `date "+%A %m/%d/%Y %H:%M"`"
echo "###################################"
echo " "
exit 0