Advertisement
themacdweeb

Add Favorite Server on OSX.sh

Oct 16th, 2013
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.17 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Modify Server Shortcuts, ©2013 David Koff
  4. # script adds a server to the list appearing at Go -> Connect to Server
  5. # result will appear for all > 500 user accounts.
  6. # to create your own shortcuts, just change the variables:
  7. #
  8. # ServerName = the name of the server you'd like to appear in your list
  9. # ServerURL = the actual URL to that server
  10. #
  11. # reference thanks to Mike and Rich:
  12. # http://jamfnation.jamfsoftware.com/viewProfile.html?userID=1927
  13. # http://derflounder.wordpress.com/2013/01/10/updating-server-bookmarks-in-com-apple-sidebarlists-plist/
  14. #
  15. # Created: 4.2013
  16.  
  17.  
  18.  
  19.  
  20. #----------------------------------------------------------
  21. #   Variables
  22. #----------------------------------------------------------
  23.  
  24. # --- assignments ---
  25. ServerName="Pubs Illustrations"
  26. ServerURL="afp://athens-shared-server/Shared/Illustrations"
  27.  
  28. # --- executables ---
  29. Plist="/usr/libexec/PlistBuddy"
  30.  
  31. #--- Set Logging
  32. exec >> "/Library/Logs/Getty Installations.log" 2>&1
  33.  
  34. # --- computationals ---
  35. date=`date "+%A %m/%d/%Y %H:%M"`
  36. over500=`dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'`
  37.  
  38. #----------------------------------------------------------
  39. #  Timestamp
  40. #----------------------------------------------------------
  41. echo "                                   "
  42. echo "###################################"
  43. echo "##### $SCRIPTNAME"
  44. echo "##### `date "+%A %m/%d/%Y %H:%M"`"
  45. echo "###################################"
  46. echo "
  47.  
  48. # ---------------------------------------------------------------------------
  49. #   Go to every user, back-up file, add new link, fix permissions
  50. # ---------------------------------------------------------------------------
  51. for i in $over500
  52. do
  53.     cd /Users/$i/Library/Preferences
  54.     zip SidebarListsBackup.zip com.apple.sidebarlists.plist
  55.     $Plist com.apple.sidebarlists.plist -c "Add :favoriteservers:CustomListItems:0 dict"
  56.     $Plist com.apple.sidebarlists.plist -c "Add :favoriteservers:CustomListItems:0:Name string ${ServerName}"
  57.     $Plist com.apple.sidebarlists.plist -c "Add :favoriteservers:CustomListItems:0:URL string ${ServerURL}"
  58.     /usr/sbin/chown ${i}:staff /Users/$i/Library/Preferences/com.apple.sidebarlists.plist
  59. done
  60.  
  61. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement