Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove suaveup root password requirement #242

Merged
merged 2 commits into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 43 additions & 10 deletions suave/suaveup/suaveup
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,54 @@ 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 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

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"

echo "Moving suave-geth to /usr/local/bin ..."
sudo mv suave-geth /usr/local/bin/suave-geth
mkdir -p "$SUAVE_BIN_DIR"

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'"
Loading