VirtualBox

source: vbox/trunk/src/VBox/Installer/linux/VBoxSysInfo.sh@ 29184

Last change on this file since 29184 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1#!/bin/sh
2
3# @file
4#
5# Installer (Unix-like)
6# Information about the host system/Linux distribution
7
8# Copyright (C) 2006-2007 Oracle Corporation
9#
10# This file is part of VirtualBox Open Source Edition (OSE), as
11# available from http://www.virtualbox.org. This file is free software;
12# you can redistribute it and/or modify it under the terms of the GNU
13# General Public License (GPL) as published by the Free Software
14# Foundation, in version 2 as it comes in the "COPYING" file of the
15# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17#
18
19# Print information about a Linux system
20# @param distribution name of the distribution
21# @param version version of the distribution
22print_linux_info () {
23 # The following regex is not quite correct for an e-mail address, as
24 # the local part may not start or end with a dot. Please correct if
25 # this upsets you.
26 kern_ver=`cat /proc/version | sed -e 's/ ([a-zA-Z0-9.!#$%*/?^{}\`+=_-]*@[a-zA-Z0-9.-]*)//'`
27 echo "Distribution: $1 | Version: $2 | Kernel: $kern_ver"
28}
29
30# Determine the distribution name and release for a Linux system and print
31# send the information to stdout using the print_linux_info function.
32# For practical reasons (i.e. lack of time), this function only gives
33# information for distribution releases considered "of interest" and reports
34# others as unknown. It can be extended later if other distributions are
35# found to be "of interest".
36get_linux_info () {
37 if [ -r /etc/lsb-release ] && grep Ubuntu /etc/lsb-release >/dev/null 2>&1
38 then
39 # Ubuntu-based system
40 . /etc/lsb-release
41 print_linux_info "Ubuntu" $DISTRIB_RELEASE
42 elif [ -r /etc/debian_version ]
43 then
44 # Debian-based system
45 release=`cat /etc/debian_version`
46 print_linux_info "Debian" $release
47 elif [ -r /etc/mandriva-release ]
48 then
49 # Mandriva-based system
50 release=`cat /etc/mandriva-release | sed -e 's/[A-Za-z ]* release //'`
51 print_linux_info "Mandriva" $release
52 elif [ -r /etc/fedora-release ]
53 then
54 # Fedora-based
55 release=`cat /etc/fedora-release | sed -e 's/[A-Za-z ]* release //'`
56 print_linux_info "Fedora" $release
57 elif [ -r /etc/SuSE-release ]
58 then
59 # SUSE-based.
60 release=`cat /etc/SuSE-release | grep "VERSION" | sed -e 's/VERSION = //'`
61 if grep openSUSE /etc/SuSE-release
62 then
63 # Is it worth distinguishing here? I did it mainly to prevent
64 # confusion with the version number
65 print_linux_info "openSUSE" $release
66 else
67 print_linux_info "SUSE" $release
68 fi
69 elif [ -r /etc/gentoo-release ]
70 then
71 # Gentoo-based
72 release=`cat /etc/gentoo-release | sed -e 's/[A-Za-z ]* release //'`
73 print_linux_info "Gentoo" $release
74 elif [ -r /etc/slackware-version ]
75 then
76 # Slackware
77 release=`cat /etc/slackware-version | sed -e 's/Slackware //'`
78 print_linux_info "Slackware" $release
79 elif [ -r /etc/arch-release ]
80 then
81 # Arch Linux
82 print_linux_info "Arch Linux" "none"
83 elif [ -r /etc/redhat-release ]
84 then
85 # Redhat-based. This should come near the end, as it other
86 # distributions may give false positives.
87 release=`cat /etc/redhat-release | sed -e 's/[A-Za-z ]* release //'`
88 print_linux_info "Redhat" $release
89 else
90 print_linux_info "unknown" "unknown"
91 fi
92}
93
94# Print information about a Solaris system. FIXME.
95get_solaris_info () {
96 kernel=`uname -v`
97 echo "Kernel: $kernel"
98}
99
100# Print information about a MacOS system. FIXME.
101get_macos_info () {
102 machine=`uname -m`
103 kernel=`uname -v`
104 echo "Machine: $machine | Kernel: $kernel"
105}
106
107# Print information about a FreeBSD system. FIXME.
108get_freebsd_info () {
109 kernel=`uname -v`
110 echo "Kernel: $kernel"
111}
112
113system=`uname -s`
114case "$system" in
115Linux|linux)
116 get_linux_info
117 ;;
118SunOS)
119 get_solaris_info
120 ;;
121Darwin)
122 get_macos_info
123 ;;
124FreeBSD)
125 get_freebsd_info
126 ;;
127*)
128 echo "System unknown"
129 exit 1
130 ;;
131esac
132exit 0
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette