From 97d61bc9bc9e3d52ce5a4376e4b65a4ec3456ec4 Mon Sep 17 00:00:00 2001 From: lachtan Date: Fri, 30 Sep 2022 18:46:24 +0200 Subject: [PATCH] Make homebrew initialization more general --- rc.local/linuxbrew.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/rc.local/linuxbrew.sh b/rc.local/linuxbrew.sh index 6559a99..41baeaf 100644 --- a/rc.local/linuxbrew.sh +++ b/rc.local/linuxbrew.sh @@ -1,5 +1,22 @@ -nop ${BREW_HOME:=/home/linuxbrew} -nop ${BREW:="$BREW_HOME/.linuxbrew/bin/brew"} +# Homebrew initialization +# Can set BREW_HOME in advance + +BREW_LOCATIONS=( \ + "$HOME/.local/share/linuxbrew" \ + "$HOME/.linuxbrew" \ + "/home/linuxbrew/.linuxbrew" \ +) + +if [[ ! -d "$BREW_HOME" ]]; then + for brew_path in "${BREW_LOCATIONS[@]}"; do + if [[ -d "$brew_path" ]]; then + BREW_HOME="$brew_path" + break + fi + done +fi + +BREW="$BREW_HOME/bin/brew" if [[ -e "$BREW" ]]; then path_backup="$PATH" @@ -9,3 +26,4 @@ if [[ -e "$BREW" ]]; then append_path "$HOMEBREW_PREFIX/bin" append_path "$HOMEBREW_PREFIX/sbin" fi +