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.
57 lines
2.4 KiB
57 lines
2.4 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())
|
|
variables.update(yaml.safe_load(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read())))
|
|
|
|
def install():
|
|
version = control['version'].split('-',1)[0]
|
|
|
|
print('Register OpenVPN as a trusted publisher')
|
|
run(r'certutil.exe -addstore trustedpublisher openvpn.p7b')
|
|
|
|
print('Installing OpenVPN client')
|
|
install_exe_if_needed('openvpn-install-%s-I602.exe' % version,'/S',key='OpenVPN',min_version='%s-I602' % version,killbefore=['openvpn','openvpn-gui'])
|
|
uninstallkey.append('TAP-Windows')
|
|
|
|
if 'openvpn_config' in variables:
|
|
print('Deploying client configuration')
|
|
open(makepath(programfiles,'OpenVPN','config','vpn.ovpn'),'w').write(variables['openvpn_config'])
|
|
|
|
def update_package():
|
|
import re, os
|
|
from waptpackage import PackageEntry
|
|
print('Updating OpenVPN package')
|
|
page = wgets('https://openvpn.net/community-downloads/')
|
|
latest_version = re.search('OpenVPN (\d+(\.\d+)*) .* released on', 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))
|
|
if not isfile('openvpn-install-%s-I602.exe' % latest_version):
|
|
url = 'https://swupdate.openvpn.org/community/releases/openvpn-install-%s-I602.exe' % latest_version
|
|
print('downloading %s' % url)
|
|
wget(url, os.getcwd())
|
|
for file in glob.glob('*.exe'):
|
|
if file != 'openvpn-install-%s-I602.exe' % latest_version:
|
|
print('Removing %s' % file)
|
|
remove_file(file)
|
|
pe.version = latest_version + '-0'
|
|
pe.save_control_to_wapt(os.getcwd())
|
|
print('Package updated to %s' % latest_version)
|
|
else:
|
|
print('No update available')
|
|
|
|
|
|
if __name__ == '__main__':
|
|
update_package()
|
|
|
|
|