Miscellaneous inspection tricks with guestfish

This requires libguestfs ≥ 1.7.5, but could be adjusted to work on 1.6

#!/bin/bash -

set -e


# Running a local copy:
# or:

# Run guestfish as a service.
eval "$($guestfish --listen -d $guest -i)"

# Get the root device.
root="$($guestfish --remote inspect-get-roots)"

# Print some inspection information.
echo "Product name:" "$($guestfish --remote inspect-get-product-name $root)"
echo "OS type:" "$($guestfish --remote inspect-get-type $root)"
echo "Major version:" "$($guestfish --remote inspect-get-major-version $root)"
echo "Minor version:" "$($guestfish --remote inspect-get-minor-version $root)"
echo "OS distro:" "$($guestfish --remote inspect-get-distro $root)"
echo "Architecture:" "$($guestfish --remote inspect-get-arch $root)"
echo "Package manager:" "$($guestfish --remote inspect-get-package-management $root)"
echo "Package format:" "$($guestfish --remote inspect-get-package-format $root)"

# Shut down guestfish service.
$guestfish --remote exit

Now we run this against various guests:

# /tmp/test.sh F14x64
Product name: Fedora release 14 (Laughlin)
OS type: linux
Major version: 14
Minor version: 0
OS distro: fedora
Architecture: x86_64
Package manager: yum
Package format: rpm
# /tmp/test.sh Win7x32
Product name: Windows 7 Enterprise
OS type: windows
Major version: 6
Minor version: 1
OS distro: windows
Architecture: i386
Package manager: unknown
Package format: unknown
# /tmp/test.sh RHEL4x64
Product name: Red Hat Enterprise Linux AS release 4 (Nahant Update 8)
OS type: linux
Major version: 4
Minor version: 8
OS distro: rhel
Architecture: x86_64
Package manager: up2date
Package format: rpm

Leave a comment

Filed under Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.