Je me permet de proposer mon code pour le logiciel Stormshield SSL VPN, je me suis basé sur les différents topic qui ont été fait à ce sujet ( 3515, 3628 )
Coté installation, j'ai seulement apporter quelques petite modifications :
Code : Tout sélectionner
# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
"""
FIREWALL_IP_ADDRESS = "YOUR_IP_ADDRESS_OR_DNS"
stormshield_folder = makepath(programfiles64, 'Stormshield\Stormshield SSL VPN Client')
def install():
# Declaring local variables
bin_name = glob.glob("Stormshield*.msi")[0]
# Installing the software
print(f"Installing: {bin_name}")
install_msi_if_needed(
bin_name,
min_version=control.get_software_version()
)
create_programs_menu_shortcut("Stormshield SSL VPN Client", target=makepath(stormshield_folder, 'sslvpn_client.exe'), folder='Stormshield SSL VPN Client')
def session_setup():
# Declaring local variables
CURRENT_USER = os.getlogin()
# Setup Firewall address
registry_set(HKEY_CURRENT_USER, r"Software\\STORMSHIELD\\STORMSHIELD SSL VPN CLIENT", "address", FIREWALL_IP_ADDRESS, type=REG_SZ)
registry_set(HKEY_CURRENT_USER, r'Software\\STORMSHIELD\\STORMSHIELD SSL VPN CLIENT', 'automatic', 'true', type=REG_SZ)
registry_set(HKEY_CURRENT_USER, r'Software\\STORMSHIELD\\STORMSHIELD SSL VPN CLIENT', 'username', CURRENT_USER, type=REG_SZ)
# Needed ?
#mkdirs(makepath(user_local_appdata, 'Stormshield\Stormshield SSL VPN Client\config'))
#run(makepath(stormshield_folder, 'scripts\generate_ovpn_auth.bat'))
def uninstall():
remove_programs_menu_folder('Stormshield SSL VPN Client')
def audit():
service_name = "Stormshield SSL VPN Service"
service_start_mode = get_service_start_mode(service_name)
service_status = service_is_running(service_name)
if service_start_mode in ["Disabled", "Manual"] and service_status:
print(f"The {service_name} is stopped and prevents the application from working properly.")
return "ERROR"
else:
print(f"The {service_name} service is working properly.")
return "OK"
Code : Tout sélectionner
# -*- coding: utf-8 -*-
from setuphelpers import *
from setupdevhelpers import *
import re
# Constantes
BASE_URL = "https://vpn.stormshield.eu/"
DOWNLOAD_FILE_PATTERN = "_win10_fr_x64.msi"
def update_package():
# Declaring local variables
package_updated = False
proxies = get_proxies() or get_proxies_from_wapt_console()
app_name = control.name
# Getting latest download link from official sources
url_version = BASE_URL + "js/app.js"
print(f"URL utilisée : {url_version}")
app_js = wgets(url_version, proxies=proxies).decode('utf-8')
pattern = r"const\s+pathVersionSSLVPN\s*=\s*(.*);"
match = re.search(pattern, app_js)
if match:
path_url = match.group(1).strip("'")
latest_version = path_url.split("_")[-1]
download_url = BASE_URL + path_url + DOWNLOAD_FILE_PATTERN
latest_bin = download_url.split("/")[1]
else:
print("The download URL cannot be found !")
return package_updated
print(f"Latest {app_name} version is: {latest_version}")
print(f"Download URL is: {download_url}")
# Downloading latest binaries
if not isfile(latest_bin):
print(f"Downloading: {latest_bin}")
wget(download_url, latest_bin, proxies=proxies)
else:
print(f"Binary is present: {latest_version}")
# Changing version of the package
if Version(latest_version) > Version(control.get_software_version()):
print(f"Software version updated (from: {control.get_software_version()} to: {Version(latest_version)})")
package_updated = True
else:
print(f"Software version up-to-date ({Version(latest_version)})")
control.set_software_version(latest_version)
control.save_control_to_wapt()
# Deleting outdated binaries
remove_outdated_binaries(latest_version)
# Validating or not update-package-sources
return package_updated
Je pense qu'avant de faire la release, il faut tester le logiciel pour être sur qu'il fonctionne comme attendu ...
Flavien.
Informations générales :
Serveur WAPT : Debian 11, version 2.4.0.14143, Édition Entreprise
Machine d'administration : Windows 11, version WAPT 2.4.0.14143