From 7e7449958fd9fab214497e43e8d4150aa6afc2f9 Mon Sep 17 00:00:00 2001 From: Alejo Salles Date: Tue, 30 Apr 2024 21:35:36 -0400 Subject: [PATCH 1/2] remove suaveup root password requirement --- suave/suaveup/suaveup | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/suave/suaveup/suaveup b/suave/suaveup/suaveup index 25e996897..dc994dfbf 100755 --- a/suave/suaveup/suaveup +++ b/suave/suaveup/suaveup @@ -56,20 +56,19 @@ else exit 1 fi -# use tar to extract the downloaded file and move it to /usr/local/bin +# use tar to extract the downloaded file and move it to ~/.suave echo "Extracting suave-geth_${VERSION}_${ARCH_STRING}.zip ..." unzip -qq -o suave-geth_${VERSION}_${ARCH_STRING}.zip chmod +x suave-geth -if [ ! -d "/usr/local" ]; then - sudo mkdir /usr/local -fi -if [ ! -d "/usr/local/bin" ]; then - sudo mkdir /usr/local/bin -fi +BASE_DIR="${XDG_CONFIG_HOME:-$HOME}" +SUAVE_DIR="${SUAVE_DIR-"$BASE_DIR/.suave"}" +SUAVE_BIN_DIR="$SUAVE_DIR/bin" + +mkdir -p "$SUAVE_BIN_DIR" -echo "Moving suave-geth to /usr/local/bin ..." -sudo mv suave-geth /usr/local/bin/suave-geth +echo "Moving suave-geth to ${SUAVE_BIN_DIR}..." +mv suave-geth $SUAVE_BIN_DIR/suave-geth rm suave-geth_${VERSION}_${ARCH_STRING}.zip echo "Installed suave-geth $VERSION ✅ " From cd08b350b619d2fab47c41ed5b1a7c9e84945325 Mon Sep 17 00:00:00 2001 From: Alejo Salles Date: Thu, 2 May 2024 19:08:50 -0400 Subject: [PATCH 2/2] add suave-geth to PATH --- suave/suaveup/suaveup | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/suave/suaveup/suaveup b/suave/suaveup/suaveup index dc994dfbf..12ea65ed6 100755 --- a/suave/suaveup/suaveup +++ b/suave/suaveup/suaveup @@ -56,7 +56,7 @@ else exit 1 fi -# use tar to extract the downloaded file and move it to ~/.suave +# use tar to extract the downloaded file and move it to the SUAVE_BIN_DIR directory echo "Extracting suave-geth_${VERSION}_${ARCH_STRING}.zip ..." unzip -qq -o suave-geth_${VERSION}_${ARCH_STRING}.zip chmod +x suave-geth @@ -71,5 +71,39 @@ echo "Moving suave-geth to ${SUAVE_BIN_DIR}..." mv suave-geth $SUAVE_BIN_DIR/suave-geth rm suave-geth_${VERSION}_${ARCH_STRING}.zip +# Pick the right shell profile file +case $SHELL in +*/zsh) + PROFILE="${ZDOTDIR-"$HOME"}/.zshenv" + PREF_SHELL=zsh + ;; +*/bash) + PROFILE=$HOME/.bashrc + PREF_SHELL=bash + ;; +*/fish) + PROFILE=$HOME/.config/fish/config.fish + PREF_SHELL=fish + ;; +*/ash) + PROFILE=$HOME/.profile + PREF_SHELL=ash + ;; +*) + echo "suaveup: could not detect shell, manually add ${SUAVE_BIN_DIR} to your PATH." + exit 1 +esac + +# Add suaveup if it isn't already in PATH. +if [[ ":$PATH:" != *":${SUAVE_BIN_DIR}:"* ]]; then + # Add the suaveup directory to the path and ensure the old PATH variables remain. + # If the shell is fish, echo fish_add_path instead of export. + if [[ "$PREF_SHELL" == "fish" ]]; then + echo >> "$PROFILE" && echo "fish_add_path -a $SUAVE_BIN_DIR" >> "$PROFILE" + else + echo >> "$PROFILE" && echo "export PATH=\"\$PATH:$SUAVE_BIN_DIR\"" >> "$PROFILE" + fi +fi + echo "Installed suave-geth $VERSION ✅ " -echo "You can confirm by running 'suave-geth version'" +echo "Run 'source $PROFILE' or start a new terminal session to add suave-geth to your PATH, then check the installation by running 'suave-geth version'"