Skip to content

Commit 514a890

Browse files
authored
Install mount as separate component (keybase#5052)
1 parent 40d4abd commit 514a890

5 files changed

Lines changed: 43 additions & 8 deletions

File tree

‎go/client/cmd_install_osx.go‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ func (v *CmdInstall) GetUsage() libkb.Usage {
7979
return libkb.Usage{}
8080
}
8181

82+
var defaultInstallComponents = []string{
83+
install.ComponentNameUpdater.String(),
84+
install.ComponentNameService.String(),
85+
install.ComponentNameMountDir.String(),
86+
install.ComponentNameKBFS.String(),
87+
}
88+
8289
func (v *CmdInstall) ParseArgv(ctx *cli.Context) error {
8390
v.force = ctx.Bool("force")
8491
v.format = ctx.String("format")
@@ -89,7 +96,7 @@ func (v *CmdInstall) ParseArgv(ctx *cli.Context) error {
8996
v.timeout = 11 * time.Second
9097
}
9198
if ctx.String("components") == "" {
92-
v.components = []string{"updater", "service", "kbfs"}
99+
v.components = defaultInstallComponents
93100
} else {
94101
v.components = strings.Split(ctx.String("components"), ",")
95102
}
@@ -133,6 +140,7 @@ func (v *CmdInstall) Run() error {
133140
var defaultUninstallComponents = []string{
134141
install.ComponentNameService.String(),
135142
install.ComponentNameKBFS.String(),
143+
install.ComponentNameMountDir.String(),
136144
install.ComponentNameUpdater.String(),
137145
install.ComponentNameFuse.String(),
138146
install.ComponentNameHelper.String(),
@@ -166,6 +174,7 @@ type CmdUninstall struct {
166174
libkb.Contextified
167175
format string
168176
components []string
177+
isDefault bool
169178
}
170179

171180
func NewCmdUninstallRunner(g *libkb.GlobalContext) *CmdUninstall {
@@ -181,6 +190,7 @@ func (v *CmdUninstall) GetUsage() libkb.Usage {
181190
func (v *CmdUninstall) ParseArgv(ctx *cli.Context) error {
182191
v.format = ctx.String("format")
183192
if ctx.String("components") == "" {
193+
v.isDefault = true
184194
if libkb.IsBrewBuild {
185195
v.components = []string{"service"}
186196
} else {
@@ -205,8 +215,10 @@ func (v *CmdUninstall) Run() error {
205215
}
206216
fmt.Fprintf(os.Stdout, "%s\n", out)
207217
} else {
208-
t := v.G().UI.GetTerminalUI()
209-
t.Printf("\nYou can now remove %s to complete your uninstall.\n", bundlePath)
218+
if v.isDefault {
219+
t := v.G().UI.GetTerminalUI()
220+
t.Printf("\nYou can now remove %s to complete your uninstall.\n", bundlePath)
221+
}
210222
}
211223
return nil
212224
}

‎go/install/install.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ const (
5858
ComponentNameFuse ComponentName = "fuse"
5959
// ComponentNameHelper is the privileged helper tool
6060
ComponentNameHelper ComponentName = "helper"
61+
// ComponentNameMountDir is the mount directory
62+
ComponentNameMountDir ComponentName = "mountdir"
6163
// ComponentNameUnknown is placeholder for unknown components
6264
ComponentNameUnknown ComponentName = "unknown"
6365
)

‎go/install/install_osx.go‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,14 @@ func Install(context Context, binPath string, components []string, force bool, t
428428
}
429429
}
430430

431+
if libkb.IsIn(string(ComponentNameMountDir), components, false) {
432+
err = installMountDir(context.GetRunMode(), log)
433+
componentResults = append(componentResults, componentResult(string(ComponentNameMountDir), err))
434+
if err != nil {
435+
log.Errorf("Error installing mount directory: %s", err)
436+
}
437+
}
438+
431439
if libkb.IsIn(string(ComponentNameKBFS), components, false) {
432440
err = InstallKBFS(context, binPath, force, timeout, log)
433441
componentResults = append(componentResults, componentResult(string(ComponentNameKBFS), err))
@@ -502,7 +510,7 @@ func InstallService(context Context, binPath string, force bool, timeout time.Du
502510
return err
503511
}
504512
UninstallKeybaseServices(context.GetRunMode(), log)
505-
log.Debug("Installing Keybase service (%s, timeout=%s)", label, timeout)
513+
log.Debug("Installing service (%s, timeout=%s)", label, timeout)
506514
if _, err := installKeybaseService(context, service, plist, timeout, log); err != nil {
507515
log.Errorf("Error installing Keybase service: %s", err)
508516
return err
@@ -544,7 +552,7 @@ func Uninstall(context Context, components []string, log Log) keybase1.Uninstall
544552
var mountDir string
545553
mountDir, err = context.GetMountDir()
546554
if err == nil {
547-
err = UninstallKBFS(context.GetRunMode(), mountDir, true, true, log)
555+
err = UninstallKBFS(context.GetRunMode(), mountDir, true, false, log)
548556
}
549557
componentResults = append(componentResults, componentResult(string(ComponentNameKBFS), err))
550558
if err != nil {
@@ -568,6 +576,14 @@ func Uninstall(context Context, components []string, log Log) keybase1.Uninstall
568576
}
569577
}
570578

579+
if libkb.IsIn(string(ComponentNameMountDir), components, false) {
580+
err = uninstallMountDir(context.GetRunMode(), log)
581+
componentResults = append(componentResults, componentResult(string(ComponentNameMountDir), err))
582+
if err != nil {
583+
log.Errorf("Error uninstalling mount dir: %s", err)
584+
}
585+
}
586+
571587
if libkb.IsIn(string(ComponentNameFuse), components, false) {
572588
err = uninstallFuse(context.GetRunMode(), log)
573589
componentResults = append(componentResults, componentResult(string(ComponentNameFuse), err))
@@ -681,6 +697,11 @@ func uninstallApp(runMode libkb.RunMode, log Log) error {
681697
return execNativeInstallerWithArg("--uninstall-app", runMode, log)
682698
}
683699

700+
func installMountDir(runMode libkb.RunMode, log Log) error {
701+
log.Info("Creating mount directory")
702+
return execNativeInstallerWithArg("--install-mountdir", runMode, log)
703+
}
704+
684705
func execNativeInstallerWithArg(arg string, runMode libkb.RunMode, log Log) error {
685706
appPath, err := AppBundleForPath()
686707
if err != nil {

‎go/launchd/launchd.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func waitForStatus(wait time.Duration, delay time.Duration, fn loadStatusFn) (*S
185185
}
186186

187187
ticker := time.NewTicker(delay)
188+
defer ticker.Stop()
188189
resultChan := make(chan serviceStatusResult, 1)
189190
go func() {
190191
for {
@@ -207,7 +208,6 @@ func waitForStatus(wait time.Duration, delay time.Duration, fn loadStatusFn) (*S
207208
case res := <-resultChan:
208209
return res.status, res.err
209210
case <-time.After(wait):
210-
ticker.Stop()
211211
return nil, nil
212212
}
213213
}
@@ -220,6 +220,7 @@ func (s Service) WaitForExit(wait time.Duration) error {
220220

221221
func waitForExit(wait time.Duration, delay time.Duration, fn loadStatusFn) error {
222222
ticker := time.NewTicker(delay)
223+
defer ticker.Stop()
223224
errChan := make(chan error, 1)
224225
go func() {
225226
for {
@@ -242,7 +243,6 @@ func waitForExit(wait time.Duration, delay time.Duration, fn loadStatusFn) error
242243
case err := <-errChan:
243244
return err
244245
case <-time.After(wait):
245-
ticker.Stop()
246246
return fmt.Errorf("Waiting for service exit timed out")
247247
}
248248
}

‎go/libkb/service_info.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ func waitForServiceInfo(timeout time.Duration, delay time.Duration, fn loadServi
118118
}
119119

120120
ticker := time.NewTicker(delay)
121+
defer ticker.Stop()
121122
resultChan := make(chan serviceInfoResult, 1)
122123
go func() {
123124
for {
@@ -140,7 +141,6 @@ func waitForServiceInfo(timeout time.Duration, delay time.Duration, fn loadServi
140141
case res := <-resultChan:
141142
return res.info, res.err
142143
case <-time.After(timeout):
143-
ticker.Stop()
144144
return nil, nil
145145
}
146146
}

0 commit comments

Comments
 (0)