Mise à jour du script de vérification version/arch.
authorProgfou <jean-christophe.andre@auf.org>
Thu, 28 Apr 2011 06:50:52 +0000 (13:50 +0700)
committerProgfou <jean-christophe.andre@auf.org>
Thu, 28 Apr 2011 06:50:52 +0000 (13:50 +0700)
sysadmin/sysadmin-check-version-arch

index 09c42ea..6f32578 100755 (executable)
@@ -45,17 +45,17 @@ display_host() {
     expected_arch="${EXPECTED_DEBIAN_ARCH}"
     accepted_arch="${ACCEPTED_DEBIAN_ARCH}"
   else
-    echo 'Système non reconnu !'
+    dist="`colorize red "${dist}"`"
   fi
   if [ "${version}" = "${expected_version}" ] ; then
-    version="`colorize green "$version"`"
+    version="`colorize green "${version}"`"
   elif [ "${version}" != "${accepted_version}" ] ; then
-    version="`colorize red "$version"`"
+    version="`colorize red "${version}"`"
   fi
-  if [ "$arch" = "${expected_arch}" ] ; then
-    arch="`colorize green "$arch"`"
-  elif [ "$arch" != "${accepted_arch}" ] ; then
-    arch="`colorize red "$arch"`"
+  if [ "${arch}" = "${expected_arch}" ] ; then
+    arch="`colorize green "${arch}"`"
+  elif [ "${arch}" != "${accepted_arch}" ] ; then
+    arch="`colorize red "${arch}"`"
   fi
   printf "%-25s: %s %s (%s)\n" "${name}" "${dist}" "${version}" "${arch}"
 }
@@ -64,15 +64,20 @@ display_host "CT 0 (host)" "`lsb_release -si`" "`lsb_release -sr`" "`uname -m`"
 if test -x /usr/sbin/vzctl
 then
   IDS="`vzlist -H -o ctid`"
-  if [ -n "$IDS" ] ; then
-    for id in $IDS
+  if [ -n "${IDS}" ] ; then
+    for id in ${IDS}
     do
       name="`sed -n '/^NAME=/s/^.*="\?\([^"]*\)"\?.*$/\1/p' /etc/vz/conf/${id}.conf`"
       if [ -z "${name}" ] ; then
         name="`sed -n '/^HOSTNAME=/s/^.*="\?\([^"]*\)"\?.*$/\1/p' /etc/vz/conf/${id}.conf`"
       fi
       dist="`vzctl exec ${id} lsb_release -si 2>/dev/null`"
-      version="`vzctl exec ${id} lsb_release -sr 2>/dev/null`"
+      if [ -n "${dist}" ] ; then
+        version="`vzctl exec ${id} lsb_release -sr 2>/dev/null`"
+      else
+        dist="(paquet lsb-release manquant)"
+        version="???"
+      fi
       arch="`vzctl exec ${id} uname -m`"
       display_host "CT ${id} (${name})" "${dist}" "${version}" "${arch}"
     done