From 8442a20c069ce82c5ed5c673252d34147cb1b823 Mon Sep 17 00:00:00 2001 From: Guillaume Bougard Date: Mon, 8 Jul 2024 11:56:20 +0200 Subject: [PATCH] feat: Add TacticalRMM Remote_Mgmt support on linux --- Changes | 2 +- .../Generic/Remote_Mgmt/TacticalRMM.pm | 40 +++++++++++++------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Changes b/Changes index b1403a599..64c2bed6d 100644 --- a/Changes +++ b/Changes @@ -16,7 +16,7 @@ inventory: This is also an attempt to start antivirus support on Windows Server based on service detection. * Add support for Cortex XDR Antivirus on MacOSX and linux -* fix #700: Add TacticalRMM Remote_Mgmt module for windows +* fix #700: Add TacticalRMM Remote_Mgmt module for windows and linux * Update Solaris OS installation date support netdiscovery/netinventory: diff --git a/lib/GLPI/Agent/Task/Inventory/Generic/Remote_Mgmt/TacticalRMM.pm b/lib/GLPI/Agent/Task/Inventory/Generic/Remote_Mgmt/TacticalRMM.pm index 55cab9744..383374d31 100644 --- a/lib/GLPI/Agent/Task/Inventory/Generic/Remote_Mgmt/TacticalRMM.pm +++ b/lib/GLPI/Agent/Task/Inventory/Generic/Remote_Mgmt/TacticalRMM.pm @@ -6,6 +6,7 @@ use warnings; use parent 'GLPI::Agent::Task::Inventory::Module'; use English qw(-no_match_vars); +use Cpanel::JSON::XS; use GLPI::Agent::Tools; @@ -26,6 +27,8 @@ sub isEnabled { return 1 if defined($key); + } elsif (OSNAME eq 'linux') { + return 1 if has_file('/etc/tacticalagent'); } return 0; @@ -57,6 +60,21 @@ sub _getAgentId { my (%params) = @_; return _winBased(%params) if OSNAME eq 'MSWin32'; + return _linuxBased(%params) if OSNAME eq 'linux'; +} + +sub _linuxBased { + my (%params) = @_; + + my $config = getAllLines( + file => '/etc/tacticalagent', + %params + ); + + my $json = decode_json($config) + or return; + + return $json->{agentid}; } sub _winBased { @@ -73,20 +91,16 @@ sub _winBased { sub _getVersion { my (%params) = @_; - my $version; - - if (OSNAME eq 'MSWin32') { - my $command = "C:\\Program Files\\TacticalAgent\\tacticalrmm.exe"; - if (canRun($command)) { - $version = getFirstMatch( - command => "\"$command\" --version", - pattern => qr/^Tactical RMM Agent:\s+(\S+)/i, - logger => $params{logger} - ); - } - } + my $command = OSNAME eq 'MSWin32' ? + '"C:\\Program Files\\TacticalAgent\\tacticalrmm.exe" --version' + : + "rmmagent --version"; - return $version; + return getFirstMatch( + command => $command, + pattern => qr/^Tactical RMM Agent:\s+(\S+)/i, + %params + ); } 1;