@@ -7,13 +7,14 @@ import (
7
7
"github.com/nodetec/rwz/pkg/utils/files"
8
8
"github.com/nodetec/rwz/pkg/utils/git"
9
9
"github.com/nodetec/rwz/pkg/utils/systemd"
10
+ "github.com/nodetec/rwz/pkg/verification"
10
11
"github.com/pterm/pterm"
11
12
"path/filepath"
12
13
)
13
14
14
15
// Function to download and make the binary executable
15
16
func InstallRelayBinary (pubKey string ) {
16
- spinner , _ := pterm .DefaultSpinner .Start (fmt .Sprintf ("Installing %s..." , RelayName ))
17
+ downloadSpinner , _ := pterm .DefaultSpinner .Start (fmt .Sprintf ("Downloading %s relay binary ..." , RelayName ))
17
18
18
19
// Check for and remove existing git repository
19
20
directories .RemoveDirectory (GitRepoTmpDirPath )
@@ -35,28 +36,35 @@ func InstallRelayBinary(pubKey string) {
35
36
// Download and copy the file
36
37
files .DownloadAndCopyFile (tmpFilePath , DownloadURL )
37
38
39
+ downloadSpinner .Success (fmt .Sprintf ("%s relay binary downloaded" , RelayName ))
40
+
41
+ // Verify relay binary
42
+ verification .VerifyRelayBinary (tmpFilePath )
43
+
44
+ installSpinner , _ := pterm .DefaultSpinner .Start (fmt .Sprintf ("Installing %s relay binary..." , RelayName ))
45
+
38
46
// Check if the service file exists and disable and stop the service if it does
39
47
if files .FileExists (ServiceFilePath ) {
40
48
// Disable and stop the Nostr relay service
41
- spinner .UpdateText ("Disabling and stopping service..." )
49
+ installSpinner .UpdateText ("Disabling and stopping service..." )
42
50
systemd .DisableService (ServiceName )
43
51
systemd .StopService (ServiceName )
44
52
} else {
45
- spinner .UpdateText ("Service file not found..." )
53
+ installSpinner .UpdateText ("Service file not found..." )
46
54
}
47
55
48
56
// Check if environment file exists
49
57
if files .FileExists (EnvFilePath ) {
50
58
// Check if the pubKey exists in the environment file
51
- spinner .UpdateText (fmt .Sprintf ("Checking for public key in the %s file..." , EnvFilePath ))
59
+ installSpinner .UpdateText (fmt .Sprintf ("Checking for public key in the %s file..." , EnvFilePath ))
52
60
lineExists := files .LineExists (fmt .Sprintf (`RELAY_PUBKEY="%s"` , pubKey ), EnvFilePath )
53
61
54
62
// If false remove data directory
55
63
if ! lineExists {
56
- spinner .UpdateText ("Public key not found, removing data directory..." )
64
+ installSpinner .UpdateText ("Public key not found, removing data directory..." )
57
65
directories .RemoveDirectory (DataDirPath )
58
66
} else {
59
- spinner .UpdateText ("Public key found, keeping data directory." )
67
+ installSpinner .UpdateText ("Public key found, keeping data directory." )
60
68
}
61
69
}
62
70
@@ -73,5 +81,5 @@ func InstallRelayBinary(pubKey string) {
73
81
// Make the file executable
74
82
files .SetPermissions (destPath , 0755 )
75
83
76
- spinner .Success (fmt .Sprintf ("%s relay binary downloaded and installed" , RelayName ))
84
+ installSpinner .Success (fmt .Sprintf ("%s relay binary installed" , RelayName ))
77
85
}
0 commit comments