Détails du package

smp-install-wapt-with-psexec

retour Revenir à la liste des packages

smp-install-wapt-with-psexec

Fichier control :

package           : smp-install-wapt-with-psexec
version           : 23
architecture      : all
section           : base
priority          : optional
name              : 
categories        : 
maintainer        : Simon Fonteneau
description       : F9 in pyscripter for run install with psexec
depends           : 
conflicts         : 
maturity          : NO_FOR_INSTALL_RUN_ONLY
locale            : 
target_os         : 
min_os_version    : 
max_os_version    : 
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      : f0947698-a3c0-489e-8027-0a4c8e4a1027
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 1e54425be03a2a3ea1a264b40d984c31f17a6a489a3b722acb993cbf6561e903
signature         : dwyePHLp4UAlNjKY6nmJBcskjXc5tveEoPzw5tdXR1J4Z9KcK0Pr75ZJENOM0NSlbYKf4J1ue3l8/h+M5ehi0ihemaHx4PIk4geljnYU0XZev7PTdGG2Q7IswDZM1/2lJxq0zV8P9djaTTclNECY0LOEtEqSUVubZ/znpZiFspByms5fpK7NiEv6wdmLMAQTzYGqGTZakfZUls5MiT2VKtEogWgD7wfsYMDwo+rAR+Ggp7bT6+N+upYaoMI6c8bFRuJooJv+XZFDZd65qc4UM7h1Cc1ZEml8jpYZ2U4liAjPu10BTG6blcVSmzLWyXEeXbtNENDoWQJsI5Y/AiwkXQ==
signature_date    : 2020-07-04T11:01:12.909000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,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,signer,signer_fingerprint,signature_date,signed_attributes



Fichier setup.py :

# -*- coding: utf-8 -*-
from setuphelpers import *
import ipaddress
import waptguihelper
import json

uninstallkey = []

timeout = '2'
listplage = [u'192.168.149.0/24',u'192.168.154.0/24']
ipexcluded = ['192.168.149.11','192.168.149.12','192.168.149.254']

def install():
    pass

def install_wapt():
    urlserver = inifile_readstring(makepath(install_location('WAPT_is1'),'wapt-get.ini'),'global','wapt_server').replace('https://','').replace('http://','')
    credential = waptguihelper.login_password_dialog('Credentials for wapt server','https://%s' % urlserver,'admin','')
    htmlpage = json.loads(wgets(r'https://%s:%s@%s/api/v2/waptagent_version' % (credential['user'],credential['password'],urlserver) ))['result']

    while True:
        listhost = data = json.loads(wgets(r'https://%s:%s@%s/api/v1/hosts?columns=connected_ips&limit=10000' % (credential['user'],credential['password'],urlserver)))
        for host in listhost['result']:
            for ip in host['connected_ips']:
                if not ip in ipexcluded:
                    ipexcluded.append(ip)

        userpassword =  waptguihelper.login_password_dialog('Credentials for psexec','Credentials for psexec','MYDOMAIN\Administrateur','')
        argument = '--hash=%s --minversion=%s --wait=15 --waptsetupurl=%s' % (htmlpage['waptagent_sha256'],htmlpage['waptagent_version'],'http://%s/wapt/waptagent.exe' % urlserver)
        for ipplage in listplage :
            net4 = ipaddress.ip_network(ipplage)
            for ip in net4.hosts():
                if not str(ip) in ipexcluded :
                    print('---------------------------------------------------------')
                    print("Installation de wapt sur l'ip %s " % ip )
                    try:
                        print(run(r'PsExec.exe \\%s -accepteula -n 3 -u %s -p %s -c waptdeploy-psexec.exe %s ' % (ip,userpassword['user'],userpassword['password'],argument)))
                    except Exception as e :
                        if r'Timeout accessing' in ensure_unicode(e):
                            print ('Timeout for ip : %s' % ip)
                        elif r'Could not start PSEXESVC' in ensure_unicode(e):
                            print ('Could not start PSEXESVC : %s' % ip)
                        elif r'Error copying waptdeploy.exe to remote system' in ensure_unicode(e):
                            print ('Error copying waptdeploy.exe to remote system : %s' % ip)
                        else :
                           print(r'Unknow erreur : %s' % ensure_unicode(e))


if __name__ == '__main__':
    install_wapt()