Compare commits

...

10 Commits

Author SHA1 Message Date
Daniel Berteaud 003062a217 Fork GLPI Agent from fusioninventory agent 2023-03-27 13:08:40 +02:00
Daniel Berteaud c126c6a4d3 Add missing binaries for 2.6 2020-11-26 19:19:44 +01:00
Daniel Berteaud 6df0fd134e Update to 2.6 2020-11-26 18:39:22 +01:00
Daniel Berteaud 40e5a5fe87 Update to 2.5.2 2019-12-16 18:54:13 +01:00
Daniel Berteaud 6469634aac Ignore WAPT build files 2019-10-23 15:44:09 +02:00
Daniel Berteaud 296b36bbb8 Update to 2.5.2 2019-07-02 17:19:23 +02:00
Daniel Berteaud 68f376c681 Update to 2.5 2019-04-17 18:56:29 +02:00
Daniel Berteaud 29d1eecdc7 Rewrite the update_package, cleaner 2019-04-17 18:45:43 +02:00
Daniel Berteaud 9a9aeb6b7e Update to 2.4.3 2019-02-26 10:47:37 +01:00
Daniel Berteaud 6efc37b8e2 Use YAML formatted variable file 2018-12-20 13:15:42 +01:00
8 changed files with 92 additions and 87 deletions

1
.gitattributes vendored
View File

@ -1 +1,2 @@
*.exe filter=lfs diff=lfs merge=lfs -text
*.msi filter=lfs diff=lfs merge=lfs -text

3
.gitignore vendored
View File

@ -94,3 +94,6 @@ ENV/
# Rope project settings
.ropeproject
WAPT/certificate.crt
WAPT/manifest.sha256
WAPT/signature.sha256

BIN
GLPI-Agent-1.4-x64.msi (Stored with Git LFS) Normal file

Binary file not shown.

