[SOLVED] Script proposal for RustDesk

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

August 8, 2024 - 11:11

Good morning,


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")


System and Network Administrator at Domitia Habitat
rmaurisso
Messages: 4
Registration: January 12, 2021 - 5:12 PM

August 14, 2024 - 09:34

Hello,
thank you @jlatieule for this script.
When using external tools in wapt, is it possible to use "rustdesk_id" as an argument? This would simplify the connection to the selected computer (as TightVNC would).
Thank you.
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

August 14, 2024 - 8:50 PM

For now, I don't know how to retrieve the ID displayed in the installation logs to feed into wapt.

By default, I've enabled IP address-based login. It works perfectly with external wapt tools.

P.S.: GDPR reminder: no connection without the user's consent. The permanent password available in the logs is only for system maintenance when no user is logged in.
System and Network Administrator at Domitia Habitat
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

August 22, 2024 - 6:05 PM

Hello @jlatieule,

thank you for your suggestion.

I've started working on RustDesk.

There are three packages:

tis-rustdesk-server (to install the RustDesk server on Linux or Windows)

, tis-rustdesk (to install the RustDesk agent on Linux, Windows, or Mac without configuration),

and tis-rustdesk-config-template (configures the RustDesk agent; requires running an update package to provide the configuration).

The random password is transmitted in encrypted form.

We'll look into adding a small native integration to the right-click menu to simplify its use. ;)
jlatieule
Messages: 59
Registration: July 3, 2019 - 9:18 AM

August 22, 2024 - 6:44 PM

Excellent, Simon! I'm very curious to see the server side of things. We had to do some research to optimize the installation on Debian.

When I get back from vacation, I can send you my server installation procedure; perhaps you'll find some tips on how to set it up... let me know which communication method you prefer.

PS: When I was an IT specialist at Victor Hugo middle school in Narbonne, I contributed to the forum under the pseudonym "percherie." I imagine you remember me, and like back then, I sincerely believe in sharing to help the community move forward.
System and Network Administrator at Domitia Habitat
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

August 23, 2024 - 09:57

jlatieule wrote: August 22, 2024 - 6:44 PM PS: When I was an ICT specialist at Victor Hugo Middle School in Narbonne, I contributed to the forum under the pseudonym percherie. I imagine you remember me, and like back then, I sincerely believe in sharing to move the collective forward.
Of course I remember ;)If you're ever in Nantes, come see us, I'd love to hear from you (I'm not often in Narbonne) :D )
jlatieule wrote: August 22, 2024 - 6:44 PM I'm very curious to see the server side. We had to do some research to optimize the installation on Debian.
Nothing extraordinary, I just reproduced the Python script found in their documentation and here: https://github.com/techahold/rustdeskin ... install.sh

And for the Windows server, I just replaced nssm with angelize

And for the rustdesk macos client, it's not great in my tests, we'll probably have to come back to it.
rmaurisso
Messages: 4
Registration: January 12, 2021 - 5:12 PM

September 5, 2024 - 4:10 PM

Hello,
thank you both.
It works well for external tools with the IP address and for the template. ;)
User avatar
dcardon
WAPT Expert
Messages: 1932
Registration: June 18, 2014 - 09:58
Location: Saint Sébastien sur Loire
Contact :

September 9, 2024 - 3:46 PM

Hello Régis,

thank you for the feedback. :-) I'm marking the topic as resolved.

Regards,

Denis
Denis Cardon - Tranquil IT
Share your experiences on WAPT! Send us your blog and article URLs in the "Your Opinion of the forum, and we'll feature them on the WAPT
Locked