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

feat: Update celestia-node.sh to use curl instead of wget #1805

Closed
wants to merge 0 commits into from

Conversation

lukecd
Copy link
Contributor

@lukecd lukecd commented Nov 26, 2024

This update modifies "celestia-node.sh" to use curl instead of wget as curl is installed by default on new Macs

Resolves #1808

Summary by CodeRabbit

  • New Features

    • Improved user feedback during the installation process with immediate error notifications for invalid inputs.
    • Updated download method to use curl for fetching resources.
  • Bug Fixes

    • Enhanced error handling for architecture and operating system validation.
  • Documentation

    • Final output message updated to confirm installation completion.
  • Refactor

    • Simplified control flow and conditional statements for better readability.
    • Removed redundant comments to streamline the script.

Copy link
Contributor

coderabbitai bot commented Nov 26, 2024

Walkthrough

The pull request introduces modifications to the public/celestia-node.sh script to enhance code readability and streamline functionality. Key changes include simplifying control flow and user input handling, replacing wget with curl for file downloads, refining error handling for architecture and OS validation, and updating output messages. Redundant comments have been removed, and the checksum verification process remains unchanged. These adjustments aim to improve the script's clarity and maintainability while retaining its core functionality.

Changes

File Change Summary
public/celestia-node.sh - Simplified conditional checks and user input handling.
- Replaced wget with curl for downloading files.
- Refined error handling for architecture and OS validation.
- Updated output messages for installation completion.
- Removed redundant comments and unnecessary sections.

Poem

In the script where bunnies hop,
Curl now fetches with a plop! 🐇
Errors handled, clear and bright,
Installation done, all feels right!
With each change, we dance and play,
Readable code leads the way! 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (4)
public/celestia-node.sh (4)

75-77: Consider adding explicit M1/M2 chip detection

While the current architecture detection works correctly, considering the PR's focus on Mac compatibility, it might be helpful to add explicit detection for Apple Silicon chips.

 case $ARCH in
     x86_64) ARCH="x86_64" ;;
-    aarch64|arm64) ARCH="arm64" ;;
+    aarch64|arm64|arm64e) ARCH="arm64" ;;  # arm64e is used by Apple Silicon
     *) echo "Unsupported architecture: $ARCH. Exiting." | tee -a "$LOGFILE"; exit 1 ;;

90-94: Add download progress indicator

While the curl implementation is correct, consider adding the -# flag to show a progress bar, improving user experience.

-if ! curl -L "$URL" -o "celestia-node_$PLATFORM.tar.gz" >> "$LOGFILE" 2>&1; then
+if ! curl -L -# "$URL" -o "celestia-node_$PLATFORM.tar.gz" >> "$LOGFILE" 2>&1; then

121-129: Consider adding cleanup trap

While the cleanup is good, consider adding a trap to clean up temporary files even if the script fails.

+# Add at the beginning of the script, after TEMP_DIR declaration
+trap 'rm -rf "$TEMP_DIR"' EXIT

195-195: Enhance completion message

Consider adding the installed version to the completion message for better user feedback.

-echo "Installation complete. You can now use the celestia binary." | tee -a "$LOGFILE"
+echo "Installation of Celestia Node $VERSION complete. You can now use the celestia binary." | tee -a "$LOGFILE"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 13c7718 and 6782373.

📒 Files selected for processing (1)
  • public/celestia-node.sh (3 hunks)
🔇 Additional comments (4)
public/celestia-node.sh (4)

31-34: LGTM! Improved user input handling

The simplified conditional using bash's native regex matching improves readability while maintaining the same functionality.


82-83: LGTM! Clear OS validation

The OS validation is concise and properly handles both Linux and macOS (Darwin) with appropriate error handling.


105-107: LGTM! Secure checksum verification

The checksum verification process is well-implemented with proper error handling and security checks.

Also applies to: 113-119


174-175: LGTM! Clear error handling

The error handling for invalid installation choices is clear and consistent.

Also applies to: 189-190


# Download the tarball
if ! wget "$URL" >> "$LOGFILE" 2>&1; then
if ! curl -L "$URL" -o "celestia-node_$PLATFORM.tar.gz" >> "$LOGFILE" 2>&1; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Inconsistent download methods detected between scripts

The verification reveals that celestia-app.sh uses wget while celestia-node.sh uses curl -L for downloading files. This inconsistency should be standardized:

  • public/celestia-app.sh: Uses wget for downloading both the main binary and checksums
  • public/celestia-node.sh: Uses curl -L -o consistently for both downloads
🔗 Analysis chain

Verify consistent curl usage

Let's verify that all download operations use curl consistently throughout the script.

Also applies to: 107-107

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining wget usage and verify curl command consistency

# Check for any remaining wget commands
echo "Checking for wget usage:"
rg "wget" 

# Check curl command patterns for consistency
echo -e "\nChecking curl command patterns:"
rg "curl.*-[L#].*-o"

Length of output: 1455

@jcstein jcstein changed the title Update celestia-node.sh to use curl instead of wget feat: Update celestia-node.sh to use curl instead of wget Nov 26, 2024
@@ -53,8 +52,6 @@ if [ -n "$USER_VERSION" ]; then
else
# Fetch the latest release tag from GitHub
VERSION=$(curl -s "https://api.github.com/repos/celestiaorg/celestia-node/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

# Check if VERSION is empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for removing this?

esac

# Construct the download URL
PLATFORM="${OS}_${ARCH}"
URL="https://github.com/celestiaorg/celestia-node/releases/download/$VERSION/celestia-node_$PLATFORM.tar.gz"

# Check if URL is valid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should still make sure the URL is valid before proceeding.

mkdir -p "$GOBIN"
mv "$TEMP_DIR/celestia" "$GOBIN/"
chmod +x "$GOBIN/celestia"
echo "Binary moved to $GOBIN" | tee -a "$LOGFILE"
# Create a symbolic link in the temporary directory
Copy link
Member

@jcstein jcstein Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this section being removed?

@@ -184,100 +157,39 @@ echo # move to a new line
if [ "$HAS_GO" = true ]; then
case $REPLY in
1)
# Install to GOBIN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comment is useful, but fine with it if there's good reason!

echo "export PATH=\$PATH:$GOBIN"
echo ""
fi
echo "You can now run celestia from anywhere (if $GOBIN is in your PATH)." | tee -a "$LOGFILE"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows anyone to download and run it without having to navigate to the directory it was installed in, if in temp dir. I think we should leave this.

;;
2)
# Install to /usr/local/bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with this

sudo mv "$TEMP_DIR/celestia" /usr/local/bin/
echo "Binary moved to /usr/local/bin" | tee -a "$LOGFILE"
# Create a symbolic link in the temporary directory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this. unless I'm missing something

;;
*)
echo ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It installs in $TEMP_DIR, so the log should remain to say that is what it's doing IMO

;;
esac
else
case $REPLY in
1)
# Install to /usr/local/bin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with all of these. outside scope of fixing curl

;;
esac
fi

echo ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is meant to give someone instructions on how to see the help menu and how to interact with the binary off the start. I think it is best to also leave this. Or at least work it into a separate PR so we can get the curl update in.

Copy link
Member

@jcstein jcstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left comments!

@jcstein
Copy link
Member

jcstein commented Nov 26, 2024

IMO these are the required changes: main...jcs/demo-curl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: quick install celestia-node script fails for mac users without wget
2 participants