As a replacement for TeamViewer, we use a RustDesk server accessible only to our workstations. It's a private relay.
For installing a private relay, you have a great installation and update script on https://github.com/techahold/rustdeskinstall
I need to update all clients to the new version.
For this purpose, I created the following package (see code at the end of the message)... installation is done using the EXE format: rustdesk-1.2.7-x86_64.exe
After installation, I modify two options before restarting the service.
This section is completely unoptimized, and I've commented on what's missing
However, since RustDesk handles it well (multiple test scenarios), I'll stop there for now
The update_package, uninstall, and audit files are missing
Denis or Simon, could you take ownership of this and add it to the store so that it can be reused by others?
I certainly assume that you will be more comfortable than me with finalizing the "options" section more neatly and with managing the update_package (I have indicated the URL to query)
Thank you in advance
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
import time, string, secrets
r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
# Création d'un mot de passe aléatoire
alphabet = string.ascii_letters + string.digits
rustdesk_pw = ''.join(secrets.choice(alphabet) for i in range(12))
# Configuration réseau pour RustDesk à importer
# Si vide ou invalide, la configuration réseau restera inchangée
rustdesk_cfg = "METTEZ-VOTRE-CONFIG-ENTRE-LES-GUILLEMETS"
def install():
# Récupération de l'exécutable
bin_name = glob.glob("rustdesk-*.exe")[0]
# Désactivé car pas de détection de fin d'installation
## install_exe_if_needed(
## bin_name,
## silentflags="--silent-install",
## key="RustDesk",
## min_version=control.get_software_version(),
## )
# Méthode manuelle
# Si n'est pas installé ou version est inférieure à celle du paquet
if ( not installed_softwares ('rustdesk') or
Version(installed_softwares('rustdesk')[0]["version"]) < Version(control['version'].split('-',1)[0]) ):
print("Installation de %s %s" % ( control['name'], control['version'].split('-',1)[0] ) )
# Timeout pour sortir sans erreur... ajouter une pause de 10s si on n'utilise plus cette méthode
run_notfatal( '%s --silent-install' % (bin_name), timeout=15 )
else:
print("%s %s est déjà installé" % ( control['name'], control['version'].split('-',1)[0] ) )
# Récupération du dossier d'installation
software = installed_softwares ('rustdesk')
install_location = software[0]["install_location"]
# Exécution ou installation du service
if service_installed ("rustdesk"):
if not service_is_running ("rustdesk"):
print ('Démarrage du service')
service_start('rustdesk')
else:
print ("Installation du service RustDesk")
run_notfatal( '"%s\\rustdesk.exe" --install-service -wait -Verbose' % (install_location), timeout = 20 )
print("Patientez quelques secondes avant que l'installation se poursuive")
time.sleep(10)
print("Application de la configuration réseau")
run_notfatal( '"%s\\rustdesk.exe" --config %s' % (install_location, rustdesk_cfg) )
print("Définition d'un mot de passe permanent aléatoire")
run( '"%s\\rustdesk.exe" --password %s' % (install_location, rustdesk_pw) )
# ID de RustDesk
rustdesk_id = run_notfatal( '"%s\\rustdesk.exe" --get-id' % (install_location) )
# Arrêt du service Rustdesk pour modifications des options
if service_installed("rustdesk"):
if service_is_running("rustdesk"):
print("Arrêt du service Rustdesk")
service_stop("rustdesk")
# Ajout d'option personnalisé à la configuration
# inifile_writestring ne peut pas être utiliser suite à mauvaise en-tête dans le fichier
# En cas de ligne en doublon dans le fichier RustDesk2.toml, les dernières seront prise en compte... mais pas toujours !!!
# Point d'amélioration :
# Supprimer les fichier %appdata%\RustDesk\config de tous les profile
# Chercher et remplacer les chaînes concernée
# Si absent, créer les chaînes au lieu de le faire systématiquement
toml = makepath("c:", "Windows", "ServiceProfiles", "LocalService", "AppData", "Roaming", "RustDesk", "config", "RustDesk2.toml")
f = open( toml, 'a')
f.write("\n" + "direct-server = 'Y'")
f.write("\n" + "direct-access-port = '21118'")
f.close
# Redémarrage du service Rustdesk
if service_installed("rustdesk"):
if service_is_stopped("rustdesk"):
print("Démarrage du service RustDesk")
service_start("rustdesk")
else:
print ("Installation du service RustDesk")
run_notfatal( '"%s\\rustdesk.exe" --install-service -wait -Verbose' % (install_location), timeout = 20 )
# Retour sur la console de l'ID et du mot de passe permanent
print ( "-------------------" )
print ( "ID RustDesk : %s" % rustdesk_id )
print ( "Mot de passe : %s" % rustdesk_pw )
print ( "-------------------" )
def session_setup():
# Créer le session_setup
def update_package():
# Créer l'update package
# curl latest sur https://www.github.com//rustdesk/rustdesk/releases/latest
# fichier lastest avec $RDLATEST sur https://github.com/rustdesk/rustdesk/releases/download/$RDLATEST/rustdesk-$RDLATEST-x86_64.exe
def uninstall():
# Créer l'uninstall
def audit():
# Créer l'audit
# Vérifier si service fonctionne
# Vérifier configuration dans makepath("c:", "Windows", "ServiceProfiles", "LocalService", "AppData", "Roaming", "RustDesk", "config", "RustDesk2.toml")
