@@ -277,7 +277,7 @@ func keybasePlist(context Context, binPath string, label string, log Log) (launc
277277}
278278
279279func installKeybaseService (context Context , service launchd.Service , plist launchd.Plist , wait time.Duration , log Log ) (* keybase1.ServiceStatus , error ) {
280- err := launchd .Install (plist , defaultLaunchdWait , log )
280+ err := launchd .Install (plist , wait , log )
281281 if err != nil {
282282 return nil , err
283283 }
@@ -330,7 +330,7 @@ func kbfsPlist(context Context, kbfsBinPath string, label string) (plist launchd
330330}
331331
332332func installKBFSService (context Context , service launchd.Service , plist launchd.Plist , wait time.Duration , log Log ) (* keybase1.ServiceStatus , error ) {
333- err := launchd .Install (plist , defaultLaunchdWait , log )
333+ err := launchd .Install (plist , wait , log )
334334 if err != nil {
335335 return nil , err
336336 }
@@ -339,7 +339,7 @@ func installKBFSService(context Context, service launchd.Service, plist launchd.
339339 return & st , err
340340}
341341
342- // UninstallUninstallKBFSServicesBFS removes KBFS service (including homebrew)
342+ // UninstallKBFSServices removes KBFS service (including homebrew)
343343func UninstallKBFSServices (runMode libkb.RunMode , log Log ) error {
344344 err1 := launchd .Uninstall (defaultKBFSLabel (runMode , false ), defaultLaunchdWait , log )
345345 err2 := launchd .Uninstall (defaultKBFSLabel (runMode , true ), defaultLaunchdWait , log )
@@ -398,14 +398,14 @@ func ServiceStatus(context Context, label ServiceLabel, wait time.Duration, log
398398}
399399
400400// Install installs all keybase components
401- func Install (context Context , binPath string , components []string , force bool , log Log ) keybase1.InstallResult {
401+ func Install (context Context , binPath string , components []string , force bool , timeout time. Duration , log Log ) keybase1.InstallResult {
402402 var err error
403403 componentResults := []keybase1.ComponentResult {}
404404
405405 log .Debug ("Installing components: %s" , components )
406406
407407 if libkb .IsIn (string (ComponentNameUpdater ), components , false ) {
408- err = InstallUpdater (context , binPath , force , log )
408+ err = InstallUpdater (context , binPath , force , timeout , log )
409409 componentResults = append (componentResults , componentResult (string (ComponentNameUpdater ), err ))
410410 }
411411
@@ -415,12 +415,12 @@ func Install(context Context, binPath string, components []string, force bool, l
415415 }
416416
417417 if libkb .IsIn (string (ComponentNameService ), components , false ) {
418- err = InstallService (context , binPath , force , log )
418+ err = InstallService (context , binPath , force , timeout , log )
419419 componentResults = append (componentResults , componentResult (string (ComponentNameService ), err ))
420420 }
421421
422422 if libkb .IsIn (string (ComponentNameKBFS ), components , false ) {
423- err = InstallKBFS (context , binPath , force , log )
423+ err = InstallKBFS (context , binPath , force , timeout , log )
424424 componentResults = append (componentResults , componentResult (string (ComponentNameKBFS ), err ))
425425 }
426426
@@ -476,7 +476,7 @@ func installCommandLineForBinPath(binPath string, linkPath string, force bool) e
476476}
477477
478478// InstallService installs the launchd service
479- func InstallService (context Context , binPath string , force bool , log Log ) error {
479+ func InstallService (context Context , binPath string , force bool , timeout time. Duration , log Log ) error {
480480 resolvedBinPath , err := chooseBinPath (binPath )
481481 if err != nil {
482482 return err
@@ -489,37 +489,17 @@ func InstallService(context Context, binPath string, force bool, log Log) error
489489 if err != nil {
490490 return err
491491 }
492- log .Debug ("Checking service: %s" , label )
493- keybaseStatus := KeybaseServiceStatus (context , label , time .Second , log )
494- log .Debug ("Service: %s (Action: %s); %#v" , keybaseStatus .InstallStatus .String (), keybaseStatus .InstallAction .String (), keybaseStatus )
495- needsInstall := keybaseStatus .NeedsInstall ()
496-
497- if ! needsInstall {
498- plistValid , err := service .CheckPlist (plist )
499- if err != nil {
500- return err
501- }
502- if ! plistValid {
503- log .Debug ("Needs plist upgrade: %s" , service .PlistDestination ())
504- needsInstall = true
505- }
506- }
507-
508- if needsInstall || force {
509- UninstallKeybaseServices (context .GetRunMode (), log )
510- log .Debug ("Installing Keybase service" )
511- _ , err := installKeybaseService (context , service , plist , defaultLaunchdWait , log )
512- if err != nil {
513- log .Errorf ("Error installing Keybase service: %s" , err )
514- return err
515- }
492+ UninstallKeybaseServices (context .GetRunMode (), log )
493+ log .Debug ("Installing Keybase service (%s, timeout=%s)" , label , timeout )
494+ if _ , err := installKeybaseService (context , service , plist , timeout , log ); err != nil {
495+ log .Errorf ("Error installing Keybase service: %s" , err )
496+ return err
516497 }
517-
518498 return nil
519499}
520500
521501// InstallKBFS installs the KBFS launchd service
522- func InstallKBFS (context Context , binPath string , force bool , log Log ) error {
502+ func InstallKBFS (context Context , binPath string , force bool , timeout time. Duration , log Log ) error {
523503 runMode := context .GetRunMode ()
524504 label := DefaultKBFSLabel (runMode )
525505 kbfsService := launchd .NewService (label )
@@ -532,31 +512,12 @@ func InstallKBFS(context Context, binPath string, force bool, log Log) error {
532512 return err
533513 }
534514
535- log .Debug ("Checking KBFS" )
536- kbfsStatus := KBFSServiceStatus (context , label , time .Second , log )
537- log .Debug ("KBFS: %s (Action: %s); %#v" , kbfsStatus .InstallStatus .String (), kbfsStatus .InstallAction .String (), kbfsStatus )
538- needsInstall := kbfsStatus .NeedsInstall ()
539-
540- if ! needsInstall {
541- plistValid , err := kbfsService .CheckPlist (plist )
542- if err != nil {
543- return err
544- }
545- if ! plistValid {
546- log .Debug ("Needs plist upgrade: %s" , kbfsService .PlistDestination ())
547- needsInstall = true
548- }
549- }
550- if needsInstall || force {
551- UninstallKBFSServices (context .GetRunMode (), log )
552- log .Debug ("Installing KBFS" )
553- _ , err := installKBFSService (context , kbfsService , plist , defaultLaunchdWait , log )
554- if err != nil {
555- log .Errorf ("Error installing KBFS: %s" , err )
556- return err
557- }
515+ UninstallKBFSServices (context .GetRunMode (), log )
516+ log .Debug ("Installing KBFS (%s, timeout=%s)" , label , timeout )
517+ if _ , err := installKBFSService (context , kbfsService , plist , timeout , log ); err != nil {
518+ log .Errorf ("Error installing KBFS: %s" , err )
519+ return err
558520 }
559-
560521 return nil
561522}
562523
@@ -677,25 +638,25 @@ func execNativeInstallerWithArg(arg string, runMode libkb.RunMode, log Log) erro
677638}
678639
679640// AutoInstallWithStatus runs the auto install and returns a result
680- func AutoInstallWithStatus (context Context , binPath string , force bool , log Log ) keybase1.InstallResult {
681- _ , res , err := autoInstall (context , binPath , force , log )
641+ func AutoInstallWithStatus (context Context , binPath string , force bool , timeout time. Duration , log Log ) keybase1.InstallResult {
642+ _ , res , err := autoInstall (context , binPath , force , timeout , log )
682643 if err != nil {
683644 return keybase1.InstallResult {Status : keybase1 .StatusFromCode (keybase1 .StatusCode_SCInstallError , err .Error ())}
684645 }
685646 return newInstallResult (res )
686647}
687648
688649// AutoInstall runs the auto install
689- func AutoInstall (context Context , binPath string , force bool , log Log ) (newProc bool , err error ) {
650+ func AutoInstall (context Context , binPath string , force bool , timeout time. Duration , log Log ) (newProc bool , err error ) {
690651 if context .GetRunMode () != libkb .ProductionRunMode {
691652 return false , fmt .Errorf ("Auto install is only supported in production" )
692653 }
693654
694- newProc , _ , err = autoInstall (context , binPath , force , log )
655+ newProc , _ , err = autoInstall (context , binPath , force , timeout , log )
695656 return
696657}
697658
698- func autoInstall (context Context , binPath string , force bool , log Log ) (newProc bool , componentResults []keybase1.ComponentResult , err error ) {
659+ func autoInstall (context Context , binPath string , force bool , timeout time. Duration , log Log ) (newProc bool , componentResults []keybase1.ComponentResult , err error ) {
699660 log .Debug ("+ AutoInstall for launchd" )
700661 defer func () {
701662 log .Debug ("- AutoInstall -> %v, %v" , newProc , err )
@@ -723,7 +684,7 @@ func autoInstall(context Context, binPath string, force bool, log Log) (newProc
723684 return
724685 }
725686
726- err = InstallService (context , binPath , true , log )
687+ err = InstallService (context , binPath , true , timeout , log )
727688 componentResults = append (componentResults , componentResult (string (ComponentNameService ), err ))
728689 if err != nil {
729690 return
@@ -880,7 +841,7 @@ func OSVersion() (semver.Version, error) {
880841}
881842
882843// InstallUpdater installs the updater launchd service
883- func InstallUpdater (context Context , keybaseBinPath string , force bool , log Log ) error {
844+ func InstallUpdater (context Context , keybaseBinPath string , force bool , timeout time. Duration , log Log ) error {
884845 if context .GetRunMode () != libkb .ProductionRunMode {
885846 return fmt .Errorf ("Updater not supported in this run mode" )
886847 }
@@ -901,38 +862,12 @@ func InstallUpdater(context Context, keybaseBinPath string, force bool, log Log)
901862 return err
902863 }
903864
904- launchdStatus , err := service .LoadStatus ()
905- if err != nil {
865+ UninstallUpdaterService (context .GetRunMode (), log )
866+ log .Debug ("Installing updater service (%s, timeout=%s)" , label , timeout )
867+ if _ , err := installUpdaterService (service , plist , timeout , log ); err != nil {
868+ log .Errorf ("Error installing updater service: %s" , err )
906869 return err
907870 }
908-
909- needsInstall := false
910- if launchdStatus == nil {
911- log .Debug ("No status, needs install" )
912- needsInstall = true
913- }
914-
915- if ! needsInstall {
916- plistValid , err := service .CheckPlist (plist )
917- if err != nil {
918- return err
919- }
920- if ! plistValid {
921- log .Debug ("Plist needs update: %s" , service .PlistDestination ())
922- needsInstall = true
923- }
924- }
925-
926- if needsInstall || force {
927- UninstallUpdaterService (context .GetRunMode (), log )
928- log .Debug ("Installing updater service" )
929- _ , err := installUpdaterService (service , plist , defaultLaunchdWait , log )
930- if err != nil {
931- log .Errorf ("Error installing updater service: %s" , err )
932- return err
933- }
934- }
935-
936871 return nil
937872}
938873
@@ -949,7 +884,7 @@ func updaterPlist(context Context, label string, serviceBinPath string, keybaseB
949884}
950885
951886func installUpdaterService (service launchd.Service , plist launchd.Plist , wait time.Duration , log Log ) (* keybase1.ServiceStatus , error ) {
952- err := launchd .Install (plist , defaultLaunchdWait , log )
887+ err := launchd .Install (plist , wait , log )
953888 if err != nil {
954889 return nil , err
955890 }
0 commit comments