Changes of Revision 103
[-] | Changed | _service:set_version:inventory-system.spec |
1
2 %define pkgname inventory-system 3 Name: inventory-system 4 Release: 0 5 -Version: 0.0.6370 6 +Version: 0.0.6381 7 Url: http://www.linux-administrator.com/ 8 License: GPLv2 9 Group: System 10 |
||
[+] | Changed | _service:recompress:tar_scm:inventory-system-0.0.6381.tar.bz2/TODO ^ |
@@ -2,18 +2,11 @@ - 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 - -- autoupdater -- get_system_software -- get_system_memory (needs check, test returned 0 as value) - - build a .deb package | ||
[+] | Changed | _service:recompress:tar_scm:inventory-system-0.0.6381.tar.bz2/client/inventory-system.sh ^ |
@@ -1,8 +1,8 @@ #!/bin/bash # Inventory System # Author: Carsten Schoene -# $LastChangedDate: 2013-08-02 20:41:57 +0200 (Fri, 02 Aug 2013) $ -# $Rev: 6370 $ +# $LastChangedDate: 2013-08-05 22:54:19 +0200 (Mon, 05 Aug 2013) $ +# $Rev: 6380 $ # # Default options (can be changed by inventory-system.conf) DEBUG="yes" @@ -33,7 +33,6 @@ virtwhat hostname ip -rpm ls df date @@ -45,6 +44,12 @@ dmsetup " +PGKMGR_COMMANDS=" +rpm +dpkg +aptitude +" + # clean old logfile rm -f /tmp/inventory-system.log @@ -77,6 +82,18 @@ fi done +# check for package manager commands +for CMD in ${PGKMGR_COMMANDS} ; do + CMDNAME=`echo ${CMD} | awk '{print toupper($1) }'` + 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,33 +217,46 @@ # 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 /"` + 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 + ;; + esac } # get unique system uuid @@ -313,7 +343,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)}'` ;; *) @@ -654,7 +684,16 @@ # 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*) + for pkg in `${DPKG} -l | ${GREP} ^ii | ${AWK} '{print $2"-"$3}' | ${AWK} -F+ '{print $1}'` ; do + PACKAGES="${PACKAGES} ${pkg}" + done + ;; + *) + PACKAGES=`${RPM} -qa --queryformat '%{name}-%{version}-%{release}.%{arch} '` + ;; + esac debug "SYSTEM-SOFTWARE: ${PACKAGES}" echo ${PACKAGES} } | ||
[+] | Added | debian.debtransform ^ |
@@ -0,0 +1 @@ +dummy file for triggering debtransform |