From e8112b39050fe4d18a16f301547be9365920f41b Mon Sep 17 00:00:00 2001 From: Pat Riehecky Date: Nov 20 2019 14:58:30 +0000 Subject: Merge branch 'master' into epel7 --- 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 index 326a3bc..51764d5 100644 --- a/ocsinventory-agent.README +++ b/ocsinventory-agent.README @@ -9,10 +9,16 @@ configuration file: /etc/sysconfig/ocsinventory-agent -The hourly "cron" will launch an inventory and send it -according to the server configuration (PROLOQ_FREQ) +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 diff --git a/ocsinventory-agent.README.fr b/ocsinventory-agent.README.fr deleted file mode 100644 index e1b491f..0000000 --- a/ocsinventory-agent.README.fr +++ /dev/null @@ -1,28 +0,0 @@ -Ce RPM installe l'agent de "OCS Inventory NG" -Il est configuré pour générer un rapport local : - - /var/lib/ocsinventory-agent/.ocs - -Si vous souhaitez envoyer le rapport de manière automatique -et régulière au serveur de communication, éditez le fichier de -configuration : - - /etc/sysconfig/ocsinventory-agent - -Le "cron" horaire déclenchera l'inventaire et la transmission en -fonction de la configuration du serveur (PROLOG_FREQ) - - - -Si vous désirez déployer ce client sur un parc important, vous -pouvez générer un RPM préconfiguré à l'aide de la commande - -rpmbuild -bb \ - --define "ocstag tagvalue" \ - --define "ocsserver ocsserver.domain.tld:port" \ - ocsinventory-agent-.src.rpm - -Le résultat sera : ocsinventory-agent-..noarch.rpm - -Dans le cas d'un RPM personalisé, le "cron" est activé par défaut. - 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 index 9dc18c5..f5a60f1 100644 --- a/ocsinventory-agent.spec +++ b/ocsinventory-agent.spec @@ -1,6 +1,7 @@ # 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/ # @@ -14,26 +15,32 @@ # 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.1.1 -Release: 1%{?dist}%{?ocstag:.%{ocstag}} +Version: 2.6.0 +Release: 2%{?dist} -Source0: http://launchpad.net/ocsinventory-unix-agent/stable-2.1/%{version}/+download/Ocsinventory-Unix-Agent-%{version}.tar.gz +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 -Source12: %{name}.README.fr -Group: Applications/System +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/ -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) - +BuildRequires: perl-interpreter +BuildRequires: perl-generators BuildRequires: perl(Module::Install) BuildRequires: perl(XML::Simple) BuildRequires: perl(LWP) @@ -41,15 +48,33 @@ BuildRequires: perl(Net::IP) BuildRequires: perl(Digest::MD5) BuildRequires: perl(File::Temp) -Requires: perl-Ocsinventory-Agent = %{version}-%{release} -Requires: crontabs +%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 @@ -76,41 +101,56 @@ de commandes ou de fichiers sur les clients Windows ou Linux. %package -n perl-Ocsinventory-Agent Summary: Libraries %{name} -Group: Development/Libraries -%if 0%{?fedora} >= 12 || 0%{?rhel} >= 6 BuildArch: noarch -%endif + Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) -Requires: perl(Crypt::SSLeay) +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: net-tools -Requires: pciutils -Requires: nmap -Requires: monitor-edid -Requires: which -Requires: smartmontools -Requires: %{_sysconfdir}/logrotate.d +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} - -%{?perl_default_filter} - - %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 hourly cron job +# used by the ocsinventory-agent.service and +# related timers. # # Add tools directory if needed (tw_cli, hpacucli, ipssend, ...) @@ -122,6 +162,10 @@ 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 @@ -144,7 +188,7 @@ cat <%{name}.cfg # # OCS Inventory "Unix Unified Agent" Configuration File # -# options used by cron job overides this (see /etc/sysconfig/%{name}) +# options used by timers or /etc/sysconfig/%{name} overide these. # # Server URL, unconmment if needed @@ -152,7 +196,7 @@ cat <%{name}.cfg local = %{_localstatedir}/lib/%{name} # Administrative TAG (optional, must be filed before first inventory) -# tag = your_tag +# tag = %{?ocsserver:yourtag} # How to log, can be File,Stderr,Syslog logger = Stderr @@ -160,28 +204,23 @@ logfile = %{_localstatedir}/log/%{name}/%{name}.log EOF cp %{SOURCE11} README.RPM -cp %{SOURCE12} README.RPM.fr %build -%{__perl} Makefile.PL INSTALLDIRS=vendor -make %{?_smp_mflags} - +/usr/bin/perl Makefile.PL INSTALLDIRS=vendor OPTIMIZE="%{optflags}" NO_PACKLIST=1 NO_PERLLOCAL=1 +%{make_build} +rm run-postinst %install -rm -rf %{buildroot} - -make pure_install PERL_INSTALL_ROOT=%{buildroot} -find %{buildroot} -type f -name .packlist -exec rm -f {} ';' -find %{buildroot} -type d -depth -exec rmdir {} 2>/dev/null ';' - -chmod -R u+rwX,go+rX,go-w %{buildroot}/* +%{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,cron.hourly,ocsinventory/softwares} +mkdir -p %{buildroot}%{_sysconfdir}/{logrotate.d,sysconfig,ocsinventory/softwares} mkdir %{buildroot}%{_localstatedir}/lib/%{name}/download cp -pr snmp %{buildroot}%{_localstatedir}/lib/%{name}/snmp @@ -189,14 +228,20 @@ 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}%{_sysconfdir}/cron.hourly/%{name} -chmod +x %{buildroot}%{_sysconfdir}/cron.hourly/%{name} + %{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 +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* @@ -208,26 +253,33 @@ rm %{buildroot}%{perl_vendorlib}/Ocsinventory/Unix/postinst.pl rm %{buildroot}%{_sbindir}/ipdiscover -%clean -rm -rf %{buildroot} +%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 -%defattr(-, root, root, -) %{_sbindir}/%{name} %config(noreplace) %{_sysconfdir}/sysconfig/%{name} -%{_sysconfdir}/cron.hourly/%{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 -%defattr(-, root, root, -) -%doc AUTHORS Changes LICENSE README THANKS README.RPM +%doc AUTHORS Changes README.md THANKS README.RPM %doc etc/ocsinventory-agent/softwares/example.sh -%lang(fr) %doc README.RPM.fr +%license LICENSE %{perl_vendorlib}/Ocsinventory %{_mandir}/man3/Ocs* -%dir %{_localstatedir}/log/%{name} %dir %{_localstatedir}/lib/%{name} %{_localstatedir}/lib/%{name}/download %{_localstatedir}/lib/%{name}/snmp @@ -235,11 +287,39 @@ rm -rf %{buildroot} %dir %{_sysconfdir}/ocsinventory/softwares %config(noreplace) %{_sysconfdir}/ocsinventory/%{name}.cfg %config(noreplace) %{_sysconfdir}/ocsinventory/modules.conf -%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} %changelog -* Thu May 22 2014 Remi Collet - 2.1.1-1 +* 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 diff --git a/sources b/sources index b29f8d3..91b3f69 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -195960e048bfa77badc2a3df382a5a88 Ocsinventory-Unix-Agent-2.1.1.tar.gz +SHA512 (Ocsinventory-Unix-Agent-2.6.0.tar.gz) = d767ee556121e132c816abd93a93aa2f2013444e009924752099daf5bb1fa4455cd8d2aff3d905780cd8edcbe7f6aee2ef0be7279716c6e7b172e4adc840bd71