Update test.sh
This commit is contained in:
63
test.sh
63
test.sh
@@ -2,64 +2,17 @@
|
||||
|
||||
source /dev/stdin <<< "$(curl -sL http://scity.xyz/colorsinc)"
|
||||
|
||||
# Detect distribution name
|
||||
if [[ `which lsb_release 2>/dev/null` ]]; then
|
||||
# lsb_release available
|
||||
distrib_name=`lsb_release -is`
|
||||
else
|
||||
# lsb_release not available
|
||||
lsb_files=`find /etc -type f -maxdepth 1 \( ! -wholename /etc/os-release ! -wholename /etc/lsb-release -wholename /etc/\*release -o -wholename /etc/\*version \) 2> /dev/null`
|
||||
for file in $lsb_files; do
|
||||
if [[ $file =~ /etc/(.*)[-_] ]]; then
|
||||
distrib_name=${BASH_REMATCH[1]}
|
||||
break
|
||||
else
|
||||
echo -e "${BOrange}Sorry, GlancesAutoInstall script is not compliant with your system.${Color_Off}"
|
||||
echo -e "${BOrange}Please read: https://github.com/nicolargo/glances#installation${Color_Off}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
while getopts 'r' flag; do
|
||||
case "${flag}" in
|
||||
r) echo 'RESTART' ;;
|
||||
*) echo 'nothing'
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
echo -e "${CS[color,LightGreen]}Detected system: $distrib_name${CS[color,Default]}"
|
||||
|
||||
echo ""
|
||||
|
||||
# if we have ignition, print and exit
|
||||
gotDist () {
|
||||
[ -n "$1" ] && echo "$1" && exit 0
|
||||
}
|
||||
|
||||
# we are only interested in a single word "dist" here
|
||||
# various malformations can occur; admin will have to code appropately based on output
|
||||
linuxRelease () {
|
||||
if [ -r /etc/lsb-release ]; then
|
||||
dist=$(grep 'DISTRIB_ID' /etc/lsb-release | sed 's/DISTRIB_ID=//' | head -1)
|
||||
gotDist "$dist"
|
||||
fi
|
||||
|
||||
dist=$(find /etc/ -maxdepth 1 -name '*release' 2> /dev/null | sed 's/\/etc\///' | sed 's/-release//' | head -1)
|
||||
if [ "$dist" = "os" ]; then
|
||||
dist=$(find /etc/ -maxdepth 1 -name '*release' 2> /dev/null | sed 's/\/etc\///' | sed 's/-release//' | head -2 | tail -1)
|
||||
fi
|
||||
gotDist "$dist"
|
||||
|
||||
dist=$(find /etc/ -maxdepth 1 -name '*version' 2> /dev/null | sed 's/\/etc\///' | sed 's/-version//' | head -1)
|
||||
gotDist "$dist"
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
# start with uname and branch the decision from there
|
||||
dist=$(uname -s 2> /dev/null)
|
||||
if [ "$dist" = "Linux" ]; then
|
||||
linuxRelease
|
||||
elif [ -n "$dist" ]; then
|
||||
echo "$dist"
|
||||
else
|
||||
echo "Couldn't find system"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user