Saturday, 19 April 2014

Lync for mac 14.0.8 package

So microsoft brought out an update to Lync for mac, this update fixes the contacts not searchable issue on mavericks. There are a few changes when its installed though.

Previously in order to auto populate a Lync users ID from the AD server all we had to do was populate the com.microsoft.Lync.plist with the sign in name and Lync address.

But in Lync 14.0.8 the /Users/UserName/Library/Preferences/com.microsoft.Lync.plist file is created only when lync is launched for the first time and the license agreement accepted. So for a new install the old method doesn't work. We worked around it by displaying the sign-in details as part of a postflight script that ran after Lync got installed.

To create the lync for mac package use composer to capture a snapshot before Lync is installed.

Modify the  MicrosoftLyncRegistrationDB.plist located at /Library/Preferences with the Lync internal and external server name.


Create the package after Lync is installed and remove unnecessary items.
You'll need to  make sure that the modified MicrosoftLyncRegistrationDB.plist is in the package,












--> Then put in preflight and postflight scripts as follows:Then after putting in the scripts Build your pkg.
I'll put in my scripts here, on condition that you credit me with any future use:
Preupgrade.sh:
################################################################
#!/bin/sh
## preinstall
#Lync for mac preupgrade script created by tausif
#created to kill lync and remove the sip_* directory in current AD users home folder .
USERNAME=$(ls -l /dev/console | awk '{print $3}' )
#get console user
HOME=$(sudo dscl . -read /Users/$USERNAME NFSHomeDirectory | awk '{print $2}')
#get current users home directory
MobileUsers=`dscl . read /Users/$USERNAME OriginalNodeName | grep "Active Directory"`
#this is to filter out local users and target only AD users
logFile="/private/var/log/LyncPreinstall.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}

LYNC_PID=$(ps ax | grep "/Applications/Microsoft Lync.app/Contents/MacOS/Microsoft Lync" | grep -v grep | awk '{ print $1 }')
kill -9 ${LYNC_PID}
if [ $? = 0 ] ; then
log "Lync is open killing it now "
else
log "Lync is not running"
fi
for username in $MobileUsers
do
rm -rf $HOME/Documents/Microsoft\ User\ Data/Microsoft\ Lync\ Data/sip_*
log "Removed SIP dir"
done

exit 0          ## Success
exit 1          ## Failure

################################################################

Postfilght.sh:
################################################################
#!/bin/sh
## postinstall.sh
#Lync for mac postupgrade script created by tausif
#created to install lync, diplay Lync credentials to user,add lync to user's dock and remove the sip_* #directory in current AD users home folder .
USERNAME=$(ls -l /dev/console | awk '{print $3}' )
#get current user
HOME=$(sudo dscl . -read /Users/$USERNAME NFSHomeDirectory | awk '{print $2}')
#get current users home directory
EMAILADDRESS=$( dscl /Search -read /Users/$USERNAME | grep -i msRTCSIP-PrimaryUserAddress | awk '{print $2}'| cut -c 5- )
#very tricky get Lync signin address
CORP='CORP\\'
LYNCNAME=$CORP$USERNAME
#do this because osascript is strange when run from shell
MobileUsers=`dscl . read /Users/$USERNAME OriginalNodeName | grep "Active Directory"`
#filter only for AD users, we don't want to do this from a local account
logFile="/private/var/log/LyncPostinstall.log"
log () {
echo $1
echo $(date "+%Y-%m-%d %H:%M:%S: ") $1 >> $logFile
}
#log everything
#check for local user running this.
if [[ $MobileUsers != " /Active Directory/CORP/corp.fairisaac.com" ]];
then
/usr/bin/osascript << EOF
tell application "System Events"
    activate
    display dialog "Lync auto-setup applies only to Active Directory accounts. Aborting " with title "Aborting" with icon note buttons {"OK"} default button 1
end tell
EOF
log "Local account used"
exit 1
fi
#tell user his lync details
/usr/bin/osascript << EOF
 tell application "System Events"
        activate
        display dialog "Please note your sign in details and click ok to complete the Installation" & "\nLync sign-in Address: \"$EMAILADDRESS\""  &  " \nLync Username: \"$LYNCNAME\" " with title "Lync Sign in Details" with icon note buttons {"OK"} default button 1
    end tell
EOF
log "sign in details displayed"
#add lync icon to dock
for username in $MobileUsers
do
defaults write $HOME/Library/Preferences/com.apple.dock.plist persistent-apps -array-add "tile-datafile-data_CFURLString/Applications/Microsoft Lync.app/_CFURLStringType0"
done
log "Lync icon added to dock"
sleep 5

chown $USERNAME:"CORP\Domain Users" $HOME/Library/Preferences/com.apple.dock.plist
chmod 600 $HOME/Library/Preferences/com.apple.dock.plist
log "perms changed on dock plist"
#bounce dock
killall -HUP cfprefsd
#cfprefsd for mavericks
killall -HUP Dock

log "bounced dock"

exit 0        ## Success
exit 1        ## Failure

No comments:

Post a Comment

Detect autopilot session

  Ensuring that some apps only install during autopilot is not easily accomplished, you can use the below powershell script as a requiremen...