Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
Beam Positoning Monitor - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Beam Positoning Monitor - Software
Commits
830390bc
Commit
830390bc
authored
Feb 05, 2016
by
Lucas Russo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scripts/*: add script to detect distribution
parent
2b94d7a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
87 additions
and
0 deletions
+87
-0
get-os-distro.sh
scripts/get-os-distro.sh
+87
-0
No files found.
scripts/get-os-distro.sh
0 → 100755
View file @
830390bc
#!/usr/bin/env bash
# Detects which OS and if it is Linux then it will detect which Linux Distribution.
OS
=
`
uname
-s
`
REV
=
`
uname
-r
`
MACH
=
`
uname
-m
`
GetVersionFromFile
()
{
VERSION
=
`
cat
$1
|
tr
"
\n
"
' '
|
sed
s/.
*
VERSION.
*
=
\
//
`
}
function
usage
()
{
echo
"Usage:
$0
[-d <Print distribution name only>] [-r <Print distribution revision only>]"
}
DIST_ONLY
=
0
REV_ONLY
=
0
# Get command line options
while
getopts
":dr"
opt
;
do
case
$opt
in
d
)
DIST_ONLY
=
1
;;
r
)
REV_ONLY
=
1
;;
\?
)
echo
"Invalid option: -
$OPTARG
"
>
&2
usage
exit
1
;;
:
)
echo
"Option -
$OPTARG
requires an argument."
>
&2
usage
exit
1
;;
esac
done
# Check some OSes and Distro
if
[
"
${
OS
}
"
=
"SunOS"
]
;
then
OS
=
Solaris
ARCH
=
`
uname
-p
`
# OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
elif
[
"
${
OS
}
"
=
"AIX"
]
;
then
OSSTR
=
"
${
OS
}
`
oslevel
`
(
`
oslevel
-r
`
)"
elif
[
"
${
OS
}
"
=
"Linux"
]
;
then
KERNEL
=
`
uname
-r
`
if
[
-f
/etc/redhat-release
]
;
then
DIST
=
'RedHat'
PSUEDONAME
=
`
cat
/etc/redhat-release |
sed
s/.
*
\(
// |
sed
s/
\)
//
`
REV
=
`
cat
/etc/redhat-release |
sed
s/.
*
release
\
// |
sed
s/
\
.
*
//
`
elif
[
-f
/etc/fedora-release
]
;
then
DIST
=
'Fedora'
PSUEDONAME
=
`
cat
/etc/fedora-release |
sed
s/.
*
\(
// |
sed
s/
\)
//
`
REV
=
`
cat
/etc/fedora-release |
sed
s/.
*
release
\
// |
sed
s/
\
.
*
//
`
elif
[
-f
/etc/SUSE-release
]
;
then
DIST
=
`
cat
/etc/SUSE-release |
tr
"
\n
"
' '
|
sed
s/VERSION.
*
//
`
REV
=
`
cat
/etc/SUSE-release |
tr
"
\n
"
' '
|
sed
s/.
*
=
\
//
`
elif
[
-f
/etc/lsb-release
]
;
then
DIST
=
'Ubuntu'
PSUEDONAME
=
`
cat
/etc/lsb-release |
grep
"DISTRIB_CODENAME=.*"
|
sed
's/DISTRIB_CODENAME=\(.*\)/\1/'
`
REV
=
`
cat
/etc/lsb-release |
grep
"DISTRIB_RELEASE=.*"
|
sed
's/DISTRIB_RELEASE=\(.*\)/\1/'
`
elif
[
-f
/etc/debian_version
]
;
then
DIST
=
"Debian
`
cat
/etc/debian_version
`
"
REV
=
""
fi
OSSTR
=
"
${
OS
}
${
DIST
}
${
REV
}
(
${
PSUEDONAME
}
${
KERNEL
}
${
MACH
}
)"
fi
OUT
=
if
[
"
${
DIST_ONLY
}
"
=
0
]
&&
[
"
${
REV_ONLY
}
"
=
0
]
;
then
OUT+
=
${
OSSTR
}
else
if
[
"
${
DIST_ONLY
}
"
=
1
]
;
then
OUT+
=
"
${
DIST
}
"
fi
if
[
"
${
REV_ONLY
}
"
=
1
]
;
then
OUT+
=
"
${
REV
}
"
fi
fi
echo
${
OUT
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment