2002-07-03 10:26:30 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
########################################################################
|
|
|
|
|
# #
|
|
|
|
|
# generic utiltiy modules #
|
|
|
|
|
# (c) 2001 jannet it services #
|
|
|
|
|
# contact@jannet.de #
|
|
|
|
|
# #
|
|
|
|
|
# $Id$
|
|
|
|
|
# #
|
|
|
|
|
# This program is free software; permission to use, copy, modify, #
|
|
|
|
|
# distribute, and sell this software and its documentation under the #
|
|
|
|
|
# terms of the GNU Public license as published by the Free Software #
|
|
|
|
|
# Foundation, either version 2 or any later version of the license, is #
|
|
|
|
|
# hereby granted without fee, provided that (i) the above copyright #
|
|
|
|
|
# notices and this permission notice appear in all copies of the #
|
|
|
|
|
# software and related documentation, and (ii) the name of JanNet may #
|
|
|
|
|
# not be used in any advertising or publicity relating to the software #
|
|
|
|
|
# without the specific, prior written permission of JanNet. #
|
|
|
|
|
# #
|
|
|
|
|
# This program is distributed in the hope that it will be useful, but #
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- #
|
|
|
|
|
# TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General #
|
|
|
|
|
# Public License for more details. #
|
|
|
|
|
# #
|
|
|
|
|
# You should have received a copy of the GNU General Public License #
|
|
|
|
|
# along with this program; if not, write to the Free Software Founda- #
|
|
|
|
|
# tion, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
|
|
|
|
|
# #
|
|
|
|
|
########################################################################
|
|
|
|
|
|
2010-07-02 14:02:51 +00:00
|
|
|
usage()
|
|
|
|
|
{
|
|
|
|
|
echo "
|
|
|
|
|
usage: $myname [-h]
|
|
|
|
|
$myname [-v]
|
2016-12-31 14:10:40 +00:00
|
|
|
$myname [-V]
|
2010-07-02 14:02:51 +00:00
|
|
|
"
|
|
|
|
|
[ "$1" ] && exit $1
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-16 10:57:11 +00:00
|
|
|
cmd_name_version()
|
|
|
|
|
{
|
|
|
|
|
if [ -r /etc/os-release ]; then
|
|
|
|
|
. /etc/os-release
|
|
|
|
|
if [ "$opt_verbose" ]; then
|
|
|
|
|
echo $NAME $VERSION
|
2018-02-28 15:16:55 +00:00
|
|
|
exit 0
|
2016-11-16 10:57:11 +00:00
|
|
|
fi
|
2018-02-28 15:16:55 +00:00
|
|
|
if grep -qi tumbleweed /etc/os-release; then
|
|
|
|
|
echo suse-tumbleweed
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
if [ "$ID" != ubuntu ]; then
|
|
|
|
|
[ "$ID_LIKE" ] && ID=$ID_LIKE
|
|
|
|
|
fi
|
|
|
|
|
case "$ID" in
|
|
|
|
|
debian)
|
|
|
|
|
VERSION_NAME=`echo $PRETTY_NAME | awk 'NF>1{print $NF}' | sed 's%/.*%%' | tr '[A-Z]' '[a-z]'`
|
|
|
|
|
case $VERSION_NAME in
|
|
|
|
|
buster) VERSION_ID=10;;
|
|
|
|
|
stretch) VERSION_ID=9;;
|
|
|
|
|
jessie) VERSION_ID=8;;
|
|
|
|
|
wheezy) VERSION_ID=7;;
|
|
|
|
|
squeeze) VERSION_ID=6.0;;
|
|
|
|
|
lenny) VERSION_ID=5.0;;
|
|
|
|
|
etch) VERSION_ID=4.0;;
|
|
|
|
|
sarge) VERSION_ID=3.1;;
|
|
|
|
|
woody) VERSION_ID=3.0;;
|
|
|
|
|
potato) VERSION_ID=2.2;;
|
|
|
|
|
slink) VERSION_ID=2.1;;
|
|
|
|
|
hamm) VERSION_ID=2.0;;
|
|
|
|
|
*)
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
;;
|
|
|
|
|
ubuntu)
|
|
|
|
|
;;
|
|
|
|
|
suse|opensuse)
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
VERSION_ID=42
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
echo $ID-$VERSION_ID | sed 's/opensuse/suse/g'
|
|
|
|
|
exit 0
|
2016-11-16 10:57:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -e /etc/SuSE-release ]; then
|
|
|
|
|
if [ "$opt_verbose" ]; then
|
|
|
|
|
head -1 /etc/SuSE-release
|
|
|
|
|
else
|
|
|
|
|
VERSION="`grep VERSION /etc/SuSE-release | sed -e 's/.*=//; s/ //g'`"
|
|
|
|
|
echo suse-$VERSION
|
|
|
|
|
fi
|
|
|
|
|
exit
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$opt_verbose" ]; then
|
|
|
|
|
uname -a
|
|
|
|
|
else
|
|
|
|
|
uname -r
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmd_version()
|
|
|
|
|
{
|
|
|
|
|
cmd_name_version | cut -d- -f2-
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-12 13:11:49 +00:00
|
|
|
cmd_name()
|
|
|
|
|
{
|
|
|
|
|
cmd_name_version | cut -d- -f1
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-02 14:02:51 +00:00
|
|
|
# --- here we go
|
|
|
|
|
|
|
|
|
|
myname=`basename $0`
|
2014-12-04 19:11:09 +00:00
|
|
|
release_file=/etc/os-release
|
2016-11-16 10:57:11 +00:00
|
|
|
cmd=name_version
|
2010-07-02 14:02:51 +00:00
|
|
|
|
2016-11-16 10:57:11 +00:00
|
|
|
set -- `getopt 'hvV' $*`
|
2010-07-02 14:02:51 +00:00
|
|
|
while [ "$1" != -- ] ; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
-h)
|
|
|
|
|
usage 0
|
|
|
|
|
;;
|
|
|
|
|
-v)
|
|
|
|
|
opt_verbose=1;
|
|
|
|
|
;;
|
2016-11-16 10:57:11 +00:00
|
|
|
-V)
|
|
|
|
|
cmd=version
|
|
|
|
|
;;
|
2010-07-02 14:02:51 +00:00
|
|
|
*)
|
|
|
|
|
usage 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
shift
|
|
|
|
|
done
|
|
|
|
|
shift
|
2002-07-03 10:26:30 +00:00
|
|
|
|
2017-04-25 16:39:32 +00:00
|
|
|
[ "$1" ] && cmd="$1"
|
|
|
|
|
|
2016-11-16 10:57:11 +00:00
|
|
|
eval cmd_$cmd
|
2002-07-03 10:26:30 +00:00
|
|
|
|