FusionInventory Agent WAPT package
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.

86 lines
4.5 KiB

# -*- coding: utf-8 -*-
from setuphelpers import *
uninstallkey = []
variables = {
'fusinv_servers': [ 'https://glpi.lan.local/plugins/fusioninventory' ]
}
# 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())))
6 years ago
def install():
parameters = '/S /acceptlicense /server="%s" /execmode=service /runnow' % (','.join(variables['fusinv_servers']))
6 years ago
if 'fusinv_user' in variables and 'fusinv_pass' in variables:
parameters = parameters + ' /user="%s" /password="%s"' % (variables['fusinv_user'],variables['fusinv_pass'])
print('Installing FusionInventory Agent')
6 years ago
versionpaquet = control['version'].split('-',1)[0]
if iswin64():
install_exe_if_needed("fusioninventory-agent_windows-x64_%s.exe" % versionpaquet,parameters,key='FusionInventory-Agent',min_version=versionpaquet)
6 years ago
else:
install_exe_if_needed("fusioninventory-agent_windows-x86_%s.exe" % versionpaquet,parameters,key='FusionInventory-Agent',min_version=versionpaquet)
def update_package():
print('Updating FusionInventory Agent package')
import requests,json
latest = json.loads(requests.get('https://api.github.com/repos/fusioninventory/fusioninventory-agent/releases/latest').text.encode('utf-8'))
version = latest['tag_name']
pe = PackageEntry();
control = pe.load_control_from_wapt('.')
5 years ago
bin_found = []
for arch in ['86','64']:
for asset in latest['assets']:
if asset['name'] == 'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version) and not isfile('fusioninventory-agent_windows-x%s_%s.exe' % (arch, version)):
url = asset['browser_download_url']
print('Downloading FusionInventory Agent %s for x%s from %s' % (version,arch,url))
wget(url,'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version))
5 years ago
bin_found.append(arch)
for file in glob.glob('fusioninventory-agent_windows-%s_*.exe' % arch):
if file != 'fusioninventory-agent_windows-x%s_%s.exe' % (arch, version):
print('Removing %s' % file)
remove_file(file)
5 years ago
if Version(version) > Version(control['version'].split('-',1)[0]) and '86' in bin_found and '64' in bin_found:
print('Updating control file with new version %s' % version)
pe.version = version + '-0'
pe.maturity = 'PREPROD'
pe.save_control_to_wapt('.')
6 years ago
def audit():
if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'server'):
print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent\server doesn't exist")
return "ERROR"
val_server = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'server')
if val_server != ','.join(variables['fusinv_servers']) :
print("server config is not %, it's % instead" % (','.join(variables['fusinv_servers']), val_server) )
6 years ago
return "WARNING"
if 'fusinv_user' in variables and 'fusinv_pass' in variables:
if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'user'):
print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent\user doesn't exist")
return "ERROR"
val_user = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'user')
if val_user != variables['fusinv_user'] :
print("user config is not %s, it's %s instead" % (variables['fusinv_user'],val_user) )
return "WARNING"
if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'password'):
print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\FusionInventory-Agent\password doesn't exist")
return "ERROR"
val_pass = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'password')
if val_pass != variables['fusinv_pass'] :
print("password doesn't match what's set")
return "WARNING"
return "OK"
if __name__ == '__main__':
update_package()