-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: chain-initiator uses snapshot url and export genesis file from …
…there
- Loading branch information
Showing
3 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os/exec" | ||
) | ||
|
||
func export(cmdPath, homePath, genesisFilePath string) { | ||
// Command and arguments | ||
args := []string{"export", "--home", homePath} | ||
|
||
// Execute the command and capture the output | ||
output, err := exec.Command(cmdPath, args...).CombinedOutput() | ||
if err != nil { | ||
log.Fatalf("Command execution failed: %v", err) | ||
} | ||
|
||
// Write the output to the specified file | ||
err = ioutil.WriteFile(genesisFilePath, output, 0644) | ||
if err != nil { | ||
log.Fatalf("Failed to write output to file: %v", err) | ||
} | ||
|
||
log.Printf("Output successfully written to %s", genesisFilePath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"os/exec" | ||
) | ||
|
||
func retrieveSnapshot(snapshotUrl, homePath string) { | ||
// Construct the command string | ||
cmdString := "curl -o - -L " + snapshotUrl + " | lz4 -c -d - | tar -x -C " + homePath | ||
|
||
// Execute the command using /bin/sh | ||
cmd := exec.Command("/bin/sh", "-c", cmdString) | ||
if err := cmd.Run(); err != nil { | ||
log.Fatalf("Command execution failed: %v", err) | ||
} | ||
|
||
// If execution reaches here, the command was successful | ||
log.Printf("Snapshot retrieved and extracted to path: %s", homePath) | ||
} |