Fix missing sudo command for new clone ssh test

This commit is contained in:
2025-07-04 13:52:16 +09:00
parent 221d1b3d35
commit d60ed41100
2 changed files with 6 additions and 3 deletions

View File

@@ -22,10 +22,12 @@ if [ -z "$(command -v git)" ]; then
error=1;
fi;
GIT_COMMAND_BASE=("git");
SUDO_COMMAND=()
if [ -n "${USE_SUDO}" ]; then
# if we are root -> ok, else we must be SUDO USER
if [ "$(whoami)" = "root" ]; then
GIT_COMMAND_BASE=("sudo" "-u" "${SUDO_USER}" "git");
SUDO_COMMAND=("sudo" "-u" "${SUDO_USER}");
GIT_COMMAND_BASE=("${SUDO_COMMAND[@]}" "git");
elif [ "$(whoami)" != "${SUDO_USER}" ]; then
echo "[!] Script must be run as root or as the ${SUDO_USER}";
error=1;