wapt-tightvnc-server/setup.py

60 lines
2.3 KiB
Python

# -*- coding: utf-8 -*-
from setuphelpers import *
import re
uninstallkey = []
variables = {
#'vnc_pass': 's3cr3t',
#'vnc_admin_pass': 'p@ssw0rd',
#'vnc_allowed_ip': ['1.2.3.4','192.168.2.1-192.168.2.10']
}
# 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():
print('Installing TightVNC Server')
version = control['version'].split('-',1)[0]
if iswin64():
msi = 'tightvnc-%s-gpl-setup-64bit.msi' % version
else:
msi = 'tightvnc-%s-gpl-setup-32bit.msi' % version
props = {
'ADDLOCAL': 'Server',
'SET_ACCEPTHTTPCONNECTIONS': 1,
'VALUE_OF_ACCEPTHTTPCONNECTIONS': 0,
'SET_ACCEPTRFBCONNECTIONS': 1,
'VALUE_OF_ACCEPTRFBCONNECTIONS': 1,
'SET_LOGLEVEL': 1,
'VALUE_OF_LOGLEVEL': 3,
'SET_REMOVEWALLPAPER': 1,
'VALUE_OF_REMOVEWALLPAPER': 0
}
if 'vnc_allowed_ip' in variables:
print('Access will be restricted to %s' % ','.join(variables['vnc_allowed_ip']))
props['SET_IPACCESSCONTROL'] = 1,
props['VALUE_OF_IPACCESSCONTROL'] = ','.join( '%s-%s:0' % (ip,ip) if not re.search('\-',ip) else '%s:0' % ip for ip in ensure_list(variables['vnc_allowed_ip']) )
if 'vnc_pass' in variables:
print('Setting VNC password')
props['SET_USEVNCAUTHENTICATION'] = 1
props['VALUE_OF_USEVNCAUTHENTICATION'] = 1
props['SET_PASSWORD'] = 1
props['VALUE_OF_PASSWORD'] = variables['vnc_pass']
props['SET_USEVNCAUTHENTICATION'] = 1
if 'vnc_admin_pass' in variables:
print('Setting VNC control password')
props['SET_USECONTROLAUTHENTICATION'] = 1
props['VALUE_OF_USECONTROLAUTHENTICATION'] = 1
props['SET_CONTROLPASSWORD'] = 1
props['VALUE_OF_CONTROLPASSWORD'] = variables['vnc_admin_pass']
install_msi_if_needed(msi,min_version=version,properties=props)