VirtualBox

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

Last change on this file since 98417 was 98103, checked in by vboxsync, 22 months ago

Copyright year updates by scm.

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