Skip to content

Commit 5de9ff2

Browse files
setup: fix unbound SUDO_USER variable when running as root in Docker
1 parent 51ad123 commit 5de9ff2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

setup.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ if grep -q "^-" "$tmpfile"; then
2525
if [[ "$OSTYPE" == "darwin"* ]]; then
2626
git submodule update --init --recursive
2727
else
28-
sudo -u $SUDO_USER git submodule update --init --recursive
28+
if [[ -n "${SUDO_USER:-}" ]]; then
29+
sudo -u "$SUDO_USER" git submodule update --init --recursive
30+
else
31+
git submodule update --init --recursive
32+
fi
2933
fi
3034
elif grep -q "^+" "$tmpfile"; then
3135
# Make it easy for users who are not hacking ORFS to do the right thing,
@@ -39,5 +43,9 @@ fi
3943
if [[ "$OSTYPE" == "darwin"* ]]; then
4044
"$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
4145
else
42-
sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
46+
if [[ -n "${SUDO_USER:-}" ]]; then
47+
sudo -u "$SUDO_USER" "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
48+
else
49+
"$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
50+
fi
4351
fi

0 commit comments

Comments
 (0)