Skip to content

Commit

Permalink
make format check
Browse files Browse the repository at this point in the history
  • Loading branch information
0pcom committed Oct 12, 2024
1 parent 569215b commit 0346756
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
39 changes: 16 additions & 23 deletions cmd/skywire-cli/commands/rewards/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
package clirewards

import (
"fmt"
"bytes"

"fmt"
"os"
"os/user"
"text/template"
"syscall"

"text/template"

"github.com/bitfield/script"
"github.com/spf13/cobra"
)

var (
userName string
userName string
workingDir string
skyenvConf string
outputPath string
)

func init() {
RootCmd.AddCommand(
systemdServicesCmd,
Expand All @@ -46,21 +45,18 @@ func init() {
systemdServicesCmd.Flags().StringVarP(&outputPath, "out", "o", "/etc/systemd/system", "path to output systemd services")
}


var systemdServicesCmd = &cobra.Command{
Use: "systemd",
Short: "set up systemd services for reward system",
Long: `set up systemd services for reward system
Long: `set up systemd services for reward system
must be run with sufficient permissions to write to output path`,
Run: func(_ *cobra.Command, _ []string) {
// Get the current user



// Prepare the data for the template
serviceConfig := svcConfig{
User: userName,
Dir: workingDir,
User: userName,
Dir: workingDir,
Conf: skyenvConf,
}

Expand All @@ -76,12 +72,11 @@ must be run with sufficient permissions to write to output path`,
log.Fatal(err)
}

_, err = script.Echo(renderedServiceFile.String()).Tee().WriteFile(outputPath+"/skywire-reward.service")
_, err = script.Echo(renderedServiceFile.String()).Tee().WriteFile(outputPath + "/skywire-reward.service")
if err != nil {
log.Fatal(err)
}
fmt.Println("Wrote to:"+outputPath+"/skywire-reward.service")

fmt.Println("Wrote to:" + outputPath + "/skywire-reward.service")

// Create a new template and parse the service file template into it
tmpl, err = template.New("").Parse(fiberRewardSvcTpl)
Expand All @@ -95,24 +90,21 @@ must be run with sufficient permissions to write to output path`,
log.Fatal(err)
}

_, err = script.Echo(renderedServiceFile.String()).Tee().WriteFile(outputPath+"/fiberreward.service")
_, err = script.Echo(renderedServiceFile.String()).Tee().WriteFile(outputPath + "/fiberreward.service")
if err != nil {
log.Fatal(err)
}
fmt.Println("Wrote to:"+outputPath+"/fiberreward.service")
fmt.Println("Wrote to:" + outputPath + "/fiberreward.service")

_, err = script.Echo(skywireRewardTimerTpl).Tee().WriteFile(outputPath+"/skywire-reward.timer")
_, err = script.Echo(skywireRewardTimerTpl).Tee().WriteFile(outputPath + "/skywire-reward.timer")
if err != nil {
log.Fatal(err)
}
fmt.Println("Wrote to:"+outputPath+"/skywire-reward.timer")

fmt.Println("Wrote to:" + outputPath + "/skywire-reward.timer")

},
}



// Timer for log collection & reward calculation

const skywireRewardTimerTpl = `[Unit]
Expand Down Expand Up @@ -164,8 +156,9 @@ TimeoutSec=30
WantedBy=multi-user.target
`

type svcConfig struct {
User string
Dir string
User string
Dir string
Conf string
}
3 changes: 1 addition & 2 deletions cmd/skywire-cli/commands/rewards/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,7 +1369,7 @@ var (
n4 = " <a href='/log-collection/tree'>survey index</a>"
n5 = " <a href='/log-collection/tplogs'>transport logging</a>"
n6 = " <a href='" + strings.ReplaceAll(skywire.Prod.UptimeTracker, "http://", "https://") + "/uptimes?v=v2'>uptime tracker</a>"
n7 = " <a href='" + strings.ReplaceAll(skywire.Prod.AddressResolver, "http://", "https://") + "'>address resolver</a>"
n7 = " <a href='" + strings.ReplaceAll(skywire.Prod.AddressResolver, "http://", "https://") + "'>address resolver</a>"
n8 = " <a href='" + strings.ReplaceAll(skywire.Prod.TransportDiscovery, "http://", "https://") + "/all-transports'>transport discovery</a>"
n9 = " <a href='" + strings.ReplaceAll(skywire.Prod.DmsgDiscovery, "http://", "https://") + "/dmsg-discovery/entries'>dmsgd entries</a>"
n10 = " <a href='" + strings.ReplaceAll(skywire.Prod.DmsgDiscovery, "http://", "https://") + "/dmsg-discovery/all_servers'>all dmsg servers</a>"
Expand Down Expand Up @@ -1415,7 +1415,6 @@ var htmlHeaderTemplate = `
</header>
`


func scriptExecString(s string) string {
if runtime.GOOS == "windows" {
var variable, defaultvalue string
Expand Down

0 comments on commit 0346756

Please sign in to comment.