From 0b772d8f2f95a624179a6cfe6850d7ca8d62fdf3 Mon Sep 17 00:00:00 2001
From: jvallve <jvallve@iri.upc.edu>
Date: Wed, 26 Jan 2022 14:44:07 +0100
Subject: [PATCH] ldconfig with sudo

---
 install_wolf.sh | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/install_wolf.sh b/install_wolf.sh
index 0f0bc2d..a109461 100755
--- a/install_wolf.sh
+++ b/install_wolf.sh
@@ -10,6 +10,14 @@ func_make_install () {
    fi
 }
 
+func_ldconfig () {
+   if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
+      ldconfig
+   else
+      sudo ldconfig
+   fi
+}
+
 func_echo () {
    if [ $VERBOSE == "true" ]; then
       echo "$1"
@@ -140,6 +148,8 @@ while getopts "vap:d:w:hf:c:" opt; do
    esac
 done
 
+# check sudo permissions
+func_ldconfig
 
 # UBUNTU
 if [ "$UID" -eq 0 -o "$EUID" -eq 0 ]; then
@@ -354,7 +364,7 @@ if [ $INSTALL_LASER == "y" ]; then
    # LASER_SCAN_UTILS
    func_echo "Installing laser_scan_utils (required)..."
    cd $DEPS_PATH
-   ldconfig
+   func_ldconfig
    git clone https://gitlab.iri.upc.edu/labrobotica/algorithms/laser_scan_utils.git
    cd laser_scan_utils
    mkdir -p build && cd build
@@ -366,7 +376,7 @@ if [ $INSTALL_LASER == "y" ]; then
    # PLUGIN
    func_echo "Cloning plugin laser..."
    cd $WOLF_PATH
-   ldconfig
+   func_ldconfig
    git clone -b master https://gitlab.iri.upc.edu/mobile_robotics/wolf_projects/wolf_lib/plugins/laser.git
    cd laser
 
@@ -379,7 +389,7 @@ if [ $INSTALL_LASER == "y" ]; then
    func_make_install
 
    func_echo "Testing plugin laser..."
-   ldconfig
+   func_ldconfig
    ctest -j$CORES
 else
    func_echo "Skipping plugin laser."
-- 
GitLab