Skip to content

Commit

Permalink
celestia init fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mmchougule committed Sep 17, 2023
1 parent 93e46a4 commit bb89f53
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cli/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,18 @@ type CelestiaLightCommander struct {
}

func (c *CelestiaLightCommander) Init(cmd *cobra.Command, args []string, mode Mode) error {
utils.ExecBashCmd(exec.Command(mode.Download), utils.WithOutputToStdout(), utils.WithErrorsToStderr())
// if isValidUrl(mode.Download) {
// fmt.Println("Downloading Celestia init script from ", mode.Download)
// if err := downloadFile(mode.Download); err != nil {
// return fmt.Errorf("failed to download file: %v", err)
// }
// } else {
// fmt.Println("Skipping download of Celestia init script from ", mode.Download)
// }
fmt.Println("Downloading Celestia from init script ", mode.Download)

utils.ExecBashCmd(exec.Command("bash", mode.Download), utils.WithOutputToStdout(), utils.WithErrorsToStderr())
fmt.Println("After from init script ", mode.Download)
compmanager := components.NewComponentManager("celestia", mode.Binary)
err := compmanager.InitializeConfig()
if err != nil {
Expand Down
24 changes: 24 additions & 0 deletions cmd/utils/bash_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package utils

import (
"fmt"
"io"
"net/http"
"os"
"os/exec"
)
Expand All @@ -28,5 +30,27 @@ func ExecBashCmd(cmd *exec.Cmd, options ...CommandOption) error {
if err != nil {
return fmt.Errorf("command execution failed: %w", err)
}
fmt.Println("Command execution completed", cmd)
return nil
}

func downloadFile(url string) (string, error) {
response, err := http.Get(url)
if err != nil {
return "", err
}
defer response.Body.Close()

tmpFile, err := os.CreateTemp("", "script-*.sh")
if err != nil {
return "", err
}

_, err = io.Copy(tmpFile, response.Body)
if err != nil {
return "", err
}

tmpFile.Close()
return tmpFile.Name(), nil
}
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ curl -O https://vistara-labs.github.io/vimana/config.toml
sudo mkdir -p ~/.vimana && sudo mv config.toml ~/.vimana/config.toml
curl -O https://vistara-labs.github.io/vimana/scripts/init.sh
sudo mkdir -p /tmp/vimana/celestia && sudo mv init.sh /tmp/vimana/celestia/init.sh
sudo chmod +x /tmp/vimana/celestia/init.sh
echo "✅ vimana installed!"
1 change: 1 addition & 0 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ sudo unzip -q /tmp/vimcel/${OS}_${ARCH}.zip -d /tmp/vimcel/
sudo mv "/tmp/vimcel/${OS}_${ARCH}"/* "$INTERNAL_DIR"
sudo chmod +x "$INTERNAL_DIR"
sudo rm -rf "/tmp/vimcel"
sudo mkdir -p ~/.vimana/celestia
${INTERNAL_DIR}/celestia version
echo "💈 Celestia light node version installed!"

0 comments on commit bb89f53

Please sign in to comment.