VBoxSysInfo.sh revision 7e443c8da6e409ead5037f14fde35b0d43440155
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#!/bin/sh
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# @file
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Installer (Unix-like)
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Information about the host system/Linux distribution
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Copyright (C) 2006-2007 innotek GmbH
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# available from http://www.virtualbox.org. This file is free software;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# you can redistribute it and/or modify it under the terms of the GNU
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# General Public License as published by the Free Software Foundation,
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# be useful, but WITHOUT ANY WARRANTY of any kind.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Print information about a Linux system
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# @param distribution name of the distribution
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# @param version version of the distribution
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncprint_linux_info () {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync # The following regex is not quite correct for an e-mail address, as
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync # the local part may not start or end with a dot. Please correct if
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync # this upsets you.
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync kern_ver=`cat /proc/version | sed -e 's/ ([a-zA-Z0-9.!#$%*/?^{}\`+=_-]*@[a-zA-Z0-9.-]*)//'`
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync echo "Distribution: $1 | Version: $2 | Kernel: $kern_ver"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync}
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync# Determine the distribution name and release for a Linux system and print
# send the information to stdout using the print_linux_info function.
# For practical reasons (i.e. lack of time), this function only gives
# information for distribution releases considered "of interest" and reports
# others as unknown. It can be extended later if other distributions are
# found to be "of interest".
get_linux_info () {
if [ -r /etc/lsb-release ] && grep Ubuntu /etc/lsb-release >/dev/null 2>&1
then
# Ubuntu-based system
. /etc/lsb-release
print_linux_info "Ubuntu" $DISTRIB_RELEASE
elif [ -r /etc/debian_version ]
then
# Debian-based system
release=`cat /etc/debian_version`
print_linux_info "Debian" $release
elif [ -r /etc/mandriva-release ]
then
# Mandriva-based system
release=`cat /etc/mandriva-release | sed -e 's/[A-Za-z ]* release //'`
print_linux_info "Mandriva" $release
elif [ -r /etc/fedora-release ]
then
# Fedora-based
release=`cat /etc/fedora-release | sed -e 's/[A-Za-z ]* release //'`
print_linux_info "Fedora" $release
elif [ -r /etc/SuSE-release ]
then
# SUSE-based.
release=`cat /etc/SuSE-release | grep "VERSION" | sed -e 's/VERSION = //'`
if grep openSUSE /etc/SuSE-release
then
# Is it worth distinguishing here? I did it mainly to prevent
# confusion with the version number
print_linux_info "openSUSE" $release
else
print_linux_info "SUSE" $release
fi
elif [ -r /etc/gentoo-release ]
then
# Gentoo-based
release=`cat /etc/gentoo-release | sed -e 's/[A-Za-z ]* release //'`
print_linux_info "Gentoo" $release
elif [ -r /etc/slackware-version ]
then
# Slackware
release=`cat /etc/slackware-version | sed -e 's/Slackware //'`
print_linux_info "Slackware" $release
elif [ -r /etc/arch-release ]
then
# Arch Linux
print_linux_info "Arch Linux" "none"
elif [ -r /etc/redhat-release ]
then
# Redhat-based. This should come near the end, as it other
# distributions may give false positives.
release=`cat /etc/redhat-release | sed -e 's/[A-Za-z ]* release //'`
print_linux_info "Redhat" $release
else
print_linux_info "unknown" "unknown"
fi
}
# Print information about a Solaris system. FIXME.
get_solaris_info () {
kernel=`uname -v`
echo "Kernel: $kernel"
}
# Print information about a MacOS system. FIXME.
get_macos_info () {
machine=`uname -m`
kernel=`uname -v`
echo "Machine: $machine | Kernel: $kernel"
}
# Print information about a FreeBSD system. FIXME.
get_freebsd_info () {
kernel=`uname -v`
echo "Kernel: $kernel"
}
system=`uname -s`
case "$system" in
Linux|linux)
get_linux_info
;;
SunOS)
get_solaris_info
;;
Darwin)
get_macos_info
;;
FreeBSD)
get_freebsd_info
;;
*)
echo "System unknown"
exit 1
;;
esac
exit 0