Skip to content

Commit

Permalink
Merge branch 'main' into itaylevyofficial/30-init-idempotancy
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayLevyOfficial committed Jun 5, 2023
2 parents 83daa22 + 77efd90 commit d922be8
Showing 1 changed file with 27 additions and 44 deletions.
71 changes: 27 additions & 44 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,44 @@
# Abort if any command fails
set -e

ROLLER_BINARY_URL="https://github.com/dymensionxyz/roller/releases/download/v0.0.0/roller"
CELESTIA_BIN_URL="https://github.com/dymensionxyz/roller/releases/download/v0.0.0/celestia"
RELAYER_BIN_URL="https://github.com/dymensionxyz/roller/releases/download/v0.0.0/rly"
EVM_ROL_BINARY_URL="https://github.com/dymensionxyz/roller/releases/download/v0.0.0/rly"
# Emoji for echo outputs
EMOJI="💈"

TGZ_URL="https://github.com/dymensionxyz/roller/releases/download/v0.0.0/roller_0.0.0_darwin_amd64.tar.gz"
# Create internal dir
INTERNAL_DIR="/usr/local/bin/roller_bins"
ROLLER_BIN_PATH="/usr/local/bin/roller"

# Check if Roller binary already exists
if [ -f "/usr/local/bin/roller" ]; then
read -p "Roller is already installed. Do you want to override it? (y/N) " answer
if [ -f "$ROLLER_BIN_PATH" ]; then
read -p "$EMOJI roller is already installed. Do you want to override it? (y/N) " answer
if [[ "$answer" != "y" && "$answer" != "Y" ]]; then
echo "Installation cancelled."
echo "$EMOJI Installation cancelled."
exit 0
fi
# Delete old binaries if user chose to override
sudo rm "/usr/local/bin/roller"
sudo rm "$ROLLER_BIN_PATH"
sudo rm -rf "$INTERNAL_DIR"
fi

# Creating the required directories
sudo mkdir -p "$INTERNAL_DIR"
sudo mkdir -p "/tmp/roller_tmp"

# Create a spinner function
spinner() {
local pid=$!
local delay=0.75
local spinstr='|/-\'
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
local temp=${spinstr#?}
printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"}
sleep $delay
printf "\b\b\b\b\b\b"
done
printf " \b\b\b\b"
}

# Fetch other binaries
echo -n "Downloading Celestia..."
sudo curl -s -L "$CELESTIA_BIN_URL" -o "$INTERNAL_DIR/celestia" & spinner
echo "Done"

echo -n "Downloading Relayer..."
sudo curl -s -L "$RELAYER_BIN_URL" -o "$INTERNAL_DIR/rly" & spinner
echo "Done"

echo -n "Downloading EVM RollApp..."
sudo curl -s -L "$EVM_ROL_BINARY_URL" -o "$INTERNAL_DIR/rollapp_evm" & spinner
echo "Done"

# Fetch roller binary
echo -n "Downloading Roller..."
sudo curl -s -L "$ROLLER_BINARY_URL" -o "/usr/local/bin/roller" & spinner
echo "Done"

sudo chmod +x "/usr/local/bin/roller"

echo "Installation complete. Roller is now available on your PATH, and the internal binaries are in $INTERNAL_DIR."
# Download and extract the tar file to a temporary directory
echo "$EMOJI Downloading roller..."
sudo curl -L "$TGZ_URL" --progress-bar | sudo tar -xz -C "/tmp/roller_tmp"

# Assuming that the tar file contains the lib folder and the roller binary inside the roller_bins directory.
# Move binaries to their correct locations
echo "$EMOJI Installing roller..."
sudo mv "/tmp/roller_tmp/roller_bins/lib"/* "$INTERNAL_DIR"
sudo mv "/tmp/roller_tmp/roller_bins/roller" "$ROLLER_BIN_PATH"

# Make roller executable
sudo chmod +x "$ROLLER_BIN_PATH"

# Cleanup temporary directory
sudo rm -rf "/tmp/roller_tmp"

echo "$EMOJI Installation complete! You can now use roller from your terminal."

0 comments on commit d922be8

Please sign in to comment.