update
This commit is contained in:
112
default.inc
112
default.inc
@@ -45,8 +45,116 @@ else
|
||||
ATYPE="unknown"
|
||||
#exit 1
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
# Script outputs results in the format that can either be parsed or
|
||||
# directly eval'ed in Bourne shell:
|
||||
#
|
||||
# Example
|
||||
# -----------
|
||||
# sherlock
|
||||
# OS=Linux
|
||||
# MACH=x86_64
|
||||
# KERNEL=2.6.32-5-amd64
|
||||
# DISTRIBUTION=debian
|
||||
# FAMILY=debian
|
||||
# DERIVATIVE=Debian
|
||||
# RELEASE=6.0.6
|
||||
# CODENAME=squeeze
|
||||
#
|
||||
|
||||
detect_os () {
|
||||
|
||||
OS=`uname -s`
|
||||
MACH=`uname -m`
|
||||
|
||||
echo OS=$OS
|
||||
echo MACH=$MACH
|
||||
|
||||
if [ "${OS}" = "SunOS" ] ; then
|
||||
echo ARCH=`uname -p`
|
||||
OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
|
||||
echo FAMILY=solaris
|
||||
elif [ "${OS}" = "AIX" ] ; then
|
||||
echo OSSTR="${OS} `oslevel` (`oslevel -r`)"
|
||||
echo FAMILY=aix
|
||||
elif [ "${OS}" = "Darwin" ] ; then
|
||||
echo REV=`uname -r`
|
||||
echo FAMILY=macosx
|
||||
elif [ "${OS}" = "Linux" ] ; then
|
||||
echo KERNEL="`uname -r`"
|
||||
linux_distro
|
||||
fi
|
||||
}
|
||||
|
||||
redhat_derivative () {
|
||||
|
||||
local FILE=/etc/redhat-release
|
||||
|
||||
grep -i 'red.*hat.*enterprise.*linux' $FILE 2>&1 > /dev/null && { echo DERIVATIVE=rhel; return; }
|
||||
grep -i 'red.*hat.*linux' $FILE 2>&1 > /dev/null && { echo DERIVATIVE=rh; return; }
|
||||
grep -i 'cern.*e.*linux' $FILE 2>&1 > /dev/null && { echo DERIVATIVE=cel; return; }
|
||||
grep -i 'scientific linux cern' $FILE 2>&1 > /dev/null && { echo DERIVATIVE=slc; return; }
|
||||
grep -i 'centos' $FILE 2>&1 > /dev/null && { echo DERIVATIVE=centos; return; }
|
||||
|
||||
echo DERIVATIVE=unknown
|
||||
}
|
||||
|
||||
redhat_release () {
|
||||
echo RELEASE=`tr -d 'a-zA-Z [](){}' < /etc/redhat-release`
|
||||
}
|
||||
|
||||
debian_derivative () {
|
||||
if which lsb_release 2>&1 > /dev/null ; then
|
||||
echo DERIVATIVE=`lsb_release --id --short 2> /dev/null`
|
||||
echo RELEASE=`lsb_release --release --short 2> /dev/null`
|
||||
echo CODENAME=`lsb_release --codename --short 2> /dev/null`
|
||||
return
|
||||
else
|
||||
echo DERIVATIVE=unknown
|
||||
echo RELEASE=`cat /etc/debian_version`
|
||||
echo CODENAME=unknown
|
||||
return
|
||||
fi
|
||||
}
|
||||
|
||||
linux_distro () {
|
||||
|
||||
if [ -f /etc/redhat-release ] ; then
|
||||
echo DISTRIBUTION=redhat
|
||||
echo FAMILY=rh
|
||||
redhat_derivative
|
||||
redhat_release
|
||||
elif [ -s /etc/slackware-version ]; then
|
||||
echo DISTRIBUTION="slackware"
|
||||
elif [ -f /etc/SUSE-release ] ; then
|
||||
# TODO - not tested
|
||||
echo DISTRIBUTION=suse
|
||||
echo PSUEDONAME=`cat /etc/SUSE-release | tr "\n" ' '| sed s/VERSION.*//`
|
||||
echo REV=`cat /etc/SUSE-release | tr "\n" ' ' | sed s/.*=\ //`
|
||||
echo VERSION=`cat /etc/SuSE-release | grep 'VERSION' | sed -e 's#[^0-9]##g'`
|
||||
elif [ -f /etc/mandrake-release ] ; then
|
||||
# TODO - not tested
|
||||
echo DISTRIBUTION=mandrake
|
||||
echo PSUEDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
|
||||
echo REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
|
||||
echo FAMILY=rh
|
||||
elif [ -f /etc/debian_version ] ; then
|
||||
echo DISTRIBUTION=debian
|
||||
echo FAMILY=debian
|
||||
debian_derivative
|
||||
elif [ -f /etc/UnitedLinux-release ]; then
|
||||
echo DISTRIBUTION="united"
|
||||
echo VERSION=`cat /etc/UnitedLinux-release`
|
||||
elif [ -r /etc/init.d/functions.sh ]; then
|
||||
# TODO - not tested
|
||||
source /etc/init.d/functions.sh
|
||||
[ zz`type -t ebegin 2>/dev/null` == "zzfunction" ] && echo DISTRIBUTION="gentoo"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
declare -A abet
|
||||
|
||||
15
test.sh
15
test.sh
@@ -1,16 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /dev/stdin <<< "$(curl -sL http://scity.xyz/colorsinc)"
|
||||
source /opt/idssys/defaults/colors.inc
|
||||
source /opt/idssys/defaults/default.inc
|
||||
|
||||
echo 'yes'
|
||||
|
||||
while getopts 'r' flag; do
|
||||
case "${flag}" in
|
||||
r) echo 'RESTART' ;;
|
||||
*) echo 'nothing'
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0; #test5
|
||||
detect_os
|
||||
|
||||
|
||||
Reference in New Issue
Block a user