Feature: show Alpine version at start

This commit is contained in:
Quentin McGaw
2021-05-19 14:30:43 +00:00
parent a9589d8d5b
commit 4f521e4dcb
3 changed files with 31 additions and 0 deletions

View File

@@ -144,6 +144,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
fmt.Println(gluetunLogging.Splash(buildInfo))
printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){
"Alpine": alpineConf.Version,
"OpenVPN": ovpnConf.Version,
"Unbound": dnsConf.Version,
"IPtables": firewallConf.Version,

View File

@@ -2,12 +2,15 @@
package alpine
import (
"context"
"github.com/qdm12/golibs/os"
"github.com/qdm12/golibs/os/user"
)
type Configurator interface {
CreateUser(username string, uid int) (createdUsername string, err error)
Version(ctx context.Context) (version string, err error)
}
type configurator struct {

View File

@@ -0,0 +1,27 @@
package alpine
import (
"context"
"io"
"os"
"strings"
)
func (c *configurator) Version(ctx context.Context) (version string, err error) {
file, err := c.openFile("/etc/alpine-release", os.O_RDONLY, 0)
if err != nil {
return "", err
}
b, err := io.ReadAll(file)
if err != nil {
return "", err
}
if err := file.Close(); err != nil {
return "", err
}
version = strings.ReplaceAll(string(b), "\n", "")
return version, nil
}