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

@ -48,9 +48,7 @@ Finally two other components exist:
# Technical Overview
The go command is almost dependency free.
It expects that a basic debian system (in particular the `apt-get` command) is available.
The command has been tested only under Debian 10, but may also work under older or newer versions.
The command expects to be run as root, and will fail when this is not the case.
It only expects that `docker` and `docker compose` are available.
Each subcommand comes with documentation, which can be found in this readme (and the readme is always outdated), as well as via the command line when passing a `--help` flag.

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")