diff --git a/fusioninventory-agent b/fusioninventory-agent index b3e83528f9..7d0ed6685b 100755 --- a/fusioninventory-agent +++ b/fusioninventory-agent @@ -23,8 +23,6 @@ GetOptions( 'conf-file=s', 'config=s', 'color', - 'daemon|d', - 'no-fork', 'debug+', 'delaytime=s', 'force|f', @@ -38,15 +36,11 @@ GetOptions( 'logfile=s', 'logfile-maxsize=i', 'no-category=s', - 'no-httpd', 'no-ssl-check', 'no-task=s', 'no-p2p', 'password|p=s', 'proxy|P=s', - 'httpd-ip=s', - 'httpd-port=s', - 'httpd-trust=s', 'scan-homedirs', 'server|s=s', 'tag|t=s', @@ -150,12 +144,6 @@ B [options] [--server server|--local path] --no-ssl-check do not check server SSL certificates (false) --timeout connection timeout (180) - Web interface options - --no-httpd disable embedded web server (false) - --httpd-ip=IP network interface to listen to - --httpd-port=PORT network port to listen to (62354) - --httpd-trust=RANGE trust requests from range without authentication token (false) - Logging options --logger=BACKEND logger backend [Stderr|File|Syslog] (Stderr) --logfile=FILE log file @@ -169,8 +157,6 @@ B [options] [--server server|--local path] Execution mode options -w --wait=DURATION maximum delay before execution, in seconds - -d --daemon run the agent as a daemon (false) - --no-fork don't fork in background (false) --debug debug mode (false) --version print the version and exit diff --git a/fusioninventory-daemon b/fusioninventory-daemon new file mode 100755 index 0000000000..2a117ff9f8 --- /dev/null +++ b/fusioninventory-daemon @@ -0,0 +1,453 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use lib './lib'; + +use English qw(-no_match_vars); +use Getopt::Long; +use Pod::Usage; +use Proc::Daemon; + +use FusionInventory::Agent; + +Getopt::Long::Configure( "no_ignorecase" ); + +my $options = {}; + +GetOptions( + $options, + 'additional-content=s', + 'backend-collect-timeout=s', + 'ca-cert-dir=s', + 'ca-cert-file=s', + 'conf-file=s', + 'config=s', + 'color', + 'no-fork', + 'debug+', + 'delaytime=s', + 'force|f', + 'help|h', + 'html', + 'lazy', + 'local|l=s', + 'logger=s', + 'logfile=s', + 'logfile-maxsize=i', + 'no-category=s', + 'no-httpd', + 'no-ssl-check', + 'no-task=s', + 'no-p2p', + 'password|p=s', + 'proxy|P=s', + 'httpd-ip=s', + 'httpd-port=s', + 'httpd-trust=s', + 'scan-homedirs', + 'server|s=s', + 'tag|t=s', + 'timeout=i', + 'user|u=s', +) or pod2usage(-verbose => 0); + +pod2usage(-verbose => 0) if $options->{help}; + +Proc::PID::File->require(); +if (!$EVAL_ERROR) { + if (Proc::PID::File->running()) { + print STDERR "An agent is already runnnig, exiting..."; + exit 1; + } +} + +my $agent = FusionInventory::Agent->new( + confdir => './etc', + datadir => './share', + libdir => './lib', + vardir => './var', +); + +eval { + $agent->init(options => { daemon => 1, %$options }); + Proc::Daemon::Init() if !$options->{'no-fork'}; + $agent->startHTTPServer(); + $agent->run(); +}; + +if ($EVAL_ERROR) { + print STDERR "Execution failure:.\n"; + print STDERR $EVAL_ERROR; + exit 1; +} + +exit(0); + +__END__ + +=head1 NAME + +fusioninventory-daemon - FusionInventory agent For Linux/UNIX, Windows and MacOSX + +=head1 SYNOPSIS + +B [options] [--server server|--local path] + + Target definition options + -s --server=URI send tasks result to a server + -l --local=PATH write tasks results locally + + Target scheduling options + --delaytime=DURATION maximum initial delay before first target, in seconds (3600) + --lazy do not contact the target before next scheduled time + + Task selection options + --list-tasks list available tasks and exit + --no-task=TASK do not run given task + + Inventory task specific options + --no-category=CATEGORY do not list given category items + --scan-homedirs allow to scan use home directories (false) + --html save the inventory as HTML (false) + -f --force always send data to server (false) + -t --tag=TAG mark the machine with given tag + --backend-collect-timeout timeout for inventory modules execution (30) + --additional-content=FILE additional inventory content + + Package deployment task specific options + --no-p2p do not use peer to peer to download files (false) + + Network options: + -P --proxy=PROXY proxy address + -u --user=USER user name for server authentication + -p --password=PWD password for server authentication + --ca-cert-dir=D path to the CA certificates directory + --ca-cert-file=F path to the CA certificates file + --no-ssl-check do not check server SSL certificates (false) + --timeout connection timeout (180) + + Web interface options + --no-httpd disable embedded web server (false) + --httpd-ip=IP network interface to listen to + --httpd-port=PORT network port to listen to (62354) + --httpd-trust=RANGE trust requests from range without authentication token (false) + + Logging options + --logger=BACKEND logger backend [Stderr|File|Syslog] (Stderr) + --logfile=FILE log file + --logfile-maxsize=X maximum size of the log file in MB (0) + --logfacility=FACILITY syslog facility (LOG_USER) + --color use color in the console (false) + + Configuration options + --config=BACKEND configuration backend [file|registry|none] + --conf-file=FILE configuration file + + Execution mode options + -w --wait=DURATION maximum delay before execution, in seconds + --no-fork don't fork in background (false) + --debug debug mode (false) + --version print the version and exit + +=head1 DESCRIPTION + +The F agent is a generic multi-platform agent. It can +perform a large array of management tasks, such as local inventory, software +deployment or network discovery. It can be used either standalone, or in +combination with a compatible server (OCS, GLPI, OTRS) acting as a centralized +control point. + +=head1 OPTIONS + +Most of the options are available in a I form and a I form. For +example, the two lines below are all equivalent: + + % fusioninventory-daemon -s localhost + % fusioninventory-daemon --server localhost + +=head2 Target definition options + +=over + +=item B<-s>, B<--server>=I + +Send the results of tasks execution to given server. + +If I doesn't start with http:// or https://, the agent assume the +parameter is a hostname and rewrite it as: + + % --server=http://servername/ocsinventory + +In general, OCS Inventory server URL have this format: + + http://servername/ocsinventory + +and FusionInventory for GLPI this one: + + http://servername/glpi/plugins/fusioninventory/front/plugin_fusioninventory.communication.php + +Multiple values can be specified, using comma as a separator. + +=item B<-l>, B<--local>=I + +Write the results of tasks execution locally. + +Exact behaviour according to given path: + +=over + +=item * + +if I is a directory, a file will be created therein + +=item * + +if I is a file, it will be used directly + +=item * + +if I is '-', STDOUT will be used + +=back + +Multiple values can be specified, using comma as a separator. + +=back + +=head2 Target scheduling options + +=over + +=item B<--delaytime>=I + +Set an initial delay before the first target, whose value is computed randomly +between LIMIT / 2 and LIMIT seconds. This setting is ignored for server targets +after the initial contact, in favor of server-specified parameter +(PROLOG_FREQ). + +=item B<--lazy> + +Do not contact the target before next scheduled time. + +This option is only available when the agent is not run as a server. + +=back + +=head2 Task selection options + +=over + +=item B<--no-task>=I + +Disable the given task + +=item B<--list-tasks> + +List available tasks and exit + +=back + +=head2 Inventory task specific options + +=over + +=item B<--no-category>=I + +Do not list given category items in inventory. + +=item B<--scan-homedirs> + +Allow the agent to scan home directories for virtual machines. + +=item B<--html> + +Save the inventory as HTML. + +This is only used for local inventories. + +=item B<-f>, B<--force> + +Send an inventory to the server, even if this last one doesn't ask for it. + +=item B<--tag>=I + +Mark the machine with given tag. + +=item B<--backend-collect-timeout>=I