cmd/system_update: Check for 'docker' and 'docker compose'

This commit is contained in:
Tom Wiesing 2022-11-22 10:21:12 +01:00
parent 57f2fe8c86
commit 4d3568a2e2
No known key found for this signature in database
3 changed files with 16 additions and 7 deletions

View file

@ -193,7 +193,8 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
// Tell the user how to proceed
logging.LogMessage(context.IOStream, "Bootstrap is complete")
context.Printf("Adjust the configuration file at %s\n", envPath)
context.Printf("Then grab a GraphDB zipped source file and run:\n")
context.Printf("Then make sure 'docker compose' is installed.\n")
context.Printf("Finally grab a GraphDB zipped source file and run:\n")
context.Printf("%s system_update /path/to/graphdb.zip\n", wdcliPath)
return nil

View file

@ -20,8 +20,8 @@ import (
var SystemUpdate wisski_distillery.Command = systemupdate{}
type systemupdate struct {
SkipCoreUpdates bool `short:"s" long:"skip-core-updates" description:"Skip applying operating system and other core system updates"`
Positionals struct {
InstallDocker bool `short:"a" long:"install-docker" description:"Try to automatically install docker. Assumes 'apt-get' as a package manager. "`
Positionals struct {
GraphdbZip string `positional-arg-name:"PATH_TO_GRAPHDB_ZIP" required:"1-1" description:"path to the graphdb.zip file"`
} `positional-args:"true"`
}
@ -79,7 +79,7 @@ func (si systemupdate) Run(context wisski_distillery.Context) error {
}
}
if !si.SkipCoreUpdates {
if si.InstallDocker {
// install system updates
logging.LogMessage(context.IOStream, "Updating Operating System Packages")
if err := si.mustExec(context, "", "apt-get", "update"); err != nil {
@ -100,6 +100,16 @@ func (si systemupdate) Run(context wisski_distillery.Context) error {
}
}
logging.LogMessage(context.IOStream, "Checking that 'docker' is installed")
if err := si.mustExec(context, "", "docker", "--version", dis.Config.DockerNetworkName); err != nil {
return err
}
logging.LogMessage(context.IOStream, "Checking that 'docker compose' is available")
if err := si.mustExec(context, "", "docker", "compose", "version"); err != nil {
return err
}
// create the docker network
// TODO: Use docker API for this
logging.LogMessage(context.IOStream, "Updating Docker Configuration")