Skip to content

Instantly share code, notes, and snippets.

@ismet55555
Last active February 4, 2023 16:48
Show Gist options
  • Save ismet55555/58e4ed56d502ec74cf8620d2302afd8b to your computer and use it in GitHub Desktop.
Save ismet55555/58e4ed56d502ec74cf8620d2302afd8b to your computer and use it in GitHub Desktop.
Setting up Teamviewer Client via Terminal
#!/bin/bash
###############################################################################
#
# This script downloads, installs, and sets teamviewer up
# via the Terminal.
# Note, that this installation is via .deb packages
# used on Debian-based systems such as Ubuntu
#
# More system architecture options:
# - https://www.teamviewer.com/en/download
#
# Usage:
# - sudo chmod +x teamviewer_client_setup.sh
# - sudo ./teamviewer_client_setup.sh <REMOTE PASSWORD> <DOWNLOAD LINK>
#
# Remote Password Rules:
# 1. At least 8 characters long
# 2. Contains at least one letter and one number
# 3. MUST NOT have any special characters, spaces,
# uppercase letters
#
###############################################################################
set -e
# Check input
if [ "$1" = "" ]; then
echo "ERROR: No teamviewer client password provided as argument"
exit 1
fi
# Check password rule
INPUT_ERROR=false
if [[ ${#1} -lt 8 ]]; then
echo "ERROR: Input password is less than 8 characters long"
INPUT_ERROR=true
fi
if [[ ! "$1" =~ ^[a-z0-9]+$ ]]; then
echo "ERROR: Input password contains characters not lowercase letters or numbers"
INPUT_ERROR=true
fi
if [ "$INPUT_ERROR" = true ]; then
echo "ERROR: Password does not conform to password rules:"
echo "ERROR: 1. At least 8 characters long"
echo "ERROR: 2. Contains only lower case letters and numbers"
exit 1
fi
TW_DOWNLOAD_LINK=${2:-"https://download.teamviewer.com/download/linux/teamviewer_amd64.deb"}
###########################################################################
# Download installation file
echo "Downloading teamviewer installation file from URL: ${TW_DOWNLOAD_LINK} ..."
curl -k -L -s -S "$TW_DOWNLOAD_LINK" --output teamviewer.deb
# Install
echo "Installing teamviewer ..."
apt -qq install ./teamviewer.deb -y
rm teamviewer.deb
# Accept Eula license
echo "Accepting EULA license ..."
echo "[int32] EulaAccepted = 1" | sudo tee -a /opt/teamviewer/config/global.conf
teamviewer license accept || echo "WARNING: License agreement already accepted"
# Set always online
echo "Setting teamviewer as always online ..."
echo "[int32] Always_Online = 1" | sudo tee -a /opt/teamviewer/config/global.conf
echo "Setting teamviewer client password ..."
teamviewer passwd "$1"
sleep 2
# Enable and start daemon service
echo "Restarting and enabling teamviewer daemon service ..."
teamviewer daemon start
sleep 2
teamviewer daemon enable
sleep 2
# Show Teamviewer ID
echo
TW_ID=$(teamviewer info | awk '/TeamViewer ID:/ {print $NF}')
echo "======================================="
echo "Teamviewer Client ID: ${TW_ID}"
echo "Password: SET"
echo "======================================="
# Start teamviewer UI
echo
echo "Starting Teamviewer UI ..."
su $SUDO_USER -c "nohup teamviewer &"
echo
echo "DONE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment