[-]
[+]
|
Changed |
_service:set_version:ix-inventory-system.spec
|
|
[-]
[+]
|
Changed |
_service:recompress:tar_scm:inventory-system-0.0.6705.tar.bz2/TODO
^
|
@@ -2,18 +2,50 @@
- needed Debian 6 packages:
uuid-runtime
- virt-what >= 1.12-1 (needs package build with symlink from virt-what to virtwhat)
+ virt-what >= 1.12-1 (needs package build with symlink from virt-what to virtwhat, buggy xen-domU detection)
ipmitool
lsb-release
ethtool
lshw >= 02.16-1 (needs package build, because 02.14-1 of Debian 6 is buggy)
dmidecode
-- package requirements in script
- - either remove rpm from list or split (out) for rpm and deb based systems
+- build a .deb package
-- autoupdater
-- get_system_software
-- get_system_memory (needs check, test returned 0 as value)
+* FreeBSD support:
+ - get_system_uuid
+ sysctl kern.hostuuid|awk '{print toupper($2)}'
+ - get_system_cpu
+ sysctl hw.model | awk -F": " '{print $2} ' | sed -r 's@ +@ @g'
+ - get_system_memory
+ expr `sysctl hw.physmem|awk '{print $2}'` / 1024 / 1024
-- build a .deb package
+ - get_system_default_ip
+ - get_system_ipv4
+ - get_system_ipv6
+
+ - get_system_disk_sizes
+ kern.disks:
+ kern.geom.conftxt:
+ - get_system_software
+ pkglst="" ; for pkg in `pkg_info | awk '{print $1}'` ; do pkglst="$pkglst $pkg"; done ; echo $pkglst
+
+
+* OpenBSD support:
+ - get_system_uuid
+ sysctl hw.uuid |awk -F= '{print toupper($2)}'
+ - get_system_cpu
+ sysctl hw.model | awk -F= '{print $2}'
+ - get_system_manufacturer
+ sysctl hw.vendor | awk -F= '{print $2}'
+ - get_system_productname
+ sysctl hw.product | awk -F= '{print $2}'
+ - get_system_memory
+ expr `sysctl hw.physmem | awk -F= '{print $2 }'` / 1024 / 1024
+
+ - get_system_default_ip
+ - get_system_ipv4
+ - get_system_ipv6
+ - get_system_disk_sizes
+
+ - get_system_software
+ pkglst="" ; for pkg in `pkg_info | awk '{print $1}'` ; do pkglst="$pkglst $pkg"; done ; echo $pkglst
|
[-]
[+]
|
Added |
_service:recompress:tar_scm:inventory-system-0.0.6705.tar.bz2/client/cron.reboot
^
|
@@ -0,0 +1 @@
+@reboot /etc/cron.daily/inventorysystem
|
[-]
[+]
|
Changed |
_service:recompress:tar_scm:inventory-system-0.0.6705.tar.bz2/client/inventory-system.sh
^
|
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/usr/bin/env bash
# Inventory System
# Author: Carsten Schoene
-# $LastChangedDate: 2013-08-02 20:41:57 +0200 (Fri, 02 Aug 2013) $
-# $Rev: 6370 $
+# $LastChangedDate: 2013-10-06 11:06:31 +0200 (Sun, 06 Oct 2013) $
+# $Rev: 6703 $
#
# Default options (can be changed by inventory-system.conf)
DEBUG="yes"
@@ -30,10 +30,9 @@
curl
lsb_release
uuidgen
-virtwhat
+virt-what
hostname
ip
-rpm
ls
df
date
@@ -45,6 +44,15 @@
dmsetup
"
+PKGMGR_COMMANDS="
+rpm
+dpkg
+dpkg-query
+aptitude
+yum
+zypper
+"
+
# clean old logfile
rm -f /tmp/inventory-system.log
@@ -67,8 +75,8 @@
# check required commands
for CMD in ${REQUIRED_COMMANDS} ; do
- CMDNAME=`echo ${CMD} | awk '{print toupper($1) }'`
- export $(eval "echo $CMDNAME")=`which ${CMD} 2>/dev/null`
+ CMDNAME=`echo ${CMD} | awk '{print toupper($1) }' | sed -e s@"-"@""@g`
+ export $(eval "echo ${CMDNAME}")=`which ${CMD} 2>/dev/null`
if [ -z "${!CMDNAME}" ] ; then
debug "Command: ${CMD} not found!"
exit 1
@@ -77,6 +85,18 @@
fi
done
+# check for package manager commands
+for CMD in ${PKGMGR_COMMANDS} ; do
+ CMDNAME=`echo ${CMD} | awk '{print toupper($1) }' | sed -e s@"-"@""@g`
+ export $(eval "echo ${CMDNAME}")=`which ${CMD} 2>/dev/null`
+ if [ -z "${!CMDNAME}" ] ; then
+ debug "Command: ${CMD} not found, skipped!"
+ # no exit here because not all commands are available on every os
+ else
+ debug "Found command $(echo $CMDNAME) in ${!CMDNAME}"
+ fi
+done
+
# check if we are running as root
MYUID=`${ID} -u`
if [ "${MYUID}" != "0" ] ; then
@@ -200,40 +220,76 @@
# autoupdate function
function autoupdate {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
- PKG=`${RPM} -qf --queryformat '%{name}\n' $0 | ${GREP} -v "^file /"`
- YUM=`which yum 2>/dev/null`
- ZYP=`which zypper 2>/dev/null`
- if [ -n "${PKG}" ] ; then
- if [ -n "${YUM}" ] && [ -f /etc/redhat-release ] ; then
- CUPD="`${YUM} check-update ${PK} | ${TAIL} -n1 | ${AWK} '{print $1}'`"
- if [ -n "${CUPD}" ] ; then
- ${YUM} -q -y update ${PKG}
- fi
- elif [ -n "${ZYP}" ] && [ -f /etc/SuSE-release ] ; then
- REL=`${LSB_RELEASE} -r | ${AWK} '{print $NF}'`
- case ${REL} in
- 11|11.1|11.2|11.3|11.4|12.1|12.2|12.3)
- CUPD="`${ZYP} -q lu | ${GREP} ${PKG}`"
- if [ -n "${CUPD}" ] ; then
- ${ZYP} -q -n update ${PKG}
- fi
- ;;
- 10)
- CUPD="`${ZYP} -t lu -t package | ${GREP} ${PKG}`"
- if [ -n "${CUPD}" ] ; then
- ${ZYP} -t -n install -y -t package ${PKG}
- fi
- ;;
- esac
- fi
- fi
+ case `get_system_os` in
+ Debian*|Ubuntu*)
+ PKG=`${DPKG} -S $0 | ${GREP} -v ^dpkg | ${AWK} -F: '{print $1}'`
+ if [ -n "${PKG}" ] ; then
+ if [ -n "${APTITUDE}" ] ; then
+ ${APTITUDE} -q -y update >/dev/null 2>&1
+ ${APTITUDE} -q -y install ${PKG} >/dev/null 2>&1
+ fi
+ fi
+ ;;
+ *)
+ PKG=`${RPM} -qf --queryformat '%{name}\n' $0 | ${GREP} -v "^file /"`
+ if [ -n "${PKG}" ] ; then
+ if [ -n "${YUM}" ] && [ -f /etc/redhat-release ] ; then
+ CUPD="`${YUM} check-update ${PK} | ${TAIL} -n1 | ${AWK} '{print $1}'`"
+ if [ -n "${CUPD}" ] ; then
+ ${YUM} -q -y update ${PKG}
+ fi
+ elif [ -n "${ZYPPER}" ] && [ -f /etc/SuSE-release ] ; then
+ REL=`${LSB_RELEASE} -r | ${AWK} '{print $NF}'`
+ case ${REL} in
+ 11|11.1|11.2|11.3|11.4|12.1|12.2|12.3)
+ CUPD="`${ZYPPER} -q lu | ${GREP} ${PKG}`"
+ if [ -n "${CUPD}" ] ; then
+ ${ZYPPER} -q -n update ${PKG}
+ fi
+ ;;
+ 10)
+ CUPD="`${ZYPPER} -t lu -t package | ${GREP} ${PKG}`"
+ if [ -n "${CUPD}" ] ; then
+ ${ZYPPER} -t -n install -y -t package ${PKG}
+ fi
+ ;;
+ esac
+ fi
+ fi
+ ;;
+ esac
+}
+
+# get product name
+function get_system_productname {
+ [ "`is_disabled $FUNCNAME`" == "1" ] && return
+ case `get_system_type` in
+ xen-dom0|baremetal|kvm|vmware)
+ PRODNAME=`${DMIDECODE} -s system-product-name`
+ ;;
+ *)
+ PRODNAME="n/a"
+ ;;
+ esac
+ debug "SYSTEM-PRODUCTNAME: ${PRODNAME}"
+ echo ${PRODNAME}
}
# get unique system uuid
function get_system_uuid {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
# newer systems have uuid integrated
- UUID=`${LSHW} -quiet -C system | ${GREP} "configuration:" | ${GREP} -i uuid | ${SED} -e 's@.*[ \s]uuid=@@i'`
+
+ # workaround for DELL CloudEdge Servers with duplicate UUIDs
+ case `get_system_productname` in
+ "PowerEdge C61*"|C61*)
+ UUID=""
+ ;;
+ *)
+ UUID=`${LSHW} -quiet -C system | ${GREP} "configuration:" | ${GREP} -i uuid | ${SED} -e 's@.*[ \s]uuid=@@i'`
+ ;;
+ esac
+
# for older systems or virtual create one and save it for later use
if [ "${UUID}" == "" ] ; then
if [ ! -s /etc/system-inventory.uuid ] ; then
@@ -313,7 +369,7 @@
[ "`is_disabled $FUNCNAME`" == "1" ] && return
INSTMEM=0
case `get_system_type` in
- xen-domU|openvz)
+ xen|xen-domU|openvz)
INSTMEM=`${CAT} /proc/meminfo | ${GREP} "^MemTotal:" | ${AWK} '{print int($2/1024)}'`
;;
*)
@@ -413,21 +469,6 @@
echo ${DEV_SIZES}
}
-# get product name
-function get_system_productname {
- [ "`is_disabled $FUNCNAME`" == "1" ] && return
- case `get_system_type` in
- xen-dom0|baremetal|kvm|vmware)
- PRODNAME=`${DMIDECODE} -s system-product-name`
- ;;
- *)
- PRODNAME="n/a"
- ;;
- esac
- debug "SYSTEM-PRODUCTNAME: ${PRODNAME}"
- echo ${PRODNAME}
-}
-
# get system vendor
function get_system_manufacturer {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
@@ -654,7 +695,14 @@
# get rpm package list
function get_system_software {
[ "`is_disabled $FUNCNAME`" == "1" ] && return
- PACKAGES=`${RPM} -qa --queryformat '%{name}-%{version}-%{release}.%{arch} '`
+ case `get_system_os` in
+ Debian*|Ubuntu*)
+ PACKAGES=`${DPKGQUERY} -W -f '${Package}-${Version}.${Architecture} ' | ${SED} -e s@"\+"@"_"@g`
+ ;;
+ *)
+ PACKAGES=`${RPM} -qa --queryformat '%{name}-%{version}-%{release}.%{arch} '`
+ ;;
+ esac
debug "SYSTEM-SOFTWARE: ${PACKAGES}"
echo ${PACKAGES}
}
|
[-]
[+]
|
Added |
_service:set_version:ix-inventory-system.dsc
^
|
@@ -0,0 +1,11 @@
+Format: 1.0
+Source: ix-inventory-system
+Binary: ix-inventory-system
+Architecture: any
+Version: 0.0.6705
+Maintainer: Carsten Schoene <cs@linux-administrator.com>
+Standards-Version: 0.0.1
+Build-Depends: cdbs, cmake, debhelper
+Files:
+ 0323ebdd4a1983de61a5e4f326194426 20710 inventory-system_0.0.1.orig.tar.gz
+
|
[-]
[+]
|
Added |
debian.changelog
^
|
@@ -0,0 +1,5 @@
+ix-inventory-system (0.0.1-1) stable; urgency=low
+
+ * Initial Release
+
+ -- Carsten Schoene <cs@linux-administrator.com> Sun, 06 Oct 2013 15:04:38 +0100
|
[-]
[+]
|
Added |
debian.control
^
|
@@ -0,0 +1,14 @@
+Source: ix-inventory-system
+Section: unknown
+Priority: extra
+Maintainer: Carsten Schoene <cs@linux-administrator.com>
+Build-Depends: debhelper (>= 4.1.16)
+Homepage: http://www.linux-administrator.com/
+
+Package: ix-inventory-system
+Architecture: any
+Depends: virt-what (>= 1.13), lshw (>= 02.16), uuid-runtime, ipmitool, lsb-release, ethtool, dmidecode, curl, dmsetup
+Description: System inventory client
+ System inventory reporting tool. It uses various tools
+ to detect system information and hardware, virtualization type,
+ serial and so on.
|
[-]
[+]
|
Added |
debian.debtransform
^
|
@@ -0,0 +1 @@
+Dummy file for triggering debtransform
|
[-]
[+]
|
Added |
debian.rules
^
|
@@ -0,0 +1,85 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=5
+export DESTDIR=/usr/src/packages/BUILD/debian/ix-inventory-system
+
+CFLAGS = -g
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+CFLAGS += -O0
+else
+CFLAGS += -O2
+endif
+
+build: build-stamp
+build-stamp:
+ dh_testdir
+
+ # --- end custom part for compiling
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Add here commands to clean up after the build process.
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package
+ install -D -m755 client/inventory-system.sh $(DESTDIR)/usr/sbin/inventory-system
+ install -D -m755 client/cron.daily $(DESTDIR)/etc/cron.daily/inventorysystem
+ install -D -m644 client/cron.reboot $(DESTDIR)/etc/cron.d/inventory-system
+ install -D -m644 ../SOURCES/inventory-system.conf $(DESTDIR)/etc/inventory-system.conf
+ install -D -m755 client/ix-functions.sh $(DESTDIR)/etc/inventory-system.d/ix-functions.sh
+ # --- end custom part for installing
+
+# Build architecture-independent files here.
+binary-indep: build install
+ # We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+# dh_installdebconf
+ dh_installdocs
+ dh_installexamples
+ dh_installmenu
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+ dh_installcron
+ dh_installman
+ dh_installinfo
+# dh_undocumented
+ dh_installchangelogs
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_makeshlibs
+ dh_installdeb
+# dh_perl
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
|
[-]
[+]
|
Added |
ix-inventory-system.dsc
^
|
@@ -0,0 +1,11 @@
+Format: 1.0
+Source: ix-inventory-system
+Binary: ix-inventory-system
+Architecture: any
+Version: 0.0.1-1
+Maintainer: Carsten Schoene <cs@linux-administrator.com>
+Standards-Version: 0.0.1
+Build-Depends: cdbs, cmake, debhelper
+Files:
+ 0323ebdd4a1983de61a5e4f326194426 20710 inventory-system_0.0.1.orig.tar.gz
+
|