@@ -3,17 +3,17 @@ package configure
33import (
44 "bytes"
55 "fmt"
6- "github.com/algorandfoundation/nodekit/cmd/utils/explanations"
7- "github.com/algorandfoundation/nodekit/internal/algod"
8- "github.com/algorandfoundation/nodekit/internal/algod/utils"
9- "github.com/algorandfoundation/nodekit/ui/style"
10- "github.com/charmbracelet/lipgloss"
116 "os"
127 "os/exec"
138 "runtime"
149 "strings"
1510 "text/template"
1611
12+ "github.com/algorandfoundation/nodekit/cmd/utils/explanations"
13+ "github.com/algorandfoundation/nodekit/internal/algod"
14+ "github.com/algorandfoundation/nodekit/internal/algod/utils"
15+ "github.com/algorandfoundation/nodekit/ui/style"
16+ "github.com/charmbracelet/lipgloss"
1717 "github.com/spf13/cobra"
1818)
1919
@@ -33,6 +33,8 @@ var long = lipgloss.JoinVertical(
3333 style .Yellow .Render (explanations .ExperimentalWarning ),
3434)
3535
36+ var algodData = ""
37+
3638var Cmd = & cobra.Command {
3739 Use : "configure" ,
3840 Short : short ,
@@ -42,6 +44,7 @@ var Cmd = &cobra.Command{
4244func init () {
4345 Cmd .AddCommand (serviceCmd )
4446 Cmd .AddCommand (telemetryCmd )
47+ Cmd .AddCommand (algodCmd )
4548}
4649
4750const RunningErrorMsg = "algorand is currently running. Please stop the node with *node stop* before configuring"
@@ -50,7 +53,7 @@ const RunningErrorMsg = "algorand is currently running. Please stop the node wit
5053func configureNode () error {
5154 var systemServiceConfigure bool
5255
53- if algod .IsRunning () {
56+ if algod .IsRunning (algodData ) {
5457 return fmt .Errorf (RunningErrorMsg )
5558 }
5659
@@ -140,9 +143,7 @@ func configureNode() error {
140143 }
141144 os .Exit (0 )
142145 }
143-
144146 } else {
145-
146147 if promptWrapperYes ("Do you want to set one of these directories as the new data directory? (y/N)" ) {
147148
148149 selectedPath := promptWrapperSelection ("Select an Algorand data directory" , paths )
@@ -200,7 +201,6 @@ func editAlgorandServiceFile(dataDirectoryPath string) {
200201}
201202
202203func editLaunchdAlgorandServiceFile (dataDirectoryPath string ) {
203-
204204 algodPath , err := exec .LookPath ("algod" )
205205 if err != nil {
206206 fmt .Printf ("Failed to find algod binary: %v\n " , err )
@@ -253,7 +253,7 @@ func editLaunchdAlgorandServiceFile(dataDirectoryPath string) {
253253 }
254254
255255 // Write the override content to the file
256- err = os .WriteFile (overwriteFilePath , overwriteContent .Bytes (), 0644 )
256+ err = os .WriteFile (overwriteFilePath , overwriteContent .Bytes (), 0o644 )
257257 if err != nil {
258258 fmt .Printf ("Failed to write override file: %v\n " , err )
259259 os .Exit (1 )
@@ -282,7 +282,6 @@ func editLaunchdAlgorandServiceFile(dataDirectoryPath string) {
282282
283283// Update the algorand.service file
284284func editSystemdAlgorandServiceFile (dataDirectoryPath string ) {
285-
286285 algodPath , err := exec .LookPath ("algod" )
287286 if err != nil {
288287 fmt .Printf ("Failed to find algod binary: %v\n " , err )
@@ -294,7 +293,7 @@ func editSystemdAlgorandServiceFile(dataDirectoryPath string) {
294293 overrideFilePath := "/etc/systemd/system/algorand.service.d/override.conf"
295294
296295 // Create the override directory if it doesn't exist
297- err = os .MkdirAll ("/etc/systemd/system/algorand.service.d" , 0755 )
296+ err = os .MkdirAll ("/etc/systemd/system/algorand.service.d" , 0o755 )
298297 if err != nil {
299298 fmt .Printf ("Failed to create override directory: %v\n " , err )
300299 os .Exit (1 )
@@ -328,7 +327,7 @@ ExecStart={{.AlgodPath}} -d {{.DataDirectoryPath}}`
328327 }
329328
330329 // Write the override content to the file
331- err = os .WriteFile (overrideFilePath , overrideContent .Bytes (), 0644 )
330+ err = os .WriteFile (overrideFilePath , overrideContent .Bytes (), 0o644 )
332331 if err != nil {
333332 fmt .Printf ("Failed to write override file: %v\n " , err )
334333 os .Exit (1 )
0 commit comments