feat: restart to apply update, privileged helper, rollback

This commit is contained in:
fsylvain committed 2026-10-01 21:36:40 +02:00
1 parent 70460e4170
commit 54e8fd5fed
63 files changed
+8635 -164

No files matched your search

+63
View File
@@ -0,0 +1,63 @@
package update
import (
"crypto/sha256"
"encoding/hex"
"path"
)
const (
RestartRequestFileName = "update-restart-request.json"
ResultFileName = "update-result.json"
HelperStatusFileName = "update-helper.json"
RunningInfoFileName = "update-running.json"
UpdatesDirName = "updates"
HelperStatusVersion = 1
PathUnitName = "renewcms-update.path"
ServiceUnitName = "renewcms-update.service"
DefaultService = "renewcms"
DefaultPort = "8080"
PreviousSuffix = ".previous"
PreviousTempSuffix = ".previous.tmp"
InstallTempSuffix = ".new"
RestoreTempSuffix = ".restore"
ResultTempSuffix = ".tmp"
ExecutableMode = 0o755
PrivateFileMode = 0o600
)
type HelperLayout struct {
DataDir string
BinaryPath string
}
func (l HelperLayout) UpdatesDir() string {
return path.Join(l.DataDir, UpdatesDirName)
}
func (l HelperLayout) StagedDir(tag string) string {
return path.Join(l.UpdatesDir(), tag)
}
func (l HelperLayout) ResultPath() string {
return path.Join(l.DataDir, ResultFileName)
}
func (l HelperLayout) ResultTempPath() string {
return l.ResultPath() + ResultTempSuffix
}
func (l HelperLayout) RestartRequestPath() string {
return path.Join(l.DataDir, RestartRequestFileName)
}
func (l HelperLayout) PreviousPath() string {
return l.BinaryPath + PreviousSuffix
}
func SHA256Hex(content []byte) string {
sum := sha256.Sum256(content)
return hex.EncodeToString(sum[:])
}