setup: Error if no options are specified
This commit is contained in:
@@ -88,6 +88,7 @@ func (obj *Svc) Validate() error {
|
|||||||
// Run performs the desired actions. This templates and installs a systemd
|
// Run performs the desired actions. This templates and installs a systemd
|
||||||
// service and enables and starts it if so desired.
|
// service and enables and starts it if so desired.
|
||||||
func (obj *Svc) Run(ctx context.Context) error {
|
func (obj *Svc) Run(ctx context.Context) error {
|
||||||
|
once := false
|
||||||
cmdNameSystemctl := "/usr/bin/systemctl"
|
cmdNameSystemctl := "/usr/bin/systemctl"
|
||||||
opts := &util.SimpleCmdOpts{
|
opts := &util.SimpleCmdOpts{
|
||||||
Debug: obj.Debug,
|
Debug: obj.Debug,
|
||||||
@@ -140,6 +141,7 @@ func (obj *Svc) Run(ctx context.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
obj.Logf("wrote file to: %s", unitPath)
|
obj.Logf("wrote file to: %s", unitPath)
|
||||||
|
once = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj.SetupSvcArgs.Start {
|
if obj.SetupSvcArgs.Start {
|
||||||
@@ -147,6 +149,7 @@ func (obj *Svc) Run(ctx context.Context) error {
|
|||||||
if err := util.SimpleCmd(ctx, cmdNameSystemctl, cmdArgs, opts); err != nil {
|
if err := util.SimpleCmd(ctx, cmdNameSystemctl, cmdArgs, opts); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
once = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj.SetupSvcArgs.Enable {
|
if obj.SetupSvcArgs.Enable {
|
||||||
@@ -154,7 +157,11 @@ func (obj *Svc) Run(ctx context.Context) error {
|
|||||||
if err := util.SimpleCmd(ctx, cmdNameSystemctl, cmdArgs, opts); err != nil {
|
if err := util.SimpleCmd(ctx, cmdNameSystemctl, cmdArgs, opts); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
once = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !once {
|
||||||
|
return fmt.Errorf("nothing done")
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user