Skip to content

Instantly share code, notes, and snippets.

@koter84
Last active February 21, 2017 10:17
Show Gist options
  • Save koter84/8ef9d87e4753f9e4f7e53e6a480db898 to your computer and use it in GitHub Desktop.
Save koter84/8ef9d87e4753f9e4f7e53e6a480db898 to your computer and use it in GitHub Desktop.
download the stand-alone version of teamviewer and link the desktop-file
#!/bin/bash
# get current dir
prog_dir="/opt/$(ls /opt/ | grep teamviewer | grep -v tar)"
if [ "$prog_dir" == "/opt/" ]
then
prog_dir=""
fi
echo "DIR: $prog_dir"
if [ -f $prog_dir/teamviewer ]
then
prog_dir_version=$(${prog_dir}/teamviewer --version|grep TeamViewer|awk '{ print $4 }')
fi
echo "DIR Version: $prog_dir_version"
# get current url
prog_url="https://download.teamviewer.com/download/teamviewer_i386.tar.xz"
echo "URL: $prog_url"
prog_url_version=$(curl -s https://www.teamviewer.com/nl/download/linux/ | sed 's/<p/\n<p/g' | grep DownloadVersion | grep 'tar\.xz' | cut -d">" -f2 | awk '{ print $1 }' | sed s/'v'//)
echo "URL Version: $prog_url_version"
#prog_url_dir=$(echo $prog_url | awk -F/ '{print $NF}' | cut -d"/" -f-1 | sed s/'-linux64.tar.xz'// )
#echo "URL Dir: $prog_url_dir"
# check that a current version is found
if [ "$prog_dir_version" == "" ]
then
echo "New Installation! (no old version found)"
new_install="1"
fi
# check that a new version and url are found
if [ "$prog_url" == "" ] || [ "$prog_url_version" == "" ]
then
echo "couldn't find url for new version"
exit
fi
# check current dir version with current url version
if [ "$prog_dir_version" != "$prog_url_version" ]
then
if [ "$new_install" != "1" ]
then
echo "New Version Found!"
fi
cd /opt/
# download
wget --quiet --show-progress -O teamviewer.new.tar.xz "$prog_url"
# remove current dir
if [ -d /opt/teamviewer ]
then
rm -r /opt/teamviewer
fi
# unpack
tar -xf teamviewer.new.tar.xz
# remove download
rm teamviewer.new.tar.xz
# install desktop shortcut, menu item and file associations
cp /opt/teamviewer/tv_bin/desktop/teamviewer.desktop.template $HOME/.local/share/applications/teamviewer.desktop
sed -i s:"EXEC":"/opt/teamviewer/tv_bin/script/teamviewer": $HOME/.local/share/applications/teamviewer.desktop
sed -i s:"ICON":"/opt/teamviewer/tv_bin/desktop/teamviewer.png": $HOME/.local/share/applications/teamviewer.desktop
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment