diff --git a/install-origin.sh b/install-origin.sh index 08a5b03..fe3b14e 100755 --- a/install-origin.sh +++ b/install-origin.sh @@ -269,7 +269,7 @@ test_ruby() { no_usable_ruby() { local ruby_exec IFS=$'\n' # Do word splitting on new lines only - for ruby_exec in $(which -a ruby); do + for ruby_exec in $(which -a ruby 2>/dev/null); do if test_ruby "$ruby_exec"; then IFS=$' \t\n' # Restore IFS to its default value return 1 @@ -360,8 +360,14 @@ fi HOMEBREW_CORE="${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core" if [[ "${EUID:-${UID}}" == "0" ]]; then - abort "Don't run this as root!" -elif [[ -d "${HOMEBREW_PREFIX}" && ! -x "${HOMEBREW_PREFIX}" ]]; then + # Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there) + if ! [[ -f /proc/1/cgroup ]] || + ! grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup; then + abort "Don't run this as root!" + fi +fi + +if [[ -d "${HOMEBREW_PREFIX}" && ! -x "${HOMEBREW_PREFIX}" ]]; then abort "$(cat </dev/null); do if test_ruby "$ruby_exec"; then IFS=$' \t\n' # Restore IFS to its default value return 1 @@ -366,8 +366,14 @@ fi HOMEBREW_CORE="${HOMEBREW_REPOSITORY}/Library/Taps/homebrew/homebrew-core" if [[ "${EUID:-${UID}}" == "0" ]]; then - abort "Don't run this as root!" -elif [[ -d "${HOMEBREW_PREFIX}" && ! -x "${HOMEBREW_PREFIX}" ]]; then + # Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there) + if ! [[ -f /proc/1/cgroup ]] || + ! grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup; then + abort "Don't run this as root!" + fi +fi + +if [[ -d "${HOMEBREW_PREFIX}" && ! -x "${HOMEBREW_PREFIX}" ]]; then abort "$(cat <