Created
June 14, 2013 11:12
-
-
Save jinie/5781080 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
trap "echo Exited!; exit;" SIGINT SIGTERM | |
# Make sure only root can run our script | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
echo "-----------------------------------------------------------" | |
echo "-----------------------------------------------------------" | |
#check SMART | |
SMART_Status=`diskutil info disk0 | grep SMART | awk '{print $3;}'` | |
if [[ "$SMART_Status" -ne "Verified" ]]; then | |
echo "-> SMART Status failed, status is $SMART_Status" | |
exit 1 | |
else | |
echo "-> SMART Status $SMART_Status" | |
fi | |
echo "-----------------------------------------------------------" | |
#Verify disk | |
echo "-> Verifying root disk" | |
diskutil verifyVolume / | |
if [ $? -ne 0 ] | |
then | |
echo "root disk needs repairs" | |
exit 1 | |
fi | |
echo "-----------------------------------------------------------" | |
#Repair Disk Permissions | |
echo "-> Repairing permissions" | |
diskutil repairPermissions / | |
echo "-----------------------------------------------------------" | |
#execute periodic scripts | |
echo "-> Running periodic scripts" | |
periodic daily weekly monthly | |
echo "-----------------------------------------------------------" | |
#reset spotlight | |
echo "-> Resetting Spotlight index" | |
mdutil -i off / | |
mdutil -E / | |
rm -Rf /var/folders/* | |
#enable spotlight again | |
mdutil -i on / | |
echo "-----------------------------------------------------------" | |
echo "-> Rebuilding launch services" | |
#rebuild launch services | |
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -seed -r | |
echo "-----------------------------------------------------------" | |
echo "-> Rebuilding dyld shared cache" | |
#rebuild dyld shared cache | |
update_dyld_shared_cache -force | |
echo "-----------------------------------------------------------" | |
echo "-> Emptying trash" | |
#empty trash | |
osascript -e 'tell app "Finder" to empty' | |
#delete caches | |
echo "-----------------------------------------------------------" | |
echo "-> Deleting user cache" | |
rm -rf ~/Library/Caches/* | |
echo "-> Deleting system cache" | |
rm -rf /Library/Caches/* | |
echo "-----------------------------------------------------------" | |
echo "All Done" | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment