-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.go
41 lines (30 loc) · 1.17 KB
/
install.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package khatru_pyramid
import (
"fmt"
"github.com/nodetec/rwz/pkg/relays"
"github.com/nodetec/rwz/pkg/utils/files"
"github.com/pterm/pterm"
"path/filepath"
)
// Function to download and make the binary executable
func InstallRelayBinary() {
spinner, _ := pterm.DefaultSpinner.Start("Installing Khatru Pyramid relay...")
// Determine the file name from the URL
tmpFileName := filepath.Base(DownloadURL)
// Temporary file path
tmpFilePath := fmt.Sprintf("%s/%s", relays.TmpDirPath, tmpFileName)
// Check if the temporary file exists and remove it if it does
files.RemoveFile(tmpFilePath)
// Download and copy the file
files.DownloadAndCopyFile(tmpFilePath, DownloadURL)
// Extract binary
files.ExtractFile(tmpFilePath, relays.BinaryDestDir)
// TODO
// Currently, the downloaded binary is expected to have a name that matches the BinaryName variable
// Ideally, the extracted binary file should be renamed to match the BinaryName variable
// Define the final destination path
destPath := filepath.Join(relays.BinaryDestDir, BinaryName)
// Make the file executable
files.SetPermissions(destPath, 0755)
spinner.Success("Khatru Pyramid relay installed successfully.")
}