OS Probe updated to be more robust
This commit is contained in:
parent
227c83867c
commit
4596e42512
2 changed files with 29 additions and 10 deletions
|
@ -7,33 +7,52 @@
|
||||||
|
|
||||||
# check if apt-get is installed
|
# check if apt-get is installed
|
||||||
|
|
||||||
|
echo "Checking OS.."
|
||||||
|
|
||||||
|
# step 1 check via os-release
|
||||||
|
|
||||||
|
if [ -f /etc/os-release ]; then
|
||||||
|
. /etc/os-release
|
||||||
|
if [ "$ID_LIKE" = "debian" ]; then
|
||||||
|
tosp="Debian"
|
||||||
|
elif [ "$ID_LIKE" = "arch" ]; then
|
||||||
|
tosp="Arch"
|
||||||
|
elif [ "$ID_LIKE" = "openwrt" ]; then
|
||||||
|
tosp="Openwrt"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -x "$(command -v apt-get)" ]; then
|
if [ -x "$(command -v apt-get)" ]; then
|
||||||
# set environment variable for os
|
# set environment variable for os
|
||||||
osp="Debian"
|
rosp="Debian"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if pacman is installed
|
# check if pacman is installed
|
||||||
|
|
||||||
if [ -x "$(command -v pacman)" ]; then
|
if [ -x "$(command -v pacman)" ]; then
|
||||||
osp="Arch"
|
rosp="Arch"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if opkg is installed
|
# check if opkg is installed
|
||||||
|
|
||||||
if [ -x "$(command -v opkg)" ]; then
|
if [ -x "$(command -v opkg)" ]; then
|
||||||
osp="Openwrt"
|
rosp="Openwrt"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# I know its so high tech and amazing right?
|
# I know its so high tech and amazing right?
|
||||||
|
|
||||||
# We are going to do a double check here using lsb_release
|
# check /etc/os-release for the ID_LIKE value
|
||||||
|
|
||||||
if [ -x "$(command -v lsb_release)" ]; then
|
if [[ "$tosp" == "$rosp" ]]; then
|
||||||
# osp=$(lsb_release -i | awk '{print $3}')
|
echo "OS detection successful"
|
||||||
|
osp=$tosp
|
||||||
|
else
|
||||||
|
echo "Looks like $tosp, but based on the package manager its $rosp"
|
||||||
|
osp=$rosp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Detected OS: $osp"
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# set -x # For debugging
|
#set -x # For debugging
|
||||||
set -eo pipefail # No -u that would just bother me
|
set -eo pipefail # No -u that would just bother me
|
||||||
trap cleanup EXIT # A little more robust cleanup
|
trap cleanup EXIT # A little more robust cleanup
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue