Configuring TeamViewer Host 9 to be deployable with Munki

Configuring TeamViewer Host 9 to be deployable with Munki

2014, Apr 16    

TeamViewer has released version 9 and made a few changes which require us to change some of our script in Munki. After testing and help from Erwin and Robert, it has been determined that TeamViewer 9 now has a new encryption that will prevent our previous method of inserting the password using the defaults write command to insert the password via a data binary for the key SecurityPasswordAES. The new key is now PermanentPassword which creates a unique data binary string in the new plist file com.teamviewer.teamviewer9.plist. If you change the password manually it will work however we would like to use Munki to automate this process. After many tests I have determined the best way to do this is to upgrade from TeamViewer 8 to TeamViewer 9.

When upgrading from TeamViewer 8 to TeamViewer 9 your current password will be converted from the old encryption method to the new encryption method. To perform this you will want to always have TeamViewer 8 install FIRST and then use the update_for key in TeamViewer 9 to define that it is an update for TeamViewer 8. Upon completing this method your systems should then be able to use the password we defined in TeamViewer 8 with TeamViewer 9. Please see below on how to set this up:

To configure TeamViewer 9 for use in Munki please follow the following:

Please read through the previous post of Configuring TeamViewer Host 8 to be deployable with Munki

Once you have read through this we will start our package for TeamViewer 9.  You can download the latest version of TeamViewer 9 from their website. Also it is worth noting that if you recently purchased TeamViewer you should still be able to download TeamViewer 8 Host and use the method described in the article above as your license is attached to your user account and not the host application. We will NOT need to define a preinstall_script as this information should carry over from version 8. If you would like to define something I would suggest defining it in the version 8 script to avoid any issues.  We will still define a post_install script as with this method the TeamViewer 8 settings file is left behind as well as a conversion file that it uses called com.TeamViewer9.Settings.plist. Listed below is a script you can use to remove these extra files as well as the customizations that may be left behind from TeamViewer 8.

Post Install Script

1
2
3
4
5
6
7
8
9
10
#!/bin/bash
# Post Instal Script to remove extra files from TeamViewer
# Upgrade by Joshua D. Miller May 16, 2014
# Remove old TeamViewer Settings File and lockfile if it exists
test -f /Library/Preferences/com.TeamViewer8.Settings.plist && rm -f /Library/Preferences/com.TeamViewer8.Settings.plist
test -f /Library/Preferences/com.TeamViewer8.Settings.plist.lockfile && rm -f /Library/Preferences/com.TeamViewer8.Settings.plist.lockfile
test -f /Library/Preferences/com.TeamViewer9.Settings.plist.lockfile && rm -f /Library/Preferences/com.TeamViewer9.Settings.plist.lockfile
# Remove TeamViewer 8 folder in Applications if it exists
test -d /Applications/TeamViewer\ 8/ && rm -rf /Applications/TeamViewer\ 8/
exit 0

Keep in mind that if you are using this with Munki you will need to replace & with && so that the script can be used in a pkginfo file.

I also write a postuninstall_script should we ever need to remove TeamViewer from the system which just basically removes the configuration file.

Post Uninstall Script

1
2
3
#!bin/bash
rm -rf /Library/Preferences/com.teamviewer.teamviewer9.plist
exit 0

Now that TeamViewer will install properly we will want to configure our extra configuration DMG like we did for version 8. We will once again make use of the update_for key to make it an update for TeamViewer 9 Host. One of the notable changes is the logo_host.tiff file is now logo_host.png so you will want to convert this file (You can use Preview). Also you will want to modify the new MainMenuHost.nib and Localizable.strings files as new variables have been added. Once you have changed these files accordingly place them in a DMG (If you need help with this pleas let me know) and use makepkginfo -f on each file in the DMG to get the MD5 for use with Munki.  To get the installer hash you will want to use shasum -a256 yourdmg.dmg. You can copy your previously made pkginfo and change the MD5, installer hash, logo_host file and installer path.

The other thing I noticed was that our customization package would attempt to install even though TeamViewer 9 had been installed since our customization package uses the installs key in Munki to install the files. To remedy this issue, I removed the installs key and used an installcheck_script written in python which will check for the correct TeamViewer installed and then if version 8 is installed compare the MD5 hashes. Please see the script listed below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
# Joshua D. Miller - [email protected]
# July 9, 2014
'''Determines if TeamViewer 9 is installed
and if so makes sure that the TeamViewer 8
customization package is not installed.'''

# Import Libraries
import os
import hashlib

# Set Variables
TeamViewerHost8='/Applications/TeamViewer 8/TeamViewerHost.app'
TeamViewerHost9='/Applications/TeamViewerHost.app'
Logo='/Contents/Resources/logo_host.tiff'
Localizable='/Contents/Resources/en.lproj/Localizable.strings'
MainMenu='/Contents/Resources/MainMenuHost.nib'
hashes = [
			( TeamViewerHost8 + Logo, '33668e170cc7049095ca59618e67f939' ),
			( TeamViewerHost8 + Localizable, '7be298c7319aa3f06295453db6d047bf' ),
			( TeamViewerHost8 + MainMenu, '975bf29115b0c6763812394a72b17453' ),
		 ]


# MD5 Checksum Function
def md5Checksum(filePath, md5sum):
    if hashlib.md5(open(filePath).read()).hexdigest() == md5sum:
    	return True
    else:
    	return False

# Does TeamViewer 9 exist?
if os.path.isfile(TeamViewerHost9 + '/Contents/Info.plist'):
	print 'TeamViewer 9 is installed'
	exit(1)

# Does TeamViewer 8 exist?
elif os.path.isfile(TeamViewerHost8 + '/Contents/Info.plist'):
	print 'TeamViewer 8 is installed.  Checking customization files.....'
	# Check Hashes of customization files
	for file, md5 in hashes:
		if not md5Checksum(file, md5):
			print file + ' md5 doesn't match md5 ' + md5
			print 'Package marked for install....'
			exit(0)
	print 'All customization files match.  Exiting....'
	exit(1)
else:
	print 'TeamViewer is not installed'
	exit(0)