Posted on 11-07-2017 05:43 AM
I did a test today with the below script in JSS. It creates the onedrive path structure we want for the current user. It worked, and surprisingly did not generate errors due to saved files that were open in the desktop and documents folder.
When I logged in as that user later, the Desktop link was automatically recreated in Finder sidebar for the user, but not the Documents link.
What can I add to this script at the end to force the Documents (and Desktop in case it was a fluke) links back to the user's Finder sidebar?
currentuser=$(who | grep console | awk '{print $1}')
echo $currentuser
mkdir /Users/$currentuser/OneDrive - Alma College/
mkdir /Users/$currentuser/OneDrive - Alma College/Mac-Files/
chown -R $currentuser /Users/$currentuser/OneDrive - Alma College/
rm -r /Users/$currentuser/Documents/Microsoft User Data
mv /Users/$currentuser/Desktop/ /Users/$currentuser/OneDrive - Alma College/Mac-Files/Desktop/
mv /Users/$currentuser/Documents/ /Users/$currentuser/OneDrive - Alma College/Mac-Files/Documents/
rm /Users/$currentuser/Library/Preferences/com.apple.sidebarlists.plist
rm /Users/$currentuser/Library/Preferences/com.apple.finder.plist
ln -s /Users/$currentuser/OneDrive - Alma College/Mac-Files/Desktop/ /Users/$currentuser/Desktop
ln -s /Users/$currentuser/OneDrive - Alma College/Mac-Files/Documents /Users/$currentuser/Documents
chown -h $currentuser /Users/$currentuser/OneDrive - Alma College/Mac-Files/Desktop/ /Users/$currentuser/Desktop
chown -h $currentuser /Users/$currentuser/OneDrive - Alma College/Mac-Files/Documents /Users/$currentuser/Documents
Posted on 11-07-2017 05:45 AM
For some reason when I copied and pasted to my post, it removed the pound signs for my comments in the script. Please ignore that.
Posted on 11-07-2017 05:50 AM
@mccallister You need to use the code block tag of three consecutive backtick characters (```) before and after any script you want to display in a post, otherwise the display gets mangled.