Add managed Gitea updates and server installer
This commit is contained in:
33
update.go
Normal file
33
update.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
const defaultUpdateStatusPath = "/var/lib/proxmox-dashboard/update-status.json"
|
||||
|
||||
type UpdateStatus struct {
|
||||
CurrentVersion string `json:"currentVersion"`
|
||||
AvailableVersion string `json:"availableVersion"`
|
||||
State string `json:"state"`
|
||||
Mode string `json:"mode"`
|
||||
Message string `json:"message"`
|
||||
ReleaseURL string `json:"releaseUrl"`
|
||||
CheckedAt time.Time `json:"checkedAt"`
|
||||
}
|
||||
|
||||
func readUpdateStatus() UpdateStatus {
|
||||
status := UpdateStatus{CurrentVersion: version, State: "unknown", Mode: "notify"}
|
||||
path := os.Getenv("DASHBOARD_UPDATE_STATUS_PATH")
|
||||
if path == "" {
|
||||
path = defaultUpdateStatusPath
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil || json.Unmarshal(data, &status) != nil {
|
||||
return status
|
||||
}
|
||||
status.CurrentVersion = version
|
||||
return status
|
||||
}
|
||||
Reference in New Issue
Block a user