Skip to content

Commit 65602e0

Browse files
committed
Fix sudo error in docker systems
1 parent 8c74465 commit 65602e0

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

scripts/install_latest_cmake.bash

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
SUDO=${SUDO:=sudo} # SUDO=command in docker (running as root, sudo not available)
4+
command_exists() {
5+
command -v "$@" >/dev/null 2>&1
6+
}
7+
8+
user_can_sudo() {
9+
command_exists sudo || return 1
10+
! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
11+
}
12+
13+
if user_can_sudo; then
14+
SUDO="sudo"
15+
else
16+
SUDO="" # To support docker environment
17+
fi
18+
519
if [ "$1" == "assume-yes" ]; then
620
APT_CONFIRM="--assume-yes"
721
else

scripts/install_open3d.bash

+15-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
SUDO=${SUDO:=sudo} # SUDO=command in docker (running as root, sudo not available)
4+
command_exists() {
5+
command -v "$@" >/dev/null 2>&1
6+
}
7+
8+
user_can_sudo() {
9+
command_exists sudo || return 1
10+
! LANG= sudo -n -v 2>&1 | grep -q "may not run sudo"
11+
}
12+
13+
if user_can_sudo; then
14+
SUDO="sudo"
15+
else
16+
SUDO="" # To support docker environment
17+
fi
18+
519
if [ "$1" == "assume-yes" ]; then
620
APT_CONFIRM="--assume-yes"
721
else

0 commit comments

Comments
 (0)