Created
July 22, 2021 18:26
-
-
Save joshua-d-miller/4b22a33cd40191e9994901d99e6a3cdd to your computer and use it in GitHub Desktop.
TeamViewer 15 PostInstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/psupython | |
# pylint:disable=C0103 | |
'''TeamViewer 15 PostInstall Script''' | |
# This will add our congifuration ID to the application | |
# bundle so that any custom host module visual modifications | |
# will be downloaded from the site for each user. It will | |
# also create a launchagent that will keep the TeamViewer | |
# client running when a user is logged in even if they exit. | |
# Joshua D. Miller - [email protected] | |
# August 13, 2020 - The Pennsylvania State University | |
from __future__ import print_function | |
from os import path | |
from plistlib import dump as writePlist | |
from xattr import setxattr | |
def main(): | |
'''This function will apply our configuration ID so that | |
customizations are added to TeamViewer from our module created | |
in the management console. It will also create our persistant | |
launchagent.''' | |
tv_app_path = '/Applications/TeamViewerHost.app' | |
# TeamViewer Config ID | |
tv_conf_id = 'com.TeamViewer.ConfigurationId' | |
# Custom Attribute from custom pkg | |
attribute = 'Your Config ID Here' | |
# Apply the xattr to TeamViewer's App file for customization | |
try: | |
setxattr(tv_app_path, tv_conf_id, attribute) | |
except StandardError as error: | |
print(error) | |
exit(1) | |
# Create LaunchAgent if it doesn't already exist | |
service_la = ('/Library/LaunchAgents/com.teamviewer.client.plist') | |
if path.isfile(service_la): | |
print('LaunchAgent exists. No creation is needed...') | |
else: | |
la_plist = dict( | |
Disabled=False, | |
KeepAlive=True, | |
Label='com.teamviewer.client', | |
ProgramArguments=[ | |
'/bin/launchctl', 'load', | |
'com.teamviewer.teamviewer.plist', | |
'com.teamviewer.teamviewer_desktop.plist'], | |
RunAtLoad=True, | |
WorkingDirectory='/Library/LaunchAgents', | |
) | |
writePlist(la_plist, service_la) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment