Skip to content

Commit

Permalink
feat[close #263]: Support custom home directories for stacks/subsystems
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkobrombin committed Jan 14, 2024
1 parent 8bb53c8 commit f9b712b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.3.0
11 changes: 10 additions & 1 deletion cmd/subsyStems.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ func NewSubSystemsCommand() *cmdr.Command {
"",
),
)
newCmd.WithStringFlag(
cmdr.NewStringFlag(
"home",
"H",
apx.Trans("subsystems.new.options.home.description"),
"",
),
)
newCmd.WithBoolFlag(
cmdr.NewBoolFlag(
"init",
Expand Down Expand Up @@ -181,6 +189,7 @@ func listSubSystems(cmd *cobra.Command, args []string) error {
}

func newSubSystem(cmd *cobra.Command, args []string) error {
home, _ := cmd.Flags().GetString("home")
stackName, _ := cmd.Flags().GetString("stack")
subSystemName, _ := cmd.Flags().GetString("name")
isInit, _ := cmd.Flags().GetBool("init")
Expand Down Expand Up @@ -233,7 +242,7 @@ func newSubSystem(cmd *cobra.Command, args []string) error {
return err
}

subSystem, err := core.NewSubSystem(subSystemName, stack, isInit, false, false, false, true)
subSystem, err := core.NewSubSystem(subSystemName, stack, home, isInit, false, false, false, true)
if err != nil {
return err
}
Expand Down
6 changes: 5 additions & 1 deletion core/dbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (d *dbox) ContainerDelete(name string, rootFull bool) error {
return err
}

func (d *dbox) CreateContainer(name string, image string, additionalPackages []string, labels map[string]string, withInit bool, rootFull bool, unshared bool, withNvidiaIntegration bool) error {
func (d *dbox) CreateContainer(name string, image string, additionalPackages []string, home string, labels map[string]string, withInit bool, rootFull bool, unshared bool, withNvidiaIntegration bool) error {
args := []string{
"--image", image,
"--name", name,
Expand All @@ -230,6 +230,10 @@ func (d *dbox) CreateContainer(name string, image string, additionalPackages []s
"--pull",
}

if home != "" {
args = append(args, "--home", home)
}

if hasNvidiaGPU() && withNvidiaIntegration {
args = append(args, "--nvidia")
}
Expand Down
5 changes: 4 additions & 1 deletion core/subSystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type SubSystem struct {
InternalName string
Name string
Stack *Stack
Home string
Status string
ExportedPrograms map[string]map[string]string
HasInit bool
Expand All @@ -33,12 +34,13 @@ type SubSystem struct {
HasNvidiaIntegration bool
}

func NewSubSystem(name string, stack *Stack, hasInit bool, isManaged bool, isRootfull bool, isUnshared bool, hasNvidiaIntegration bool) (*SubSystem, error) {
func NewSubSystem(name string, stack *Stack, home string, hasInit bool, isManaged bool, isRootfull bool, isUnshared bool, hasNvidiaIntegration bool) (*SubSystem, error) {
internalName := genInternalName(name)
return &SubSystem{
InternalName: internalName,
Name: name,
Stack: stack,
Home: home,
HasInit: hasInit,
IsManaged: isManaged,
IsRootfull: isRootfull,
Expand Down Expand Up @@ -142,6 +144,7 @@ func (s *SubSystem) Create() error {
s.InternalName,
s.Stack.Base,
s.Stack.Packages,
s.Home,
labels,
s.HasInit,
s.IsRootfull,
Expand Down
2 changes: 2 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ subsystems:
description: "The name of the subsystem."
stack:
description: "The stack to use."
home:
description: "The custom home directory of the subsystem."
info:
description: "Use systemd inside the subsystem."
rm:
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
Version = "2.2.0"
Version = "2.3.0"
)

//go:embed locales/*.yml
Expand Down

0 comments on commit f9b712b

Please sign in to comment.