From 640827efd60363a37e80b898e631652b5ca76cde Mon Sep 17 00:00:00 2001
From: Johan Cwiklinski <[email protected]>
Date: Thu, 9 Feb 2017 14:08:20 +0100
Subject: Change systemd configuration files

Re-add comments and default options to get cron mode working
Use new service file
Deprecate using EnvironmentFile for service extra config
---
 fusioninventory-agent.cron         |  2 +-
 fusioninventory-agent.service      | 20 ++++++++++++++++++++
 fusioninventory-agent.service.conf |  9 +++++++++
 fusioninventory-agent.spec         | 37 +++++++++++++++++++++++++++++++------
 4 files changed, 61 insertions(+), 7 deletions(-)
 create mode 100644 fusioninventory-agent.service
 create mode 100644 fusioninventory-agent.service.conf

diff --git a/fusioninventory-agent.cron b/fusioninventory-agent.cron
index 8b4b99f..8129715 100644
--- a/fusioninventory-agent.cron
+++ b/fusioninventory-agent.cron
@@ -29,7 +29,7 @@ do
                 OPTS="$OPTS --lazy --server=${OCSSERVER[$i]}"
         fi
         echo "[$(date '+%c')] Running $NAME $OPTS"
-        /usr/bin/$NAME $FUSINVOPT --logfile=$LOG $OPTS
+        /usr/bin/$NAME $OPTIONS --logfile=$LOG $OPTS
     fi
     ((i++))
 done
diff --git a/fusioninventory-agent.service b/fusioninventory-agent.service
new file mode 100644
index 0000000..2e220d4
--- /dev/null
+++ b/fusioninventory-agent.service
@@ -0,0 +1,20 @@
+# It is not recommended to modify this file in-place, because it will be
+# overwritten during package upgrades.  If you want to customize, the best
+# way is to use the "systemctl edit" command to create an override unit.
+
+# For example, to pass additional options (for instance,
+# --no-category=software) to the agent at startup, create an override unit
+# (as is done by systemctl edit) and enter the following:
+
+# [Service]
+# Environment="OPTIONS=--no-category=software"
+
+[Unit]
+Description=FusionInventory agent
+After=syslog.target network.target
+
+[Service]
+ExecStart=/usr/bin/fusioninventory-agent --daemon --no-fork $OPTIONS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/fusioninventory-agent.service.conf 
b/fusioninventory-agent.service.conf
new file mode 100644
index 0000000..77ee066
--- /dev/null
+++ b/fusioninventory-agent.service.conf
@@ -0,0 +1,9 @@
+# Extra configuration file for fusioninventory-agent unit
+[Service]
+#Deprecated: will be removed in a future version
+EnvironmentFile=-/etc/sysconfig/fusioninventory-agent
+#New way to declare values
+#Commented right now, because it will be overriden from EnvironmentFile
+#Will be enabled in a future version
+#Environment="OPTIONS=--debug"
+#Environment="PATH=/sbin:/bin:/usr/sbin:/usr/bin"
diff --git a/fusioninventory-agent.spec b/fusioninventory-agent.spec
index e8e786c..cd62ec3 100644
--- a/fusioninventory-agent.spec
+++ b/fusioninventory-agent.spec
@@ -10,9 +10,12 @@ License:     GPLv2+
 URL:         http://fusioninventory.org/
 
 Version:     2.3.18
-Release:     2%{?dist}
+Release:     3%{?dist}
 Source0:     
https://github.com/fusioninventory/%{name}/releases/download/%{version}/FusionInventory-Agent-%{version}.tar.gz
 Source1:     %{name}.cron
+#Use systemd override capabilities
+Source10:    %{name}.service
+Source11:    %{name}.service.conf
 #Apply 
https://github.com/fusioninventory/fusioninventory-agent/commit/25404f038f99bd091e0fb2368879e848500f5082
 Patch0:      %{name}-useless-module-cleaning
 
@@ -60,7 +63,6 @@ You can add additional packages for optional tasks:
 * fusioninventory-agent-task-wakeonlan
     not included due to a licensing issue for perl-Net-Write
 
