#!/usr/bin/env bash set -e echo Installing conduitup... CONDUIT_DIR=${CONDUIT_DIR-"$HOME/.conduit"} CONDUIT_BIN_DIR="$CONDUIT_DIR/bin" CONDUIT_MAN_DIR="$CONDUIT_DIR/share/man/man1" BIN_URL="https://raw.githubusercontent.com/conduitxyz/conduit-cli/master/conduitup/conduitup" BIN_PATH="$CONDUIT_BIN_DIR/conduitup" # Create the .conduit bin directory and conduitup binary if it doesn't exist. mkdir -p $CONDUIT_BIN_DIR curl -# -L $BIN_URL -o $BIN_PATH chmod +x $BIN_PATH # Create the man directory for future man files if it doesn't exist. mkdir -p $CONDUIT_MAN_DIR # Store the correct profile file (i.e. .profile for bash or .zshrc for ZSH). case $SHELL in */zsh) PROFILE=$HOME/.zshrc 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 "conduitup: could not detect shell, manually add ${CONDUIT_BIN_DIR} to your PATH." exit 1 esac # Only add conduitup if it isn't already in PATH. if [[ ":$PATH:" != *":${CONDUIT_BIN_DIR}:"* ]]; then # Add the conduitup directory to the path and ensure the old PATH variables remain. echo >> $PROFILE && echo "export PATH=\"\$PATH:$CONDUIT_BIN_DIR\"" >> $PROFILE fi # Warn MacOS users that they may need to manually install libusb via Homebrew: if [[ "$OSTYPE" =~ ^darwin && ! -f /usr/local/opt/libusb/lib/libusb-1.0.0.dylib ]]; then echo && echo "warning: libusb not found. You may need to install it manually on MacOS via Homebrew (brew install libusb)." fi echo && echo "Detected your preferred shell is ${PREF_SHELL} and added conduitup to PATH. Run 'source ${PROFILE}' or start a new terminal session to use conduitup." echo "Then, simply run 'conduitup' to install Conduit."