Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add selfupdate #51

Merged
merged 9 commits into from
Jan 5, 2025
Prev Previous commit
Next Next commit
Remove systemd restart from autoupdate
  • Loading branch information
QuintenQVD0 authored Dec 7, 2024
commit b7e1b53341d374945927e6f7234ea4b299ece3f2
21 changes: 1 addition & 20 deletions cmd/selfupdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"io"
"net/http"
"os"
"os/exec"

Check failure on line 10 in cmd/selfupdate.go

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-22.04, 1.22.7, linux, amd64)

"os/exec" imported and not used

Check failure on line 10 in cmd/selfupdate.go

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-22.04, 1.22.7, linux, arm64)

"os/exec" imported and not used

Check failure on line 10 in cmd/selfupdate.go

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-22.04, 1.23.3, linux, amd64)

"os/exec" imported and not used

Check failure on line 10 in cmd/selfupdate.go

View workflow job for this annotation

GitHub Actions / Build and Test (ubuntu-22.04, 1.23.3, linux, arm64)

"os/exec" imported and not used
"runtime"
"strings"
"time"
Expand Down Expand Up @@ -110,13 +110,8 @@
return
}

fmt.Println("Restarting service...")
fmt.Println("Now restart the wings service. Example: systemctl restart wings")

if err := restartService(); err != nil {
fmt.Println("Error restarting the wings service:", err)
} else {
fmt.Println("Service restarted successfully.")
}
}

func fetchLatestGitHubRelease() (string, error) {
Expand Down Expand Up @@ -241,17 +236,3 @@

return n, err
}

func restartService() error {
// Try to run the systemctl restart command
cmd := exec.Command("systemctl", "restart", "wings")
cmdOutput, err := cmd.CombinedOutput()

if err != nil {
// If systemctl command fails, return the error with output
return fmt.Errorf("failed to restart service: %s\n%s", err.Error(), string(cmdOutput))
}

// If successful, return nil
return nil
}
Loading