VirtualBox

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

Last change on this file since 86186 was 82968, checked in by vboxsync, 5 years 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.1 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-2020 Oracle Corporation
10#
11# This file is part of VirtualBox Open Source Edition (OSE), as
12# available from http://www.virtualbox.org. This file is free software;
13# you can redistribute it and/or modify it under the terms of the GNU
14# General Public License (GPL) as published by the Free Software
15# Foundation, in version 2 as it comes in the "COPYING" file of the
16# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
17# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
18#
19
20# Print information about a Linux system
21# @param distribution name of the distribution
22# @param version version of the distribution
23print_linux_info () {
24 # The following regex is not quite correct for an e-mail address, as
25 # the local part may not start or end with a dot. Please correct if
26 # this upsets you.
27 kern_ver=`cat /proc/version | sed -e 's/ ([a-zA-Z0-9.!#$%*/?^{}\`+=_-]*@[a-zA-Z0-9.-]*)//'`
28 echo "Distribution: $1 | Version: $2 | Kernel: $kern_ver"
29}
30
31# Determine the distribution name and release for a Linux system and print
32# send the information to stdout using the print_linux_info function.
33# For practical reasons (i.e. lack of time), this function only gives
34# information for distribution releases considered "of interest" and reports
35# others as unknown. It can be extended later if other distributions are
36# found to be "of interest".
37get_linux_info () {
38 if which lsb_release > /dev/null 2>&1
39 then
40 # LSB-compliant system
41 print_linux_info `lsb_release -i -s` `lsb_release -r -s`
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