Commit b51f21c8e35c650e81a769035ef680a255158d10
Exists in
master
Merge branch 'master' of https://github.com/lightbase/cacic-agente
Conflicts: install-cacic/installcacic.cpp
Showing
5 changed files
with
80 additions
and
40 deletions
Show diff stats
cacic-daemon/cacicD/Readme.txt
1 | 1 | Para instalar um serviço no Windows: |
2 | 2 | ~$ sc create "CacicD" binPath= "C:\endereco\do\cacicd\CacicD.exe" start= auto |
3 | 3 | |
4 | -Para instalar um serviço no Linux: | |
5 | - Usar o Upstart | |
6 | - | |
4 | +Para instalar um serviço no Linux (TESTADO no Ubuntu 14.04): | |
5 | + 1- copiar o /etc/init.d/skeleton para /etc/init.d/cacic e fazer as modificações necessarias. | |
6 | + (como por exemplo o endereço do binario) e dar as permissões de execução. | |
7 | + * edit as linhas: DESC="Description of the service" //descrição | |
8 | + NAME=daemonexecutablename //nome correto do binario | |
9 | + DAEMON=/usr/sbin/$NAME // endereço/correto/do/binario/$NAME | |
10 | + * sudo chmod +x cacic | |
11 | + 2- criar um link simbolico para /etc/rc2.d/S99cacic | |
12 | + * sudo ln -s /etc/init.d/cacic /etc/rc2.d/S99cacic | |
13 | + 3- iniciar o serviço. | |
14 | + * /bin/bash -vx /etc/init.d/cacic start | ... | ... |
cacic-daemon/cacicD/cacicD.pro
... | ... | @@ -8,43 +8,42 @@ QT += core |
8 | 8 | QT -= gui |
9 | 9 | QT += network |
10 | 10 | |
11 | -TARGET = cacic-service | |
12 | -CONFIG += console | |
13 | -CONFIG -= app_bundle | |
14 | -CONFIG += static | |
11 | +TARGET = cacic-service | |
12 | +CONFIG += console | |
13 | +CONFIG -= app_bundle | |
14 | +CONFIG += static | |
15 | +TEMPLATE = app | |
16 | +INCLUDEPATH += ../../src \ | |
17 | + ../../src/crypto++/include/ | |
18 | + | |
15 | 19 | win32 { |
16 | - LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp | |
17 | - QT += axcontainer | |
20 | + LIBS += -LE:\LightBase\cacic-agente-project\cacic-agente\src\crypto++\lib -lcryptopp | |
21 | + QT += axcontainer | |
18 | 22 | } else { |
19 | - LIBS += -L/usr/lib -lcryptopp | |
23 | + LIBS += -L/usr/lib -lcryptopp | |
20 | 24 | } |
21 | -TEMPLATE = app | |
22 | - | |
23 | -SOURCES += main.cpp \ | |
24 | - cacicd.cpp \ | |
25 | - cacictimer.cpp \ | |
26 | - cacicthread.cpp \ | |
27 | - ../../src/cacic_comm.cpp \ | |
28 | - ../../src/ccacic.cpp \ | |
29 | - ../../src/wmi.cpp \ | |
30 | - ../../src/cacic_computer.cpp \ | |
31 | - ../../src/operatingsystem.cpp \ | |
32 | - ../../src/QLogger.cpp \ | |
33 | - | |
34 | - | |
35 | -HEADERS += cacicd.h \ | |
36 | - cacictimer.h \ | |
37 | - cacicthread.h \ | |
38 | - ../../src/ccacic.h \ | |
39 | - ../../src/wmi.h \ | |
40 | - ../../src/cacic_computer.h \ | |
41 | - ../../src/operatingsystem.h \ | |
42 | - ../../src/cacic_comm.h \ | |
43 | - ../../src/QLogger.h \ | |
44 | 25 | |
26 | +SOURCES += main.cpp \ | |
27 | + cacicd.cpp \ | |
28 | + cacictimer.cpp \ | |
29 | + cacicthread.cpp \ | |
30 | + ../../src/cacic_comm.cpp \ | |
31 | + ../../src/ccacic.cpp \ | |
32 | + ../../src/wmi.cpp \ | |
33 | + ../../src/cacic_computer.cpp \ | |
34 | + ../../src/operatingsystem.cpp \ | |
35 | + ../../src/QLogger.cpp | |
36 | + | |
37 | + | |
38 | +HEADERS += cacicd.h \ | |
39 | + cacictimer.h \ | |
40 | + cacicthread.h \ | |
41 | + ../../src/ccacic.h \ | |
42 | + ../../src/wmi.h \ | |
43 | + ../../src/cacic_computer.h \ | |
44 | + ../../src/operatingsystem.h \ | |
45 | + ../../src/cacic_comm.h \ | |
46 | + ../../src/QLogger.h | |
45 | 47 | |
46 | 48 | include(../../src/qtservice/src/qtservice.pri) |
47 | 49 | |
48 | -INCLUDEPATH += ../../src \ | |
49 | - ../../src/crypto++/include/ | |
50 | - | ... | ... |
install-cacic/installcacic.cpp
... | ... | @@ -57,15 +57,15 @@ void InstallCacic::run(QStringList argv, int argc) { |
57 | 57 | |
58 | 58 | //TO DO: Fazer download do serviço |
59 | 59 | #ifdef Q_OS_WIN |
60 | - oCacicComm->ftpDownload("agentes/cacic.exe"); | |
60 | + oCacicComm->ftpDownload("agentes/cacic-service.exe"); | |
61 | 61 | |
62 | - QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic.exe", | |
62 | + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic-service.exe", | |
63 | 63 | false, |
64 | 64 | &ok, |
65 | 65 | QStringList("-install"); |
66 | 66 | #else |
67 | - oCacicComm->ftpDownload("agentes/cacic"); | |
68 | - QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic", | |
67 | + oCacicComm->ftpDownload("agentes/cacic-service"); | |
68 | + QString exitStatus = oCacic.startProcess(oCacic.getCacicMainFolder() + "cacic-service", | |
69 | 69 | false, |
70 | 70 | &ok, |
71 | 71 | QStringList("-install", | ... | ... |
src/cacic_hardware.cpp
... | ... | @@ -10,6 +10,10 @@ void cacic_hardware::iniciaColeta() |
10 | 10 | #elif defined(Q_OS_LINUX) |
11 | 11 | OperatingSystem operatingSystem; |
12 | 12 | |
13 | + | |
14 | + // Como criaremos pacotes agora, todas essas verificações podiam só | |
15 | + // ser incluídas como dependências. | |
16 | + | |
13 | 17 | // se o shell retorna erro ao tentar utilizar o lshw ou o dmidecode, instala o mesmo |
14 | 18 | if( console("lshw").contains("/bin/sh:") ){ qDebug() << "lshw nao instalado."; |
15 | 19 | if(operatingSystem.getIdOs() == OperatingSystem::LINUX_ARCH) |
... | ... | @@ -288,6 +292,7 @@ QJsonObject cacic_hardware::coletaLinux() |
288 | 292 | coletaLinuxBios(hardware); |
289 | 293 | coletaLinuxMotherboard(hardware); |
290 | 294 | coletaLinuxIsNotebook(hardware); |
295 | + coletaLinuxPrinters(hardware); | |
291 | 296 | |
292 | 297 | return hardware; |
293 | 298 | } |
... | ... | @@ -435,6 +440,33 @@ void cacic_hardware::coletaLinuxIsNotebook(QJsonObject &hardware) |
435 | 440 | |
436 | 441 | } |
437 | 442 | |
443 | +void cacic_hardware::coletaLinuxPrinters(QJsonObject &hardware) | |
444 | +{ | |
445 | + QStringList consoleOutput; | |
446 | + | |
447 | + if( console("lpstat").contains("/bin/sh:") ) { // Cups não instalado | |
448 | + return; | |
449 | + } else { | |
450 | + | |
451 | + consoleOutput = console("lpstat -a").split("\n"); | |
452 | + consoleOutput.removeLast(); // remover o último elemento que é somente vazio | |
453 | + | |
454 | + if( consoleOutput[0].contains("No destination") ) | |
455 | + return; | |
456 | + | |
457 | + QJsonArray printersList; | |
458 | + foreach(QString line, consoleOutput ) { | |
459 | + | |
460 | + if ( line.split(" ")[1] == QString("accepting") ) { | |
461 | + QString printerName = line.split(" ")[0]; | |
462 | + printersList.append(QJsonValue::fromVariant(printerName)); | |
463 | + } | |
464 | + } | |
465 | + hardware["printers"] = printersList; | |
466 | + } | |
467 | + | |
468 | +} | |
469 | + | |
438 | 470 | #endif |
439 | 471 | QJsonObject cacic_hardware::toJsonObject() { |
440 | 472 | return coletaHardware; | ... | ... |
src/cacic_hardware.h
... | ... | @@ -34,6 +34,7 @@ private: |
34 | 34 | void coletaLinuxBios(QJsonObject &hardware); |
35 | 35 | void coletaLinuxMotherboard(QJsonObject &hardware); |
36 | 36 | void coletaLinuxIsNotebook(QJsonObject &hardware); |
37 | + void coletaLinuxPrinters(QJsonObject &hardware); | |
37 | 38 | #endif |
38 | 39 | |
39 | 40 | CCacic oCacic; | ... | ... |