Skip to content

Commit

Permalink
feat: 更新脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
neo committed Dec 13, 2023
1 parent 6f89a30 commit ef1e02b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
14 changes: 5 additions & 9 deletions install-origin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ execute() {

execute_sudo() {
local -a args=("$@")
if have_sudo_access
if [[ "${EUID:-${UID}}" != "0" ]] && have_sudo_access
then
if [[ -n "${SUDO_ASKPASS-}" ]]
then
Expand Down Expand Up @@ -484,7 +484,7 @@ ohai 'Checking for `sudo` access (which may request your password)...'

if [[ -n "${HOMEBREW_ON_MACOS-}" ]]
then
have_sudo_access
[[ "${EUID:-${UID}}" == "0" ]] || have_sudo_access
elif ! [[ -w "${HOMEBREW_PREFIX}" ]] &&
! [[ -w "/home/linuxbrew" ]] &&
! [[ -w "/home" ]] &&
Expand Down Expand Up @@ -910,13 +910,6 @@ EOABORT
fi
fi

# Set HOMEBREW_DEVELOPER on Linux systems where usable Git/cURL is not in /usr/bin
if [[ -n "${HOMEBREW_ON_LINUX-}" && (-n "${HOMEBREW_CURL_PATH-}" || -n "${HOMEBREW_GIT_PATH-}") ]]
then
ohai "Setting HOMEBREW_DEVELOPER to use Git/cURL not in /usr/bin"
export HOMEBREW_DEVELOPER=1
fi

ohai "Downloading and installing Homebrew..."
(
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
Expand Down Expand Up @@ -1029,6 +1022,9 @@ case "${SHELL}" in
shell_rcfile="${ZDOTDIR:-"${HOME}"}/.zprofile"
fi
;;
*/fish*)
shell_rcfile="${HOME}/.config/fish/config.fish"
;;
*)
shell_rcfile="${ENV:-"${HOME}/.profile"}"
;;
Expand Down
31 changes: 21 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ checkExecute() {
fi
}

checkGitProxy() {
git_https_proxy=$(git config --global https.proxy)
git_http_proxy=$(git config --global http.proxy)
if [[ -z "$git_https_proxy" && -z "$git_http_proxy" ]]; then

Check failure on line 121 in install.sh

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.

Check failure on line 121 in install.sh

View workflow job for this annotation

GitHub Actions / tests (ubuntu-latest)

Prefer putting braces around variable references even when not strictly required.
echo ""
else
warn "
发现git代理!如果后面出现git相关报错,尝试在终端执行下面命令:
git config --global --unset https.proxy
git config --global --unset http.proxy
"
fi
}

# Check if script is run non-interactively (e.g. CI)
# If it is run non-interactively we should not prompt for passwords.
# Always use single-quoted strings with `exp` expressions
Expand Down Expand Up @@ -970,6 +985,8 @@ EOABORT
fi
fi

checkGitProxy

if ! command -v curl >/dev/null
then
abort "$(
Expand Down Expand Up @@ -1143,14 +1160,6 @@ ohai "Downloading and installing Homebrew..."

ring_bell

ohai "Homebrew是由志愿者义务维护的,如果可以请考虑捐赠:"
echo "$(
cat <<EOS
${tty_underline}https://github.com/Homebrew/brew#donations${tty_reset}
EOS
)
"

(
cd "${HOMEBREW_REPOSITORY}" >/dev/null || return
execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.analyticsmessage" "true"
Expand Down Expand Up @@ -1202,11 +1211,13 @@ then
eval \$(${HOMEBREW_PREFIX}/bin/brew shellenv) #brew.idayer.com
export HOMEBREW_API_DOMAIN=${HOMEBREW_API_DOMAIN} #brew.idayer.com
export HOMEBREW_BOTTLE_DOMAIN=${HOMEBREW_BOTTLE_DOMAIN} #brew.idayer.com
export HOMEBREW_PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ #brew.idayer.com
EOS
else
cat >> ${shell_rcfile} <<EOS
export HOMEBREW_API_DOMAIN=${HOMEBREW_API_DOMAIN} #brew.idayer.com
export HOMEBREW_BOTTLE_DOMAIN=${HOMEBREW_BOTTLE_DOMAIN} #brew.idayer.com
export HOMEBREW_PIP_INDEX_URL=https://mirrors.aliyun.com/pypi/simple/ #brew.idayer.com
EOS
fi

Expand Down Expand Up @@ -1260,8 +1271,8 @@ echo ""
ohai "🎉 恭喜,安装成功!"

cat <<EOS
- 安装成功后可以执行 ${tty_bold}brew help${tty_reset} 验证。
- 教程文档: ${tty_underline}https://brew.idayer.com${tty_reset}
- 验证命令: ${tty_bold}brew help${tty_reset}
- 请收藏,谨防失联: ${tty_underline}https://brew.idayer.com${tty_reset}
EOS

echo ""
Expand Down

0 comments on commit ef1e02b

Please sign in to comment.