BIN
GLPI-Agent-1.4-x86.msi (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1,32 +1,44 @@
package : fws-fusioninventory
version : 2.4.2-11
package : eht-glpi-agent
version : 1.4-3
architecture : all
section : base
priority : optional
maintainer : Daniel Berteaud
description : FusionInventory is a computer inventory agent
name :
categories :
maintainer : Daniel Berteaud <dbd@ehtrace.com>
description : GLPI Agent is a computer inventory agent
depends :
conflicts :
maturity : PROD
locale : all
target_os : windows
min_os_version : 5.0
max_os_version :
min_wapt_version : 1.3.12
sources :
installed_size :
impacted_process :
description_fr : FusionInventory est un agent d'inventaire d'ordinateurs
description_fr : L'agent GLPI est un agent d'inventaire d'ordinateurs
description_pl :
description_de :
description_es :
description_pt :
description_it :
description_nl :
description_ru :
audit_schedule : 2d
editor :
keywords : inventory
licence : GPLv2+
homepage : http://fusioninventory.org/
package_uuid :
signer :
signer_fingerprint:
signature_date :
signed_attributes :
homepage : http://glpi-project.org/
package_uuid : 6248be43-0eca-41e8-8669-715b2a11a891
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version : 5.0
max_os_version :
icon_sha256sum : fba3af4f79be43de12a5f9438a98831edc7a08c5761e5f216eb9d9ca5d98b3ff
signer : dbd
signer_fingerprint: e9156ec73f1ea6b50f33e0d9f580e8ae56db147100894bb5d2d4648a46f07ed1
signature : tFm2L6g17bG0buZW6ZeKFk0tJrBbx5R+rPNoxyEip1QTtbaV3ulI3OLyoOZdeK16f+9W4w2hDYNghV4Hd5KnEXL7DpW/JELwaomyoJr2Jq8j4mIKVmEok48rApssOm/iwtPs+kseRtv3Yi6sEHlYg7yqzndIgIWxtQq48GkYwephCsdZEV/RH0uixE1XDf36d6Z4PlxHILZ68o1JOxbCE/rKa6S1kunxnLNsV3eg3YF1ALVj65Wovr3raJsLFOoqRp87a6uxnHViNtIjscR5DlhXGCQqqEpMWcGY6KNBsU86aOG3GqnlcNjvKKvwOgyYNLxZvO4fiNVNXmqR5tLVKg==
signature_date : 2023-03-27T12:54:25.342941
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes

Binary file not shown.

Binary file not shown.

125
setup.py
View File

@ -1,104 +1,93 @@
# -*- coding: utf-8 -*-
from setuphelpers import *
from cryptography.fernet import Fernet
import json
uninstallkey = []
variables = {
'fusinv_servers': [ 'https://glpi.lan.local/plugins/fusioninventory' ]
'glpi_inv_servers': [ 'https://glpi.lan.local/front/inventory.php' ]
}
# 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')
f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read())
variables.update(json.loads(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read())))
from cryptography.fernet import Fernet
import yaml
f = Fernet(bytes(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read(), 'utf-8'))
variables.update(yaml.safe_load(f.decrypt(bytes(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read(), 'utf-8'))))
def install():
parameters = '/S /acceptlicense /server="%s" /execmode=service /runnow' % (','.join(variables['fusinv_servers']))
if 'fusinv_user' in variables and 'fusinv_pass' in variables:
parameters = parameters + ' /user="%s" /password="%s"' % (variables['fusinv_user'],variables['fusinv_pass'])
props = {
'ADDLOCAL': 'feat_AGENT',
'HTTPD_IP': '127.0.0.1',
'NO_P2P': '1',
'RUNNOW': '1'
}
if 'glpi_inv_servers' in variables:
print('Found servers %s in settings' % (','.join(variables['glpi_inv_servers']))
props['SERVER'] = ','.join(variables['glpi_inv_servers'])
print('Installing FusionInventory Agent')
versionpaquet = control['version'].split('-',1)[0]
if 'glpi_inv_user' in variables and 'glpi_inv_pass' in variables:
print('Found user % in settings' % variables['glpi_inv_user'])
props['USER'] = variables['glpi_inv_user']
props['PASSWORD'] = variables['glpi_inv_pass']
print('Installing GLPI Agent')
version = 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)
msi = 'GLPI-Agent-1.4-x64.msi'
else:
install_exe_if_needed("fusioninventory-agent_windows-x86_%s.exe" % versionpaquet,parameters,key='FusionInventory-Agent',min_version=versionpaquet)
msi = 'GLPI-Agent-1.4-x86.msi'
install_msi_if_needed(msi,min_version=version,properties=props)
def update_package():
import BeautifulSoup,requests,re
print('Updating GLPI Agent package')
import requests,json
from waptpackage import PackageEntry
verify=True
pe = PackageEntry()
pe.load_control_from_wapt(os.getcwd())
current_version = pe['version'].split('-',1)[0]
verify=True
url = 'https://github.com/fusioninventory/fusioninventory-agent/releases'
import requests,BeautifulSoup
page = requests.get(url + '/latest',headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'},verify=verify).text
bs = BeautifulSoup.BeautifulSoup(page)
bs_raw_string = str(bs.find('span',{'class':'css-truncate-target'}).text)
version = bs_raw_string
url64 = url + "/download/" + version + "/fusioninventory-agent_windows-x64_%s.exe" % version
url86 = url + "/download/" + version + "/fusioninventory-agent_windows-x86_%s.exe" % version
filenamex86 = "fusioninventory-agent_windows-x86_%s.exe" % version
filenamex64 = "fusioninventory-agent_windows-x64_%s.exe" % version
if not isfile( filenamex64 ) :
wget( url64 )
if not isfile( filenamex86 ) :
wget( url86 )
for fileexe in glob.glob('fusioninventory-agent_windows-x64*.exe'):
if fileexe != filenamex64 :
print('Delete ' + fileexe)
remove_file(fileexe)
for fileexe in glob.glob('fusioninventory-agent_windows-x86*.exe'):
if fileexe != filenamex86 :
print('Delete ' + fileexe)
remove_file(fileexe)
if not isfile(filenamex64):
print('Download ' + url64)
wget(url64,filenamex64)
if not isfile(filenamex86):
print('Download ' + url86)
wget(url86,filenamex86)
latest = json.loads(requests.get('https://api.github.com/repos/glpi-project/glpi-agent/releases/latest').text.encode('utf-8'))
version = latest['tag_name']
pe = PackageEntry();
control = pe.load_control_from_wapt('.')
bin_found = []
for arch in ['86','64']:
for asset in latest['assets']:
if asset['name'] == 'GLPI-Agent-x%s-%s.msi' % (version, arch) and not isfile('GLPI-Agent-x%s-%s.msi' % (version, arch)):
url = asset['browser_download_url']
print('Downloading GLPI Agent %s for x%s from %s' % (version, arch ,url))
wget(url,'GLPI-Agent-x%s-%s.msi' % (version, arch))
bin_found.append(arch)
for file in glob.glob('GLPI-Agent-x*-%s.msi' % arch):
if file != 'GLPI-Agent-x%s-%s.msi' % (version, arch):
print('Removing %s' % file)
remove_file(file)
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('.')
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")
if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','GLPI-Agent'),'server'):
print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\GLPI-Agent\server doesn't exist")
return "ERROR"
val_server = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'server')
val_server = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','GLPI-Agent'),'server')
if val_server != ','.join(variables['fusinv_servers']) :
print("server config is not %, it's % instead" % (','.join(variables['fusinv_servers']), val_server) )
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")
if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','GLPI-Agent'),'user'):
print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\GLPI-Agent\user doesn't exist")
return "ERROR"
val_user = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'user')
val_user = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','GLPI-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")
if not registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','GLPI-Agent'),'password'):
print(r"key HKEY_LOCAL_MACHINE\SOFTWARE\GLPI-Agent\password doesn't exist")
return "ERROR"
val_pass = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','FusionInventory-Agent'),'password')
val_pass = registry_readstring(HKEY_LOCAL_MACHINE,makepath('SOFTWARE','GLPI-Agent'),'password')
if val_pass != variables['fusinv_pass'] :
print("password doesn't match what's set")
return "WARNING"