Add opt-in auto-update from Gitea releases
The program now lives in /usr/local/lib/blacktip and is owned by its service user so it can replace itself. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d9c422fb84
commit
c5019f38b6
7 files changed
+28
-9
No files matched your search
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
"git.veillax.com/Veillax/blacktip"
|
||||
"git.veillax.com/Veillax/reef/dotenv"
|
||||
"git.veillax.com/Veillax/reef/selfupdate"
|
||||
)
|
||||
|
||||
// version is set at build time (deploy/build.sh).
|
||||
@@ -38,6 +39,7 @@ func main() {
|
||||
acmeDNS := flag.String("acme-dns", os.Getenv("BLACKTIP_ACME_DNS"), "with -traefik: DNS-challenge provider (e.g. cloudflare) for wildcard certificates; its credentials go in this process's environment")
|
||||
noACME := flag.Bool("no-acme", false, "with -traefik: serve Traefik's self-signed certificate instead of requesting Let's Encrypt ones")
|
||||
flag.String("env", ".env", "file to read secrets and settings from")
|
||||
autoUpdate := flag.Bool("auto-update", os.Getenv("BLACKTIP_AUTO_UPDATE") == "1", "check for new releases every few hours and update and restart by itself (Linux and macOS)")
|
||||
showVersion := flag.Bool("version", false, "print the version and exit")
|
||||
flag.Parse()
|
||||
if *showVersion {
|
||||
@@ -58,6 +60,9 @@ func main() {
|
||||
log.Printf("blacktip %s starting", version)
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||
defer stop()
|
||||
if *autoUpdate {
|
||||
go selfupdate.Run(ctx, selfupdate.Config{Server: "https://git.veillax.com", Repo: "Veillax/blacktip", App: "blacktip", Current: version, Logf: log.Printf})
|
||||
}
|
||||
if err := b.Run(ctx); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user