Hey,
I have a problem with my TeamViewer Installation script.
The download and installation part works great, but the assignment isnt working reliable.
I have followed the steps from here: https://community.teamviewer.com/English/kb/articles/50739-mass-deployment-on-macos
I have added a 'sleep' and increased the '-wait' parameter, both without success.
Sometimes it works, sometimes it does not.
Is there a more reliable way to assign the device in TeamViewer?
Here is my script:
#!/bin/zsh
#
# Downloads and installs latest TeamViewer Host with custom configuration
# Runs the TeamViewer Assignment Tool after the installation
# Provide configuration details via jamf parameter:#
# Parameter $4 = Teamviewer configuration ID
# Parameter $5 = Teamviewer assignment API token
#
# Created 16. March 2021
#
#
#
# Precheck - configuration id
if [[ -z $4 ]]; then
echo "$(date): No teamviewer configuration id provided."
exit 1
else
tv_customID="$4"
fi
# Precheck - assignment api token
if [[ -z $5 ]]; then
echo "$(date): No teamviewer api token provided."
exit 1
else
tv_apiToken="$5"
fi
# Generate url with confiugration id
downloadUrl="https://dl.teamviewer.com/download/version_15x/CustomDesign/Install%20TeamViewerHost-idc$tv_customID.pkg"
# Choices xml for silent installation
choices_xml=$(
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>attributeSetting</key>
<integer>1</integer>
<key>choiceAttribute</key>
<string>selected</string>
<key>choiceIdentifier</key>
<string>com.teamviewer.teamviewerSilentInstaller</string>
</dict>
</array>
</plist>
EOF
)
# Create working directory
# stolen from here: https://gist.github.com/talkingmoose/a16ca849416ce5ce89316bacd75fc91a
echo "$(date): Creating working directory"
workDirectory=$( /usr/bin/basename $0 )
tempDirectory=$( /usr/bin/mktemp -d "/private/tmp/$workDirectory.XXXXXX" )
downloadFilePath="TeamviewerHost-idc$tv_customID.pkg"
# change directory to temporary working directory
echo "Changing directory to working directory "$tempDirectory""
cd "$tempDirectory"
# Download
echo "$(date): Downloading Teamviewer Host Application"
/usr/bin/curl --location --silent -o "$downloadFilePath" "$downloadUrl"
# Preparation
echo "$(date): Creating choices.xml"
echo "$choices_xml" > "choices.xml"
# Installation
echo "$(date): Installing Teamviewer Host Application"
echo "$(date): .pkg path: $downloadFilePath"
/usr/sbin/installer -pkg "$downloadFilePath" -applyChoiceChangesXML "choices.xml" -target /
sleep 30
# Assignment
echo "$(date): Run Teamviewer assignment"
tv_assignmentHelper="/Applications/TeamViewerHost.app/Contents/Helpers/TeamViewer_Assignment"
tv_hostname="$(hostname -s) | $(id -P $(stat -f%Su /dev/console) | cut -d : -f 8)"
${tv_assignmentHelper} -api-token "$tv_apiToken" -alias "$tv_hostname" -wait 60
# clean up
echo "$(date): Cleanup"
/bin/rm -Rf "$tempDirectory"
Any help is appreciated,
Greetings
Martin
