cmd: add very simple cmdline omaha server
this implementation uses the TrivialServer that is already provided by the go-omaha library. it is a very simple wrapper, simply asking for the file, version, and listening address on the command line. it can only handle one package at a time, naming the payload from the server "update.gz", which is the standard filename for the update payload. the additional metadata required for package creation is generated based on the provided file. when the server is setup, update_engine can be pointed at it by setting the SERVER variable in /etc/coreos/update.conf
This commit is contained in:
parent
e95ad781c1
commit
af61458371
3 changed files with 73 additions and 0 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1,3 @@
|
|||
pkg
|
||||
bin
|
||||
|
||||
|
|
25
Makefile
Normal file
25
Makefile
Normal file
|
@ -0,0 +1,25 @@
|
|||
# kernel-style V=1 build verbosity
|
||||
ifeq ("$(origin V)", "command line")
|
||||
BUILD_VERBOSE = $(V)
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VERBOSE),1)
|
||||
Q =
|
||||
else
|
||||
Q = @
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
all: bin/serve-package
|
||||
|
||||
bin/serve-package:
|
||||
$(Q)go build -o $@ cmd/serve-package/main.go
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(Q)rm -rf bin
|
||||
|
||||
.PHONY: vendor
|
||||
vendor:
|
||||
$(Q)glide update --strip-vendor
|
||||
$(Q)glide-vc --use-lock-file --no-tests --only-code
|
46
cmd/serve-package/main.go
Normal file
46
cmd/serve-package/main.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/coreos/go-omaha/omaha"
|
||||
)
|
||||
|
||||
func main() {
|
||||
pkgfile := flag.String("package-file", "", "Path to the update payload")
|
||||
version := flag.String("package-version", "", "Semantic version of the package provided")
|
||||
listenAddress := flag.String("listen-address", ":8000", "Host and IP to listen on")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
if *pkgfile == "" {
|
||||
fmt.Println("package-file is a required flag")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if *version == "" {
|
||||
fmt.Println("package-version is a required flag")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
server, err := omaha.NewTrivialServer(*listenAddress)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to make new server: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
server.SetVersion(*version)
|
||||
err = server.AddPackage(*pkgfile, "update.gz")
|
||||
if err != nil {
|
||||
fmt.Printf("failed to add package: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = server.Serve()
|
||||
if err != nil {
|
||||
fmt.Printf("server exited with an error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue