diff --git a/os_probe.bash b/os_probe.bash index a96a356..0c1bb2e 100755 --- a/os_probe.bash +++ b/os_probe.bash @@ -7,33 +7,52 @@ # 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 # set environment variable for os - osp="Debian" + rosp="Debian" fi # check if pacman is installed if [ -x "$(command -v pacman)" ]; then - osp="Arch" + rosp="Arch" fi # check if opkg is installed if [ -x "$(command -v opkg)" ]; then - osp="Openwrt" + rosp="Openwrt" fi # 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 - # osp=$(lsb_release -i | awk '{print $3}') +if [[ "$tosp" == "$rosp" ]]; then + echo "OS detection successful" + osp=$tosp +else + echo "Looks like $tosp, but based on the package manager its $rosp" + osp=$rosp fi - - - +echo "Detected OS: $osp" + +sleep 3 diff --git a/syssetup.bash b/syssetup.bash index 522fe1b..38b2268 100755 --- a/syssetup.bash +++ b/syssetup.bash @@ -1,6 +1,6 @@ #!/bin/bash -# set -x # For debugging +#set -x # For debugging set -eo pipefail # No -u that would just bother me trap cleanup EXIT # A little more robust cleanup