Bug 188941 - sysutils/dmidecode: Proposed daily periodic script
Summary: sysutils/dmidecode: Proposed daily periodic script
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Kurt Jaeger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-24 06:50 UTC by Dmitry Morozovsky
Modified: 2015-12-08 06:14 UTC (History)
2 users (show)

See Also:
koobs: maintainer-feedback? (sunpoet)


Attachments
patch as an attachment (3.44 KB, patch)
2015-04-27 10:08 UTC, Dmitry Morozovsky
no flags Details | Diff
fixed Makefile (3.47 KB, patch)
2015-04-27 10:24 UTC, Dmitry Morozovsky
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Morozovsky freebsd_committer freebsd_triage 2014-04-24 06:50:00 UTC
I suppose it would be useful to be able to track server hardware changes via
SMBIOS/DMI.

In my case, after replacing server RAM I could not find exact failed module by
serial number because did not save dmidecode output before memory swap.

The attached script should help in such and related situations. To enable
tracking dmidecode diffs in daily mail the admin should set the variable
daily_status_dmidecode_enable to "YES" in /etc/periodic.conf

Fix: 

Property changes on: files/dmidecode.in
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property--NIv951IkonxdJaiuwNYyiFrqnSjkPlELs7r1B0QeJvPuCedE
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

Index: Makefile
===================================================================
--- Makefile	(revision 351962)
+++ Makefile	(working copy)
@@ -3,6 +3,7 @@
 
 PORTNAME=	dmidecode
 PORTVERSION=	2.12
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	${MASTER_SITE_SAVANNAH} \
 		ftp://ftp.nuug.no/pub/anders/distfiles/
@@ -19,10 +20,17 @@
 MAKE_ENV+=	DOCSDIR="${DOCSDIR}"
 
 PLIST_FILES=	sbin/dmidecode \
-		man/man8/dmidecode.8.gz
+		man/man8/dmidecode.8.gz \
+		etc/periodic/daily/dmidecode
 
 PORTDOCS=	AUTHORS CHANGELOG README
+USE_RC_SUBR=	dmidecode
 
+post-install:
+	${MKDIR} ${STAGEDIR}${PREFIX}/etc/periodic/daily
+	${INSTALL_SCRIPT} ${WRKDIR}/dmidecode \
+		${STAGEDIR}${PREFIX}/etc/periodic/daily
+
 .include <bsd.port.pre.mk>
 
 .if ${ARCH} == "amd64" || ${ARCH} == "i386"
Index: files/dmidecode.in
===================================================================
--- files/dmidecode.in	(revision 0)
+++ files/dmidecode.in	(working copy)
@@ -0,0 +1,53 @@
+#!/bin/sh -
+#
+# Copyright (c) 2001-2014  The FreeBSD Project
+# Copyright (c) 2014	Dmitry Morozovsky <marck@rinet.ru>
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+# If there is a global system configuration file, suck it in.
+#
+if [ -r /etc/defaults/periodic.conf ]
+then
+    . /etc/defaults/periodic.conf
+    source_periodic_confs
+fi
+
+dmidecode=%%PREFIX%%/sbin/dmidecode
+
+. /etc/periodic/security/security.functions
+
+rc=0
+
+case "$daily_status_dmidecode_enable" in
+    [Yy][Ee][Ss])
+	$dmidecode 2>/dev/null |
+	    check_diff dmidecode - "${host} hardware dmi status:"
+	rc=$?;;
+    *)	rc=0;;
+esac
+
+exit $rc
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2014-04-24 06:50:03 UTC
Responsible Changed
From-To: freebsd-ports-bugs->anders

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2015-04-26 13:38:55 UTC
I would have assigned this to you since you're a committer Dmitry, and gladly helped to review it if you dont have a ports bit. But it turns out the maintainer of sysutils/dmidecode is also a committerm, so assign accordingly. Anyone could have done this (correctly assign) since October 2014 btw :)

Dmitry, can you please include your patch as an attachment, updated against ports HEAD if required, as well as the following QA results:

 * portlint -AC
 * poudriere testport (or bulk -t)
Comment 3 Dmitry Morozovsky freebsd_committer freebsd_triage 2015-04-27 10:08:01 UTC
Created attachment 156035 [details]
patch as an attachment

I'm attaching patch against contemporary port state;

While here, it also fixes one small portlint warning about non-compliant patch-Makefile format.

poudriere for 10amd64 and 10i386 passed (unfortunately I have no -CURRENT machine handy to test with)
Comment 4 Dmitry Morozovsky freebsd_committer freebsd_triage 2015-04-27 10:12:44 UTC
Maybe it would be also useful to mention periodic in pkg_display?
Comment 5 Dmitry Morozovsky freebsd_committer freebsd_triage 2015-04-27 10:24:45 UTC
Created attachment 156036 [details]
fixed Makefile

Argh, USE_RC_SUBR is still needed, otherwise dmidecode script misses staging area.
Comment 6 Kurt Jaeger freebsd_committer freebsd_triage 2015-12-06 10:04:38 UTC
Testbuilds fine on 11a, 10.2a+i, 9.3a.
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-12-06 10:05:42 UTC
A commit references this bug:

Author: pi
Date: Sun Dec  6 10:04:51 UTC 2015
New revision: 403097
URL: https://svnweb.freebsd.org/changeset/ports/403097

Log:
  sysutils/dmidecode: add dmidecode to periodic/daily to track hardware changes

  To enable tracking dmidecode diffs in daily mail the admin should
  set the variable daily_status_dmidecode_enable to "YES" in
  /etc/periodic.conf

  PR:		188941
  Submitted by:	marck
  Approved by:	sunpoet (timeout)

Changes:
  head/sysutils/dmidecode/Makefile
  head/sysutils/dmidecode/files/dmidecode.in
  head/sysutils/dmidecode/files/patch-Makefile
Comment 8 Kurt Jaeger freebsd_committer freebsd_triage 2015-12-06 10:06:39 UTC
Committed, thanks.
Comment 9 commit-hook freebsd_committer freebsd_triage 2015-12-07 19:52:36 UTC
A commit references this bug:

Author: pi
Date: Mon Dec  7 19:52:20 UTC 2015
New revision: 403232
URL: https://svnweb.freebsd.org/changeset/ports/403232

Log:
  sysutils/dmidecode: remove rc.d/dmidecode introduced with r403097

  PR:		188941
  Submitted by:	matthew, dim
  Pointy hat to:	pi

Changes:
  head/sysutils/dmidecode/Makefile
Comment 10 commit-hook freebsd_committer freebsd_triage 2015-12-08 06:14:22 UTC
A commit references this bug:

Author: pi
Date: Tue Dec  8 06:14:00 UTC 2015
New revision: 403253
URL: https://svnweb.freebsd.org/changeset/ports/403253

Log:
  sysutils/dmidecode: really fix problem from r403232

  PR:		188941
  Submitted by:	mat

Changes:
  head/sysutils/dmidecode/Makefile