Skip to content

Instantly share code, notes, and snippets.

@cshepp1211
Created February 23, 2016 15:51
Show Gist options
  • Save cshepp1211/c59b485b9dd034abbc76 to your computer and use it in GitHub Desktop.
Save cshepp1211/c59b485b9dd034abbc76 to your computer and use it in GitHub Desktop.
OneDrive through Self Service
#!/bin/bash
# Author : Chris Sheppard
# Set up log file, folder and function
LOGFOLDER="/private/var/log/gov.fnal"
LOG=$LOGFOLDER"/OneDrive-2016-Install.log"
error=0
if [ ! -d "$LOGFOLDER" ];
then
mkdir $LOGFOLDER
fi
logme()
{
# Check to see if function has been called correctly
if [ -z "$1" ]
then
echo $( date )" - logme function call error: no text passed to function! Please recheck code!"
exit 1
fi
# Log the passed details
echo $( date )" - "$1 >> $LOG
echo "" >> $LOG
}
logme "Starting Installation of Microsoft OneDrive"
# Install all the packages
logme "Installing Microsoft OneDrive"
jamf policy -trigger run-onedrive-install ${LOG}
logme "System Events Choice"
osascript -e 'tell app "System Events" to display alert "Hello, To help get things setup..." message "Do you currently have the Microsoft OneDrive Application installed and a personal account activated?" as critical buttons {"Yes" , "No"} default button 2
set response to button returned of the result
if response is "Yes" then
do shell script "defaults write /Library/Preferences/com.microsoft.OneDrive-mac EnableAddAccounts -bool True"
else if response is "No" then
do shell script "defaults write /Library/Preferences/com.microsoft.OneDrive-mac EnableAddAccounts -bool True"
do shell script "defaults write /Library/Preferences/com.microsoft.OneDrive-mac DefaultToBusinessFRE -bool True"
end if'
logme "Package installation completed."
osascript -e 'tell app "System Events" to display alert "Micorosft OneDrive was successfully Installed" message "You may click on the Open Link button below for instructions on how to setup OneDrive." as critical buttons {"Open Link" , "No Thanks"} default button 1
set response to button returned of the result
if response is "Open Link" then open location "https://urltoKBarticle.com"'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment