🐛 fix(setup): detect Homebrew download failure and verify installation

Split curl download from bash execution so network errors are caught
explicitly. Add post-install verification that brew is actually
available before reporting success.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
FlintyLemming
2026-02-27 16:27:28 +08:00
parent cdef27e5a9
commit 10388ebe6d

View File

@@ -167,12 +167,25 @@ install_homebrew() {
return
fi
info "Installing Homebrew ..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
local install_script
install_script="$(mktemp)"
if ! curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh -o "$install_script"; then
rm -f "$install_script"
error "Failed to download Homebrew install script (network error)"
exit 1
fi
/bin/bash "$install_script"
rm -f "$install_script"
# Add brew to PATH for the rest of this script
if [ -f /home/linuxbrew/.linuxbrew/bin/brew ]; then
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
fi
if ! command -v brew &>/dev/null; then
error "Homebrew installation failed (brew not found after install)"
exit 1
fi
success "Homebrew installed"
}
@@ -283,15 +296,19 @@ install_docker() {
if command -v docker &>/dev/null; then
info "Docker already installed ($(docker --version)), skipping"
else
info "Downloading Docker install script ..."
curl -fsSL https://config.mitsea.com/install-docker.sh -o /tmp/install-docker.sh
echo ""
echo -e "Use a ${BOLD}mirror${NC} for Docker installation? ${YELLOW}(recommended in China)${NC}"
read -rp "Use nyist mirror? [y/N] " use_mirror
echo -e "Use a ${BOLD}domestic mirror${NC} for Docker installation? ${YELLOW}(recommended in China)${NC}"
read -rp "Use mirror? [y/N] " use_mirror
case "$use_mirror" in
[Yy]*) sudo sh /tmp/install-docker.sh --mirror nyist ;;
*) sudo sh /tmp/install-docker.sh ;;
[Yy]*)
curl -fsSL https://git.mitsea.com/FlintyLemming/scripts-public/raw/branch/main/linux-managements/install-docker.sh \
-o /tmp/install-docker.sh
sudo sh /tmp/install-docker.sh --mirror nyist
;;
*)
curl -fsSL https://get.docker.com -o /tmp/get-docker.sh
sudo sh /tmp/get-docker.sh
;;
esac
success "Docker installed"
fi