Guest User

Untitled

a guest
Feb 22nd, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # odde (Optical Drive Disabler and Enabler)
  4. # Ben Atkin (ben@benatkin.com)
  5. # 2009-01-05
  6. #
  7. # NO WARRANTY!
  8. #
  9. # Please only run this if you can grok the code.
  10. #
  11. # This will disable and enable your optical drive. It requires a restart.
  12. # It is not known what effect other software (including software updates)
  13. # will have on this if they do anything with this kernel extension.
  14. #
  15. # I created this because I've found the optical drive noise my MacBook
  16. # makes when it comes out of sleep to be annoying at times. Unfortunately
  17. # it still makes that noise.
  18.  
  19. ddir='/System/Library/Disabled Extensions'
  20. dkext='/System/Library/Disabled Extensions/IODVDStorageFamily.kext'
  21. ekext='/System/Library/Extensions/IODVDStorageFamily.kext'
  22.  
  23. check_for_root ()
  24. {
  25. if [ $(id -u) != 0 ]; then
  26. echo "You must be root to execute this script."
  27. exit 67
  28. fi
  29. }
  30.  
  31. case $1 in
  32. 'disable')
  33. check_for_root
  34.  
  35. if [ -a "$dkext" ]; then
  36. echo "The optical drive has already been disabled. Try restarting."
  37. exit 1
  38. fi
  39.  
  40. echo 'Please remove any disc(s) from your optical drive(s) and press return.'
  41. read
  42.  
  43. mkdir -p "$ddir" && mv "$ekext" "$dkext"
  44.  
  45. echo 'Your optical drive will be disabled after you restart.'
  46. ;;
  47. 'enable')
  48. check_for_root
  49.  
  50. if [ -a "$ekext" ]; then
  51. echo "The optical drive is already enabled. Try restarting."
  52. exit 1
  53. fi
  54.  
  55. mv "$dkext" "$ekext"
  56.  
  57. echo 'Your optical drive will be enabled after you restart.'
  58. ;;
  59. *)
  60. echo "usage: $0 disable or $0 enable"
  61. ;;
  62. esac
Add Comment
Please, Sign In to add comment