/
prepare_linux.go
38 lines (32 loc) · 1002 Bytes
/
prepare_linux.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package prepare
import (
svcApp "github.com/ActiveState/cli/cmd/state-svc/app"
svcAutostart "github.com/ActiveState/cli/cmd/state-svc/autostart"
"github.com/ActiveState/cli/internal/errs"
"github.com/ActiveState/cli/internal/locale"
"github.com/ActiveState/cli/internal/osutils/autostart"
)
func (r *Prepare) prepareOS() error {
svcApp, err := svcApp.New()
if err != nil {
r.reportError(locale.T("err_autostart_app"), err)
}
if err = autostart.Enable(svcApp.Path(), svcAutostart.Options); err != nil {
r.reportError(locale.Tl(
"err_prepare_autostart",
"Could not enable autostart: {{.V0}}.", err.Error(),
), err)
}
return nil
}
func cleanOS() error {
svcApp, err := svcApp.New()
if err != nil {
return locale.WrapError(err, "Could not get svc autostart shortcut")
}
// cleans ~/.profile if necessary
if err = autostart.Disable(svcApp.Path(), svcAutostart.Options); err != nil {
return errs.Wrap(err, "Failed to enable autostart for service app.")
}
return nil
}