feat: 更新脚本

This commit is contained in:
neo 2021-06-11 23:32:38 +08:00
parent ed40e3a56f
commit e5283f438e
3 changed files with 19 additions and 7 deletions

View File

@ -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 <<EOABORT
The Homebrew prefix, ${HOMEBREW_PREFIX}, exists but is not searchable.
If this is not intentional, please restore the default permissions and

View File

@ -275,7 +275,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
@ -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 <<EOABORT
The Homebrew prefix, ${HOMEBREW_PREFIX}, exists but is not searchable.
If this is not intentional, please restore the default permissions and

View File

@ -227,7 +227,7 @@ fi
if [[ -s $HOMEBREW_REPOSITORY/.gitignore ]]; then
gitignore=$(<"$HOMEBREW_REPOSITORY/.gitignore")
else
gitignore=$(curl -fsSL https://raw.githubusercontent.com/Homebrew/brew/master/.gitignore)
gitignore=$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/brew/.gitignore)
fi
[[ -n $gitignore ]] || abort "Failed to fetch Homebrew .gitignore!"