I have onedrive implemented for users that received new notebooks (manually pushing the app and our preference files), and now I need to push it out with JAMF to all the desktop machines. Below are the unix commands I have been manually entering in Terminal to create the onedrive path structure, move desktop and documents to there, and correct permission.
Question 1. What do I need to enter at the beginning of this script to read the current logged in user and substitute their username for the username of "mactest" that I have in the script?
Question 2. With the user logged in, the desktop and document folders (and files under them) may be in use. Will the script fail in that scenario?
Create onedrive structure
mkdir /Users/mactest/OneDrive - Alma College/
mkdir /Users/mactest/OneDrive - Alma College/Mac-Files/
Change ownership of that onedrive structure
chown -R mactest:"ALMANETDomain Users" /Users/mactest/OneDrive - Alma College/
Delete Microsoft User Data from Office 2011 prior to moving due to illegal characters in filenames
rm -r /Users/mactest/Documents/Microsoft User Data
Move the files
mv /Users/mactest/Desktop/ /Users/mactest/OneDrive - Alma College/Mac-Files/Desktop/
mv /Users/mactest/Documents/ /Users/mactest/OneDrive - Alma College/Mac-Files/Documents/
Delete finder prefs for user
rm /Users/mactest/Library/Preferences/com.apple.sidebarlists.plist
rm /Users/mactest/Library/Preferences/com.apple.finder.plist
Create symbolic links
ln -s /Users/mactest/OneDrive - Alma College/Mac-Files/Desktop/ /Users/mactest/Desktop
ln -s /Users/mactest/OneDrive - Alma College/Mac-Files/Documents /Users/mactest/Documents
Modify permissions on symbolic links themselves
chown -h mactest:"ALMANETDomain Users" /Users/mactest/OneDrive - Alma College/Mac-Files/Desktop/ /Users/mactest/Desktop
chown -h mactest:"ALMANETDomain Users" /Users/mactest/OneDrive - Alma College/Mac-Files/Documents /Users/mactest/Documents