Feature: show Alpine version at start
This commit is contained in:
@@ -144,6 +144,7 @@ func _main(ctx context.Context, buildInfo models.BuildInformation,
|
|||||||
fmt.Println(gluetunLogging.Splash(buildInfo))
|
fmt.Println(gluetunLogging.Splash(buildInfo))
|
||||||
|
|
||||||
printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){
|
printVersions(ctx, logger, map[string]func(ctx context.Context) (string, error){
|
||||||
|
"Alpine": alpineConf.Version,
|
||||||
"OpenVPN": ovpnConf.Version,
|
"OpenVPN": ovpnConf.Version,
|
||||||
"Unbound": dnsConf.Version,
|
"Unbound": dnsConf.Version,
|
||||||
"IPtables": firewallConf.Version,
|
"IPtables": firewallConf.Version,
|
||||||
|
|||||||
@@ -2,12 +2,15 @@
|
|||||||
package alpine
|
package alpine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/qdm12/golibs/os"
|
"github.com/qdm12/golibs/os"
|
||||||
"github.com/qdm12/golibs/os/user"
|
"github.com/qdm12/golibs/os/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Configurator interface {
|
type Configurator interface {
|
||||||
CreateUser(username string, uid int) (createdUsername string, err error)
|
CreateUser(username string, uid int) (createdUsername string, err error)
|
||||||
|
Version(ctx context.Context) (version string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type configurator struct {
|
type configurator struct {
|
||||||
|
|||||||
27
internal/alpine/version.go
Normal file
27
internal/alpine/version.go
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user