Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.77 KB | None | 0 0
  1. #/bin/bash
  2.  
  3. #Read the Windows formatted SMB path to the user's home directory
  4. #Stores only the URL string from \\ onwards
  5. #Note that four backslashes represent a single backslash here
  6. WinFormattedDirectory=`dscl /Active\ Directory/All\ Domains -read /Users/$USER SMBHome | grep \\\\\\\\.* -o`
  7.  
  8. #If AD fails to return a path to the user space, don't proceed as we don't want to break the user's documents folder
  9. #This is particularly important if the user is logged in as a local user
  10. if [ $? -eq 0 ]
  11. then
  12.     #Replace the server name \\FS0[0-9] from the start of the string with /Volumes to give us the share name and path
  13.     #Note that eight backslashes represent a single backslash here
  14.     ShortenedWinFormattedDirectory=`echo $WinFormattedDirectory | sed s/\\\\\\\\\\\\\\\\fs0[0-9]/\\\\/Volumes/`
  15.  
  16.     #Replace all backslashes with forward slashes
  17.     #Note that eight backslashes represent a single backslash here
  18.     MacFormattedDirectory=`/Volumes/$USER`
  19.  
  20.     #Change permissions on local documents folder so that we can delete it
  21.     chmod -R -N ~/Documents
  22.  
  23.     #Remove the local Documents folder
  24.     rm -rf ~/Documents
  25.  
  26.     #Create a SymLink to the network documents folder
  27.     ln -s $MacFormattedDirectory ~/Documents
  28.  
  29.     #Create Downloads directory in network My Documents folder if it doesn't already exist
  30.     mkdir ~/Documents/Downloads
  31.  
  32.     #Change permissions on local Downloads folder so that we can delete it
  33.     chmod -R -N ~/Downloads
  34.  
  35.     #Remove the local Downloads folder
  36.     rm -rf ~/Downloads
  37.  
  38.     #Create a SymLink to the network Downloads folder
  39.     ln -s ~/Documents/Downloads ~/Downloads
  40.  
  41.     #Create My Videos directory in network My Documents folder if it doesn't already exist
  42.     mkdir ~/Documents/My\ Videos
  43.  
  44.     #Change permissions on local Movies folder so that we can delete it
  45.     chmod -R -N ~/Movies
  46.  
  47.     #Remove the local Movies folder
  48.     rm -rf ~/Movies
  49.  
  50.     #Create a SymLink to the network My Videos folder
  51.     ln -s ~/Documents/My\ Videos ~/Movies
  52.  
  53.     #Create My Music directory in network My Documents folder if it doesn't already exist
  54.     mkdir ~/Documents/My\ Music
  55.  
  56.     #Change permissions on local Music folder so that we can delete it
  57.     chmod -R -N ~/Music
  58.  
  59.     #Remove the local Music folder
  60.     rm -rf ~/Music
  61.  
  62.     #Create a SymLink to the network My Music folder
  63.     ln -s ~/Documents/My\ Music ~/Music
  64.  
  65.     #Create My Pictures directory in network My Documents folder if it doesn't already exist
  66.     mkdir ~/Documents/My\ Pictures
  67.  
  68.     #Change permissions on local Pictures folder so that we can delete it
  69.     chmod -R -N ~/Pictures
  70.  
  71.     #Remove the local Pictures folder
  72.     rm -rf ~/Pictures
  73.  
  74.     #Create a SymLink to the network My Pictures folder
  75.     ln -s ~/Documents/My\ Pictures ~/Pictures
  76. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement