Browse Source

Merge branch 'os-detection' of stefan.schmidt/ID2T-toolkit into master

Carlos Garcia 6 years ago
parent
commit
6c732e744f
1 changed files with 15 additions and 2 deletions
  1. 15 2
      resources/install_dependencies.sh

+ 15 - 2
resources/install_dependencies.sh

@@ -43,7 +43,15 @@ install_pkg_arch()
 
 install_pkg_ubuntu()
 {
-    APT_PKGS="build-essential libboost-dev libboost-python-dev cmake python3-dev python3-pip python3-venv sqlite tcpdump libtins-dev libpcap-dev"
+    APT_PKGS='build-essential libboost-dev libboost-python-dev cmake python3-dev python3-pip python3-venv sqlite tcpdump libtins-dev libpcap-dev'
+
+    which sudo >/dev/null
+    if [ $? != 0 ]; then
+        # sudo wasn't found, so we use su
+        SUDO="su -c "
+    else
+        SUDO=sudo
+    fi
 
     # Check first to avoid unnecessary sudo
     echo -e "Packages: Checking..."
@@ -51,7 +59,7 @@ install_pkg_ubuntu()
     if [ $? != 0 ]; then
         # Install all missing packages
         echo -e "Packages: Installing..."
-        sudo apt-get install $APT_PKGS
+        $SUDO "apt-get install $APT_PKGS"
     else
         echo -e "Packages: Found."
     fi
@@ -95,6 +103,11 @@ elif [ "$KERNEL" = 'Linux' ]; then
     OS=$(awk '/DISTRIB_ID=/' /etc/*-release | sed 's/DISTRIB_ID=//' | sed 's/"//g' | tr '[:upper:]' '[:lower:]')
     OS_LIKE=$(awk '/ID_LIKE=/' /etc/*-release | sed 's/ID_LIKE=//' | sed 's/"//g' | tr '[:upper:]' '[:lower:]')
 
+    if [ -z "$OS_LIKE" ]; then
+        # This distribution is missing the os-release file, so try lsb_release
+        OS_LIKE=$(lsb_release -si | tr '[:upper:]' '[:lower:]')
+    fi
+
     if [ "$OS_LIKE" = 'archlinux' ]; then
         echo -e "Detected OS: Arch Linux"
         install_pkg_arch