OpenVPN for WAPT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
3.1 KiB

# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
variables = {}
# Read local variables file if available
if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')):
print('Reading local encrypted variables file')
from cryptography.fernet import Fernet
import yaml
f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read())
def install():
import re
version = control['version'].split('-',1)[0]
print('Register OpenVPN as a trusted publisher')
run(r'certutil.exe -f -addstore trustedpublisher openvpn.p7b')
print('Installing OpenVPN client')
os_version = 'Win10'
# We need to identify the build
for file in glob.glob('openvpn-install-%s-I*-%s.exe' % (version, os_version)):
build ='openvpn\-install\-%s\-(I\d+)\-%s\.exe' % (version, os_version), file).group(1)
install_exe_if_needed('openvpn-install-%s-%s-%s.exe' % (version, build, os_version), '/S', key='OpenVPN', min_version='%s-%s-%s' % (version, build, os_version), killbefore=['openvpn','openvpn-gui'])
if 'openvpn_config' in variables:
print('Deploying client configuration')
def update_package():
import re, os
from waptpackage import PackageEntry
print('Updating OpenVPN package')
page = wgets('')
latest_version ='OpenVPN (\d+(\.\d+)*) .* Released', page).group(1)
pe = PackageEntry()
control = pe.load_control_from_wapt(os.getcwd())
current_version = control['version'].split('-',1)[0]
if Version(latest_version) > Version(current_version):
print('Updating Package from %s to %s' % (current_version, latest_version))
# Win7 Would be possible, but has a problem installing the tap driver, even when the cert is added to the trust store
# Just maintain the package for Win10 and later. Win7 is EOL in 2020 anyway
for os_version in ['Win10']:
build ='OpenVPN\-%s\-(I\d+)\-%s\.msi' % (latest_version, os_version), page).group(1)
if not isfile('OpenVPN-%s-%s.msi' % (latest_version, build)):
url = '' % (latest_version, build, os_version)
print('downloading %s' % url)
wget(url, os.getcwd())
for file in glob.glob('*%s.msi' % os_version):
if file != 'OpenVPN-%s-%s-%s.msi' % (latest_version, build, os_version):
print('Removing %s' % file)
pe.version = latest_version + '-0'
pe.maturity = 'PREPROD'
print('Package updated to %s' % latest_version)
print('No update available')
if __name__ == '__main__':