-Edit the /etc/sysconfig/%{name} file for service configuration.
 
 %package -n perl-FusionInventory-Agent
 Summary:        Libraries for Fusioninventory agent
@@ -176,15 +178,32 @@ EOF
 cat <<EOF | tee %{name}.conf
 #
 # Fusion Inventory Agent Configuration File
-# used by hourly cron job and service launcher to override the %{name}.cfg 
setup.
+# used by hourly cron job to override the %{name}.cfg setup.
 #
-# DONT FORGET to enable the service !
+# /!\
+# USING THIS FILE TO OVERRIDE SERVICE OPTIONS IS DEPRECATED!
+# See %{_unitdir}/%{name}.service notice
 #
 # Add tools directory if needed (tw_cli, hpacucli, ipssend, ...)
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 # Global options (debug for verbose log, rpc-trust-localhost for yum-plugin)
 OPTIONS="--debug "
 
+# Mode, change to "cron" to activate
+# - none (default on install) no activity
+# - cron (inventory only) use the cron.hourly
+OCSMODE[0]=none
+# OCS Inventory or FusionInventory server URI
+# OCSSERVER[0]=your.ocsserver.name
+# OCSSERVER[0]=http://your.ocsserver.name/ocsinventory
+# OCSSERVER[0]=http://your.glpiserveur.name/glpi/plugins/fusioninventory/
+# corresponds with --local=%{_localstatedir}/lib/%{name}
+# OCSSERVER[0]=local
+# Wait before inventory (for cron mode)
+OCSPAUSE[0]=120
+# Administrative TAG (optional, must be filed before first inventory)
+OCSTAG[0]=
+
 EOF
 
 
@@ -211,8 +230,8 @@ mkdir -p %{buildroot}%{_localstatedir}/{log,lib}/%{name}
 install -m 644 -D  logrotate     %{buildroot}%{_sysconfdir}/logrotate.d/%{name}
 install -m 644 -D  %{name}.conf  %{buildroot}%{_sysconfdir}/sysconfig/%{name}
 install -m 755 -Dp %{SOURCE1}    %{buildroot}%{_sysconfdir}/cron.hourly/%{name}
-install -m 644 -D contrib/unix/%{name}.service    
%{buildroot}%{_unitdir}/%{name}.service
-
+install -m 644 -D  %{SOURCE10}   %{buildroot}%{_unitdir}/%{name}.service
+install -m 644 -D  %{SOURCE11}   
%{buildroot}%{_sysconfdir}/systemd/system/%{name}.service.d/override.conf
 
 # Yum plugin installation
 install -m 644 -D contrib/yum-plugin/%{name}.py   
%{buildroot}%{_prefix}/lib/yum-plugins/%{name}.py
@@ -240,6 +259,8 @@ install -m 644 -D contrib/yum-plugin/%{name}.conf 
%{buildroot}%{_sysconfdir}/yum
 %config(noreplace) %{_sysconfdir}/fusioninventory/agent.cfg
 %{_sysconfdir}/cron.hourly/%{name}
 %{_unitdir}/%{name}.service
+%dir %{_sysconfdir}/systemd/system/%{name}.service.d
+%{_sysconfdir}/systemd/system/%{name}.service.d/override.conf
 %{_bindir}/fusioninventory-agent
 %{_bindir}/fusioninventory-injector
 %{_mandir}/man1/fusioninventory-agent*
@@ -299,6 +320,10 @@ install -m 644 -D contrib/yum-plugin/%{name}.conf 
%{buildroot}%{_sysconfdir}/yum
 
 
 %changelog
+* Thu Feb 09 2017 Johan Cwiklinski <jcwiklinski AT teclib DOT com> - 2.3.18-3
+- Change systemd unit to not use fork mode
+- Re-add options in sysconfig file to get cron mode running
+
 * Wed Jun 22 2016 Johan Cwiklinski <johan AT x-tnd DOT be> - 2.3.18-2
 - Add task-collect subpackage
 - Change package source according to upstream recomendations
-- 
cgit v1.1


        
https://src.fedoraproject.org/cgit/fusioninventory-agent.git/commit/?h=f25&id=640827efd60363a37e80b898e631652b5ca76cde
_______________________________________________
perl-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to