From fe84cd47932d9d0fbadc85d1a173c6b6a3ce2fc7 Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Oct 02 2019 13:51:33 +0000 Subject: Update to agent 2.6.0 --- diff --git a/.gitignore b/.gitignore index cfa4791..2cc68e7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ Ocsinventory-Agent-1.1.2.tar.gz /Ocsinventory-Unix-Agent-2.0.5.tar.gz /Ocsinventory-Unix-Agent-2.1.tar.gz /Ocsinventory-Unix-Agent-2.1.1.tar.gz +/Ocsinventory-Unix-Agent-2.6.0.tar.gz diff --git a/ocsinventory-agent-daily.timer b/ocsinventory-agent-daily.timer new file mode 100644 index 0000000..cfbed2c --- /dev/null +++ b/ocsinventory-agent-daily.timer @@ -0,0 +1,14 @@ +[Unit] +Description=Run OCS Inventory once per day + +[Timer] +OnCalendar=daily +OnUnitInactiveSec=86000 + +Unit=ocsinventory-agent.service +RandomizedDelaySec=900 +AccuracySec=900 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/ocsinventory-agent-hourly.timer b/ocsinventory-agent-hourly.timer new file mode 100644 index 0000000..b5fdd85 --- /dev/null +++ b/ocsinventory-agent-hourly.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run OCS Inventory Hourly (if server permits) + +[Timer] +OnCalendar=hourly +Unit=ocsinventory-agent.service +RandomizedDelaySec=10 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/ocsinventory-agent-onboot.timer b/ocsinventory-agent-onboot.timer new file mode 100644 index 0000000..45b05aa --- /dev/null +++ b/ocsinventory-agent-onboot.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Run OCS Inventory shortly after boot + +[Timer] +OnBootSec=900 +Unit=ocsinventory-agent.service +RandomizedDelaySec=10 +Persistent=true + +[Install] +WantedBy=timers.target diff --git a/ocsinventory-agent.README b/ocsinventory-agent.README new file mode 100644 index 0000000..51764d5 --- /dev/null +++ b/ocsinventory-agent.README @@ -0,0 +1,34 @@ +Thie RPM install the OCS Inventory NG client +It is configure to generate a local report: + + /var/lib/ocsinventory-agent/.ocs + +If you want it to automaticaly and regularly transfer the +result to your organization communication server, edit the +configuration file: + + /etc/sysconfig/ocsinventory-agent + +You may choose how often to run the 'cron' script via +the provided systemd timers. + +The 'cron' script will respect the server PROLOQ_FREQ. + +An hourly run will report back to the server when the +PROLOQ_FREQ is over, but will prevent some hibernation. + +The less frequent runs may result in clients that do not +report back within certian time frames. + +If you want to deploy this client on a important number of +computer, you can generate a already configured RPM with + +rpmbuild -bb \ + --define "ocstag tagvalue" \ + --define "ocsserver ocsserver.domain.tld:port" \ + ocsinventory-agent-.src.rpm + +Result will be : ocsinventory-agent-..noarch.rpm + +When using a personalized RPM, the cron is enabled by default. + diff --git a/ocsinventory-agent.cron b/ocsinventory-agent.cron new file mode 100644 index 0000000..b2528ac --- /dev/null +++ b/ocsinventory-agent.cron @@ -0,0 +1,38 @@ +#!/bin/bash +NAME=ocsinventory-agent + +exec >>/var/log/$NAME/$NAME.log 2>&1 + +[ -f /etc/sysconfig/$NAME ] || exit 0 +source /etc/sysconfig/$NAME +export PATH + +i=0 +while [ $i -lt ${#OCSMODE[*]} ] +do + if [ ${OCSMODE[$i]:-none} == cron ]; then + OPTS= + if [ ! -z "${OCSPAUSE[$i]}" ]; then + OPTS="--wait ${OCSPAUSE[$i]}" + fi + + if [ ! -z "${OCSTAG[$i]}" ]; then + OPTS="$OPTS --tag=${OCSTAG[$i]}" + fi + + if [ "z${OCSSERVER[$i]}" = 'zlocal' ]; then + # Local inventory + OPTS="$OPTS --local=/var/lib/$NAME" + + elif [ ! -z "${OCSSERVER[$i]}" ]; then + # Remote inventory + OPTS="$OPTS --lazy --nolocal --server=${OCSSERVER[$i]}" + fi + + echo "[$(date '+%c')] Running $NAME $OPTS" + /usr/sbin/$NAME $OPTS + fi + ((i++)) +done +echo "[$(date '+%c')] End of cron job ($PATH)" + diff --git a/ocsinventory-agent.logrotate b/ocsinventory-agent.logrotate new file mode 100644 index 0000000..2483628 --- /dev/null +++ b/ocsinventory-agent.logrotate @@ -0,0 +1,9 @@ +# Rotate OCS Inventory NG agent logs daily, only if not empty +# Save 7 days old logs under compressed mode +/var/log/ocsinventory-agent/*.log { + daily + rotate 7 + compress + notifempty + missingok +} diff --git a/ocsinventory-agent.service b/ocsinventory-agent.service new file mode 100644 index 0000000..3450343 --- /dev/null +++ b/ocsinventory-agent.service @@ -0,0 +1,10 @@ +[Unit] +Description=OCS Inventory Agent +After=network.target + +[Service] +Type=oneshot +ExecStart=/usr/libexec/ocsinventory-agent/ocsinventory-agent.cron + +[Install] +WantedBy=multi-user.target diff --git a/ocsinventory-agent.spec b/ocsinventory-agent.spec new file mode 100644 index 0000000..f5a60f1 --- /dev/null +++ b/ocsinventory-agent.spec @@ -0,0 +1,486 @@ +# spec file for ocsinventory-agent +# +# Copyright (c) 2007-2014 Remi Collet +# Copyright (c) 2016-2017 Philippe Beaumont +# License: CC-BY-SA +# http://creativecommons.org/licenses/by-sa/3.0/ +# +# Please, preserve the changelog entries +# + +# Can, optionaly, be define at build time (see README.RPM) +# - ocstag : administrative tag +# - ocsserver : OCS Inventory NG communication serveur + +# Avoid empty debuginfo package, arched only for dep +%global debug_package %{nil} + +# Official release version +%global official_version 2.6.0 + +Name: ocsinventory-agent +Summary: Open Computer and Software Inventory Next Generation client + +Version: 2.6.0 +Release: 2%{?dist} + +Source0: https://github.com/OCSInventory-NG/UnixAgent/releases/download/v%{official_version}/Ocsinventory-Unix-Agent-%{official_version}.tar.gz + +Source1: %{name}.logrotate +Source2: %{name}.cron + +Source11: %{name}.README + +Source30: ocsinventory-agent.service +Source31: ocsinventory-agent-onboot.timer +Source32: ocsinventory-agent-hourly.timer +Source33: ocsinventory-agent-daily.timer + +License: GPLv2+ +URL: http://www.ocsinventory-ng.org/ + +BuildRequires: perl-interpreter +BuildRequires: perl-generators +BuildRequires: perl(Module::Install) +BuildRequires: perl(XML::Simple) +BuildRequires: perl(LWP) +BuildRequires: perl(Net::IP) +BuildRequires: perl(Digest::MD5) +BuildRequires: perl(File::Temp) + +%if 0%{?rhel} >= 7 +BuildRequires: systemd +Requires(post): systemd +%else +BuildRequires: systemd-rpm-macros +Requires(post): systemd +%endif + +### +# NOTE: rpmlint: the runtime requirments change depending on the arch +# so while this package contains no binaries, it is arch dependant. +### +Requires: perl-Ocsinventory-Agent = %{version}-%{release} +%ifarch %{ix86} x86_64 ia64 +Requires: dmidecode +%endif + +%ifarch %{ix86} x86_64 +Requires: libx86 +%endif + +Requires: %{_sysconfdir}/logrotate.d + +Obsoletes: ocsinventory-client < %{version} +Provides: ocsinventory-client = %{version}-%{release} + +%{?perl_default_filter} + +%description +Open Computer and Software Inventory Next Generation is an application +designed to help a network or system administrator keep track of computer +configuration and software installed on the network. + +It also allows deploying software, commands or files on Windows and +Linux client computers. + +%{name} provides the client for Linux (Unified Unix Agent). + + +%description -l fr +Open Computer and Software Inventory Next Generation est une application +destinée à aider l'administrateur système ou réseau à garder un oeil sur +la configuration des machines du réseau et sur les logiciels qui y sont +installés. + +Elle autorise aussi la télédiffusion (ou déploiement) de logiciels, +de commandes ou de fichiers sur les clients Windows ou Linux. + +%{name} fournit le client pour Linux (Agent Unix Unifié) + + +%package -n perl-Ocsinventory-Agent +Summary: Libraries %{name} +BuildArch: noarch + +Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) +Requires: perl(Data::UUID) +Requires: perl(Digest::MD5) +Requires: perl(File::Temp) +Requires: perl(HTTP::Request) +Requires: perl(LWP) > 6 +Requires: perl(LWP::Protocol) +Requires: perl(LWP::Protocol::http) +Requires: perl(LWP::Protocol::https) +Requires: perl(Net::IP) +Requires: perl(Net::Netmask) +Requires: perl(Net::SNMP) +Requires: perl(Net::SSLeay) +Requires: perl(Proc::Daemon) +Requires: perl(XML::Simple) +Requires: monitor-edid +%if 0%{?fedora} >= 25 || 0%{?rhel} >= 8 +Recommends: perl(Net::Cups) +Recommends: perl(Net::Ping) +Recommends: perl(Parse::EDID) +Suggests: nmap +Suggests: perl(Nmap::Parser) +%endif +Requires: net-tools +Requires: pciutils +Requires: smartmontools +Requires: which + +Conflicts: %{name} < %{version} + +%description -n perl-Ocsinventory-Agent +Perl libraries for %{name} + +%prep +%setup -q -n Ocsinventory-Unix-Agent-%{version} + +sed -e 's/\r//' -i snmp/mibs/local/6876.xml + +### +# NOTE: rpmlint will complain about these macros in comments +# they are on purpose to permit the comments to match +# what the values used by the build environment. +### +cat <%{name}.conf +# +# OCS Inventory "Unix Unified Agent" Configuration File +# used by the ocsinventory-agent.service and +# related timers. +# + +# Add tools directory if needed (tw_cli, hpacucli, ipssend, ...) +PATH=/sbin:/bin:/usr/sbin:/usr/bin + +%if 0%{?ocsserver:1} +# Mode, change to "none" to disable +OCSMODE[0]=cron + +# used to override the %{name}.cfg setup. +OCSSERVER[0]=%{ocsserver} + +# runs in addition to the remote report +# corresponds with --local=%{_localstatedir}/lib/%{name} +# OCSSERVER[1]=local +%else +# Mode, change to "cron" to activate +OCSMODE[0]=none + +# can be used to override the %{name}.cfg setup. +# OCSSERVER[0]=your.ocsserver.name +# +# corresponds with --local=%{_localstatedir}/lib/%{name} +# OCSSERVER[0]=local +%endif + +# Wait before inventory +OCSPAUSE[0]=100 + +# Administrative TAG (optional, must be filed before first inventory) +OCSTAG[0]=%{?ocstag} +EOF + +cat <%{name}.cfg +# +# OCS Inventory "Unix Unified Agent" Configuration File +# +# options used by timers or /etc/sysconfig/%{name} overide these. +# + +# Server URL, unconmment if needed +# server = your.ocsserver.name +local = %{_localstatedir}/lib/%{name} + +# Administrative TAG (optional, must be filed before first inventory) +# tag = %{?ocsserver:yourtag} + +# How to log, can be File,Stderr,Syslog +logger = Stderr +logfile = %{_localstatedir}/log/%{name}/%{name}.log +EOF + +cp %{SOURCE11} README.RPM + + +%build +/usr/bin/perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" NO_PACKLIST=1 NO_PERLLOCAL=1 +%{make_build} +rm run-postinst + +%install +%{make_install} +find %{buildroot} -type f -name '*.bs' -size 0 -delete +%{_fixperms} %{buildroot}/* + +# Move exe to root directory +mv %{buildroot}%{_bindir} %{buildroot}%{_sbindir} + +mkdir -p %{buildroot}%{_localstatedir}/{log,lib}/%{name} +mkdir -p %{buildroot}%{_sysconfdir}/{logrotate.d,sysconfig,ocsinventory/softwares} + +mkdir %{buildroot}%{_localstatedir}/lib/%{name}/download +cp -pr snmp %{buildroot}%{_localstatedir}/lib/%{name}/snmp + +install -pm 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/logrotate.d/%{name} +install -pm 644 %{name}.conf %{buildroot}%{_sysconfdir}/sysconfig/%{name} + +mkdir -p %{buildroot}/%{_libexecdir}/%{name} +sed -e 's;/etc/;%{_sysconfdir}/;' \ + -e 's;/var/;%{_localstatedir}/;' \ + -e 's;/usr/sbin/;%{_sbindir}/;' \ + %{SOURCE2} > %{buildroot}%{_libexecdir}/%{name}/ocsinventory-agent.cron + +mkdir -p %{buildroot}/%{_unitdir} +install -pm 644 %{SOURCE30} %{buildroot}/%{_unitdir}/ +install -pm 644 %{SOURCE31} %{buildroot}/%{_unitdir}/ +install -pm 644 %{SOURCE32} %{buildroot}/%{_unitdir}/ +install -pm 644 %{SOURCE33} %{buildroot}/%{_unitdir}/ + +install -m 644 %{name}.cfg %{buildroot}/%{_sysconfdir}/ocsinventory/%{name}.cfg +install -m 644 etc/ocsinventory-agent/modules.conf %{buildroot}/%{_sysconfdir}/ocsinventory/modules.conf + +# Remove some unusefull files (which brings unresolvable deps) +rm -rf %{buildroot}%{perl_vendorlib}/Ocsinventory/Agent/Backend/OS/Win32* + +# Only need for manual installation +rm %{buildroot}%{perl_vendorlib}/Ocsinventory/Unix/postinst.pl + +# Provided by ocsinventtory-ipdiscover +rm %{buildroot}%{_sbindir}/ipdiscover + + +%post + +# See if sysadmin requested ocs agent run on boot +%systemd_post ocsinventory-agent-onboot.timer + +# See if sysadmin requested ocs agent hourly run +%systemd_post ocsinventory-agent-hourly.timer + +# See if sysadmin requested ocs agent daily run +%systemd_post ocsinventory-agent-daily.timer + +%files +%{_sbindir}/%{name} +%config(noreplace) %{_sysconfdir}/sysconfig/%{name} +%attr(0755, root, root) %{_libexecdir}/%{name}/ +%attr(0755, root, root) %{_libexecdir}/%{name}/ocsinventory-agent.cron +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%dir %{_localstatedir}/log/%{name} +%{_mandir}/man1/%{name}* +%{_unitdir}/* + +%files -n perl-Ocsinventory-Agent +%doc AUTHORS Changes README.md THANKS README.RPM +%doc etc/ocsinventory-agent/softwares/example.sh +%license LICENSE +%{perl_vendorlib}/Ocsinventory +%{_mandir}/man3/Ocs* +%dir %{_localstatedir}/lib/%{name} +%{_localstatedir}/lib/%{name}/download +%{_localstatedir}/lib/%{name}/snmp +%dir %{_sysconfdir}/ocsinventory +%dir %{_sysconfdir}/ocsinventory/softwares +%config(noreplace) %{_sysconfdir}/ocsinventory/%{name}.cfg +%config(noreplace) %{_sysconfdir}/ocsinventory/modules.conf + + +%changelog +* Thu Aug 15 2019 Pat Riehecky - 2.6.0-2 +- Return to Fedora +- Use systemd timers rather than cron for regular runs +- Add a handful of possible timers users might want + +* Mon May 20 2019 Philippe Beaumont - 2.6.0-1 +- Update to 2.6.0 + +* Mon Dec 31 2018 Philippe Beaumont - 2.4.2-3 +- Remove Module::Install as dependancy + +* Mon Dec 24 2018 Philippe Beaumont - 2.4.2-2 +- Add core agent + +* Tue Jul 31 2018 Philippe Beaumont - 2.4.2-1 +- Update to 2.4.2 + +* Sun Feb 11 2018 Philippe Beaumont - 2.4.0-1 +- Update to 2.4.0 + +* Mon Jan 15 2018 Philippe Beaumont - 2.3.0-2 +- Add SSL dependancies + +* Thu Jan 12 2017 Philippe Beaumont - 2.3.0-1 +- Update to 2.3.0 + +* Sun Jan 01 2017 Philippe Beaumont - 2.3.0-0.1 +- Update to 2.3RC1 + +* Thu May 22 2014 Remi Collet - 2.1.1-2 +- Update to 2.1.1 + +* Thu Feb 13 2014 Remi Collet - 2.1-2 +- more upstream patches +- add /var/lib/ocsinventory-agent/snmp and download folder +- move /etc/ocsinventory and /var/lib to subpackage + +* Thu Feb 13 2014 Remi Collet - 2.1-1 +- Update to 2.1 +- move perl library to perl-Ocsinventory-Agent +- make main package arched for dependency on dmidecode + +* Fri Aug 02 2013 Petr Pisar - 2.0.5-8 +- Perl 5.18 rebuild + +* Sat Jul 27 2013 Jóhann B. Guðmundsson - 2.0.5-7 +- Add a missing requirement on crontabs to spec file + +* Thu Feb 14 2013 Fedora Release Engineering - 2.0.5-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild + +* Mon Dec 17 2012 Remi Collet - 2.0.5-5 +- fix provided configuration when build with ocsserver defined + +* Sun Sep 23 2012 Remi Collet - 2.0.5-4 +- fix ifconfig output parser (#853982) + https://bugs.launchpad.net/bugs/1045356 + +* Fri Jul 20 2012 Fedora Release Engineering - 2.0.5-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild + +* Fri Jun 22 2012 Petr Pisar - 2.0.5-2 +- Perl 5.16 rebuild + +* Sat Apr 14 2012 Remi Collet - 2.0.5-1 +- update to 2.0.5 + +* Mon Feb 13 2012 Remi Collet - 2.0.4-1 +- update to 2.0.4 + +* Fri Jan 13 2012 Fedora Release Engineering - 1.1.2.1-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild + +* Wed Jul 20 2011 Petr Sabata - 1.1.2.1-3 +- Perl mass rebuild + +* Tue Feb 08 2011 Fedora Release Engineering - 1.1.2.1-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild + +* Wed Oct 13 2010 Remi Collet 1.1.2.1-1 +- security update for CVE-2009-0667 + http://bugs.debian.org/590879 + http://www.debian.org/security/2009/dsa-1828 + +* Sat Oct 09 2010 Remi Collet 1.1.2-3 +- remove perl-XML-SAX optional dep, which is broken on EL5 + and cause overload when installed on the OCS server + +* Tue Jun 01 2010 Marcela Maslanova - 1.1.2-2 +- Mass rebuild with perl-5.12.0 + +* Sun Jan 03 2010 Remi Collet 1.1.2-1 +- update to 1.1.2 + +* Sun Dec 27 2009 Remi Collet 1.1.1-2 +- missing perl(Net::IP) requires (+ some EL3 stuff: yes, I know) + +* Tue Dec 22 2009 Remi Collet 1.1.1-1 +- update to 1.1.1 + +* Sat Nov 28 2009 Remi Collet 1.1-2 +- add Requires: which + +* Sat Nov 07 2009 Remi Collet 1.1-1 +- update to 1.1 +- add missing modules.conf +- new Requires perl(Net::SSLeay), perl(Crypt::SSLeay), smartmontools +- download URL to launchpad + +* Sat Jul 25 2009 Fedora Release Engineering - 1.0.1-5 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild + +* Thu May 14 2009 Remi Collet 1.0.1-4 +- fix typo + +* Thu May 14 2009 Remi Collet 1.0.1-3 +- define PATH in config (workaround for #500594 + tool path if needed) + +* Fri Apr 24 2009 Remi Collet 1.0.1-2 +- update the README.RPM (new configuration file) +- change from URL to only servername in config comment + +* Sun Mar 29 2009 Remi Collet 1.0.1-1 +- update to 1.0.1 + +* Thu Feb 26 2009 Fedora Release Engineering - 0.0.9.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild + +* Mon Oct 20 2008 Remi Collet 0.0.9.2-2 +- fix FTBFS (#465073) + +* Sun Apr 20 2008 Remi Collet 0.0.9.2-1 +- update to 0.0.9.2 (minor bug fix) + +* Mon Apr 07 2008 Remi Collet 0.0.9.1-2 +- add Requires monitor-edid + +* Thu Apr 03 2008 Remi Collet 0.0.9.1-1 +- update to 0.0.9.1 (minor bug fix) +- swicth back to nobundle sources + +* Wed Apr 02 2008 Remi Collet 0.0.9-1 +- update to 0.0.9 finale +- provides default config to file (need options.patch) +- add requires nmap (for ipdiscover) +- add BR perl(XML::SAX) (to avoid install of bundled one) + +* Mon Mar 10 2008 Remi Collet 0.0.8.2-0.6.20080305 +- rebuild against perl 5.10 + +* Fri Mar 7 2008 Remi Collet 0.0.8.2-0.5.20080305 +- patches from review (Patrice Dumas) + +* Wed Mar 5 2008 Remi Collet 0.0.8.2-0.4.20080305 +- update to 2008-03-05 +- add /etc/sysconfig/ocsinventory-agent config file for cron job + +* Mon Mar 3 2008 Remi Collet 0.0.8.2-0.3.20080302 +- only enable cron when server is configured + +* Sun Mar 2 2008 Remi Collet 0.0.8.2-0.2.20080302 +- from Review, see #435593 + +* Sun Mar 2 2008 Remi Collet 0.0.8.2-0.1.20080302 +- update to 0.0.8.2 from CVS + +* Fri Feb 22 2008 Remi Collet 0.0.8.2-0.1.20080222 +- update to 0.0.8.2 from CVS + +* Sun Feb 17 2008 Remi Collet 0.0.8.1-0.1.20080217 +- update to 0.0.8.1 from CVS +- change config file used + from /etc/ocsinventory-agent/ocsinv.conf + to /etc/ocsinventory/ocsinventory-agent.cfg + +* Sat Jan 26 2008 Remi Collet 0.0.7-1 +- update to 0.0.7 + +* Fri Dec 28 2007 Remi Collet 0.0.6.2-1 +- update to 0.0.6.2 + +* Mon Apr 16 2007 Remi Collet 0.0.6-1 +- update to 0.0.6 + +* Sat Feb 10 2007 Remi Collet 0.0.5-0.20070409 +- cvs update 20070409 +- create cron.daily file +- create logrotate.d file +- create ocsinv.conf +- cvs update 20070405 +- cvs update 20070403 + +* Sat Feb 10 2007 Remi Collet 0.0.2-0.20070210 +- initial spec diff --git a/sources b/sources new file mode 100644 index 0000000..91b3f69 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (Ocsinventory-Unix-Agent-2.6.0.tar.gz) = d767ee556121e132c816abd93a93aa2f2013444e009924752099daf5bb1fa4455cd8d2aff3d905780cd8edcbe7f6aee2ef0be7279716c6e7b172e4adc840bd71