// Install implements Service.
510461
func (s *Service) Install() error {
	if s.NoConf() {
		return s.errorf(nil, "missing conf")
	}

	err := s.install()
	if errors.IsAlreadyExists(err) {
		logger.Debugf("service %q already installed", s.Name())
		return nil
	} else if err != nil {
		logger.Errorf("failed to install service %q: %v", s.Name(), err)
		return err
	}
	logger.Debugf("service %q successfully installed", s.Name())
	return nil
}
499339
func (s *Service) InstallCommands() ([]string, error) {
	if s.NoConf() {
		return nil, s.errorf(nil, "missing conf")
	}

	name := s.Name()
	dirname := s.DirName

	data, err := s.serialize()
	if err != nil {
		return nil, errors.Trace(err)
	}

	cmdList := []string{
		cmds.mkdirs(dirname),
	}
	if s.Script != nil {
		scriptName := renderer.Base(renderer.ScriptFilename("exec-start", ""))
		cmdList = append(cmdList, []string{
			// TODO(ericsnow) Use the renderer here.
			cmds.writeFile(scriptName, dirname, s.Script),
			cmds.chmod(scriptName, dirname, 0755),
		}...)
	}
	cmdList = append(cmdList, []string{
		cmds.writeConf(name, dirname, data),
		cmds.link(name, dirname),
		cmds.reload(),
		cmds.enableLinked(name, dirname),
	}...)
	return cmdList, nil
}
492265
func (w *whitelistRegistry) Install(_ User, app AppManifest) error {
	// We assume that the parentDir already exists, where the binary lives.
	jsonPath, keyPath := w.paths(app)
	if err := w.writeJSON(jsonPath, app); err != nil {
		return err
	}

	scope := registry.CURRENT_USER
	k, _, err := registry.CreateKey(scope, keyPath, registry.SET_VALUE|registry.CREATE_SUB_KEY|registry.WRITE)
	if err != nil {
		return err
	}
	defer k.Close()

	return k.SetStringValue("", jsonPath)
}
528466
func (s *Supervisor) Add(service Service, opts ...ServiceOption) {
	s.addService(service, opts...)
}
1067376
func (s *Service) Installed() (bool, error) {
	_, err := os.Stat(s.confPath())
	if os.IsNotExist(err) {
		return false, nil
	}
	if err != nil {
		return false, errors.Trace(err)
	}
	return true, nil
}
834015
func (i Index) Install(pathProvider ListedPathProvider, mux *mux.PathRecorderMux) {
	handler := IndexLister{StatusCode: http.StatusOK, PathProvider: pathProvider}

	mux.UnlistedHandle("/", handler)
	mux.UnlistedHandle("/index.html", handler)
}
657011
func (linux *systemDRecord) Install(args ...string) (string, error) {
	installAction := "Install " + linux.description + ":"

	if ok, err := checkPrivileges(); !ok {
		return installAction + failed, err
	}

	srvPath := linux.servicePath()

	if linux.isInstalled() {
		return installAction + failed, ErrAlreadyInstalled
	}

	file, err := os.Create(srvPath)
	if err != nil {
		return installAction + failed, err
	}
	defer file.Close()

	execPatch, err := executablePath(linux.name)
	if err != nil {
		return installAction + failed, err
	}

	templ, err := template.New("systemDConfig").Parse(systemDConfig)
	if err != nil {
		return installAction + failed, err
	}

	if err := templ.Execute(
		file,
		&struct {
			Name, Description, Dependencies, Path, Args string
		}{
			linux.name,
			linux.description,
			strings.Join(linux.dependencies, " "),
			execPatch,
			strings.Join(args, " "),
		},
	); err != nil {
		return installAction + failed, err
	}

	if err := exec.Command("systemctl", "daemon-reload").Run(); err != nil {
		return installAction + failed, err
	}

	if err := exec.Command("systemctl", "enable", linux.name+".service").Run(); err != nil {
		return installAction + failed, err
	}

	return installAction + success, nil
}
1084684
func (s *Service) Install() error {
	exists, same, conf, err := s.existsAndSame()
	if err != nil {
		return errors.Trace(err)
	}
	if same {
		return nil
	}
	if exists {
		if err := s.Stop(); err != nil {
			return errors.Annotate(err, "upstart: could not stop installed service")
		}
		if err := s.Remove(); err != nil {
			return errors.Annotate(err, "upstart: could not remove installed service")
		}
	}
	if err := ioutil.WriteFile(s.confPath(), conf, 0644); err != nil {
		return errors.Trace(err)
	}

	return nil
}
557378
func Install(scheme *runtime.Scheme) {
	utilruntime.Must(batch.AddToScheme(scheme))
	utilruntime.Must(v1.AddToScheme(scheme))
	utilruntime.Must(v1beta1.AddToScheme(scheme))
	utilruntime.Must(v2alpha1.AddToScheme(scheme))
	utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v1beta1.SchemeGroupVersion, v2alpha1.SchemeGroupVersion))
}
555406
func Install(scheme *runtime.Scheme) {
	utilruntime.Must(autoscaling.AddToScheme(scheme))
	utilruntime.Must(v2beta2.AddToScheme(scheme))
	utilruntime.Must(v2beta1.AddToScheme(scheme))
	utilruntime.Must(v1.AddToScheme(scheme))
	utilruntime.Must(scheme.SetVersionPriority(v1.SchemeGroupVersion, v2beta1.SchemeGroupVersion, v2beta2.SchemeGroupVersion))
}
1298213
func (l *Login) Install(mux oauthserver.Mux, paths ...string) {
	for _, path := range paths {
		path = strings.TrimRight(path, "/")
		mux.HandleFunc(path, l.ServeHTTP)
	}
}
370536
func (a *MetricsAPIInstaller) Install(ws *restful.WebService) (errors []error) {
	errors = make([]error, 0)

	err := a.handlers.registerResourceHandlers(a, ws)
	if err != nil {
		errors = append(errors, fmt.Errorf("error in registering custom metrics resource: %v", err))
	}

	return errors
}
34658
func (windows *windowsRecord) Install(args ...string) (string, error) {
	installAction := "Install " + windows.description + ":"

	execp, err := execPath()

	if err != nil {
		return installAction + failed, err
	}

	m, err := mgr.Connect()
	if err != nil {
		return installAction + failed, err
	}
	defer m.Disconnect()

	s, err := m.OpenService(windows.name)
	if err == nil {
		s.Close()
		return installAction + failed, err
	}

	s, err = m.CreateService(windows.name, execp, mgr.Config{
		DisplayName:  windows.name,
		Description:  windows.description,
		StartType:    mgr.StartAutomatic,
		Dependencies: windows.dependencies,
	}, args...)
	if err != nil {
		return installAction + failed, err
	}
	defer s.Close()

	return installAction + " completed.", nil
}
843225
func installService() error {
	// Get the path of the current executable.  This is needed because
	// os.Args[0] can vary depending on how the application was launched.
	// For example, under cmd.exe it will only be the name of the app
	// without the path or extension, but under mingw it will be the full
	// path including the extension.
	exePath, err := filepath.Abs(os.Args[0])
	if err != nil {
		return err
	}
	if filepath.Ext(exePath) == "" {
		exePath += ".exe"
	}

	// Connect to the windows service manager.
	serviceManager, err := mgr.Connect()
	if err != nil {
		return err
	}
	defer serviceManager.Disconnect()

	// Ensure the service doesn't already exist.
	service, err := serviceManager.OpenService(svcName)
	if err == nil {
		service.Close()
		return fmt.Errorf("service %s already exists", svcName)
	}

	// Install the service.
	service, err = serviceManager.CreateService(svcName, exePath, mgr.Config{
		DisplayName: svcDisplayName,
		Description: svcDesc,
	})
	if err != nil {
		return err
	}
	defer service.Close()

	// Support events to the event log using the standard "standard" Windows
	// EventCreate.exe message file.  This allows easy logging of custom
	// messges instead of needing to create our own message catalog.
	eventlog.Remove(svcName)
	eventsSupported := uint32(eventlog.Error | eventlog.Warning | eventlog.Info)
	return eventlog.InstallAsEventCreate(svcName, eventsSupported)
}
508296
func Install(context Context, binPath string, sourcePath string, components []string, force bool, timeout time.Duration, log Log) keybase1.InstallResult {
	var err error
	componentResults := []keybase1.ComponentResult{}

	log.Debug("Installing components: %s", components)

	if libkb.IsIn(string(ComponentNameCLI), components, false) {
		err = installCommandLine(context, binPath, true, log) // Always force CLI install
		componentResults = append(componentResults, componentResult(string(ComponentNameCLI), err))
		if err != nil {
			log.Errorf("Error installing CLI: %s", err)
		}
	}

	if libkb.IsIn(string(ComponentNameApp), components, false) {
		err = libnativeinstaller.InstallAppBundle(context, sourcePath, log)
		componentResults = append(componentResults, componentResult(string(ComponentNameApp), err))
		if err != nil {
			log.Errorf("Error installing app bundle: %s", err)
		}
	}

	if libkb.IsIn(string(ComponentNameUpdater), components, false) {
		err = InstallUpdater(context, binPath, force, timeout, log)
		componentResults = append(componentResults, componentResult(string(ComponentNameUpdater), err))
		if err != nil {
			log.Errorf("Error installing updater: %s", err)
		}
	}

	if libkb.IsIn(string(ComponentNameService), components, false) {
		err = InstallService(context, binPath, force, timeout, log)
		componentResults = append(componentResults, componentResult(string(ComponentNameService), err))
		if err != nil {
			log.Errorf("Error installing service: %s", err)
		}
	}

	helperCanceled := false
	if libkb.IsIn(string(ComponentNameHelper), components, false) {
		err = libnativeinstaller.InstallHelper(context.GetRunMode(), log)
		cr := componentResult(string(ComponentNameHelper), err)
		componentResults = append(componentResults, cr)
		if err != nil {
			log.Errorf("Error installing Helper: %v", err)
		}
		if cr.ExitCode == installHelperExitCodeAuthCanceled {
			log.Debug("Auth canceled; uninstalling mountdir and fuse")
			helperCanceled = true
			// Unmount the user's KBFS directory.
			mountDir, err := context.GetMountDir()
			if err == nil {
				err = UninstallKBFS(context, mountDir, true, log)
			}
			if err != nil {
				log.Errorf("Error uninstalling KBFS: %s", err)
			}

			// For older systems, check `/keybase` too, just in case.
			var oldMountDir string
			switch context.GetRunMode() {
			case libkb.ProductionRunMode:
				oldMountDir = "/keybase"
			case libkb.StagingRunMode:
				oldMountDir = "/keybase.staging"
			default:
				oldMountDir = "/keybase.devel"
			}
			err = unmount(oldMountDir, true, log)
			if err != nil {
				log.Debug("Error unmounting old mount dir %s: %v", oldMountDir,
					err)
			}

			err = libnativeinstaller.UninstallMountDir(
				context.GetRunMode(), log)
			if err != nil {
				log.Errorf("Error uninstalling mount directory: %s", err)
			}

			err = libnativeinstaller.UninstallRedirector(
				context.GetRunMode(), log)
			if err != nil {
				log.Errorf("Error stopping redirector: %s", err)
			}

			err = libnativeinstaller.UninstallFuse(context.GetRunMode(), log)
			if err != nil {
				log.Errorf("Error uninstalling FUSE: %s", err)
			}
		}
	}

	if !helperCanceled &&
		libkb.IsIn(string(ComponentNameFuse), components, false) {
		err = installFuse(context.GetRunMode(), log)
		componentResults = append(componentResults, componentResult(string(ComponentNameFuse), err))
		if err != nil {
			log.Errorf("Error installing KBFuse: %s", err)
		}
	}

	if !helperCanceled &&
		libkb.IsIn(string(ComponentNameMountDir), components, false) {
		err = libnativeinstaller.InstallMountDir(context.GetRunMode(), log)
		componentResults = append(componentResults, componentResult(string(ComponentNameMountDir), err))
		if err != nil {
			log.Errorf("Error installing mount directory: %s", err)
		}
	}

	if libkb.IsIn(string(ComponentNameKBFS), components, false) {
		err = InstallKBFS(context, binPath, force, true, timeout, log)
		componentResults = append(componentResults, componentResult(string(ComponentNameKBFS), err))
		if err != nil {
			log.Errorf("Error installing KBFS: %s", err)
		}
	}

	if !helperCanceled &&
		libkb.IsIn(string(ComponentNameRedirector), components, false) {
		err = libnativeinstaller.InstallRedirector(context.GetRunMode(), log)
		componentResults = append(componentResults, componentResult(string(ComponentNameRedirector), err))
		if err != nil {
			log.Errorf("Error starting redirector: %s", err)
		}
	}

	if libkb.IsIn(string(ComponentNameKBNM), components, false) {
		err = InstallKBNM(context, binPath, log)
		componentResults = append(componentResults, componentResult(string(ComponentNameKBNM), err))
		if err != nil {
			log.Errorf("Error installing KBNM: %s", err)
		}
	}

	if libkb.IsIn(string(ComponentNameCLIPaths), components, false) {
		err = libnativeinstaller.InstallCommandLinePrivileged(context.GetRunMode(), log)
		componentResults = append(componentResults, componentResult(string(ComponentNameCLIPaths), err))
		if err != nil {
			log.Errorf("Error installing command line (privileged): %s", err)
		}
	}

	return newInstallResult(componentResults)
}
114469
func install(msg proto.Message, cf *ChaincodeCmdFactory) error {
	creator, err := cf.Signer.Serialize()
	if err != nil {
		return fmt.Errorf("Error serializing identity for %s: %s", cf.Signer.GetIdentifier(), err)
	}

	prop, _, err := utils.CreateInstallProposalFromCDS(msg, creator)
	if err != nil {
		return fmt.Errorf("Error creating proposal  %s: %s", chainFuncName, err)
	}

	var signedProp *pb.SignedProposal
	signedProp, err = utils.GetSignedProposal(prop, cf.Signer)
	if err != nil {
		return fmt.Errorf("Error creating signed proposal  %s: %s", chainFuncName, err)
	}

	// install is currently only supported for one peer
	proposalResponse, err := cf.EndorserClients[0].ProcessProposal(context.Background(), signedProp)
	if err != nil {
		return fmt.Errorf("Error endorsing %s: %s", chainFuncName, err)
	}

	if proposalResponse != nil {
		if proposalResponse.Response.Status != int32(pcommon.Status_SUCCESS) {
			return errors.Errorf("Bad response: %d - %s", proposalResponse.Response.Status, proposalResponse.Response.Message)
		}
		logger.Infof("Installed remotely %v", proposalResponse)
	} else {
		return errors.New("Error during install: received nil proposal response")
	}

	return nil
}
1258557
func (s Service) Installed() (bool, error) {
	installed, _, _, err := s.status()
	if err != nil {
		return false, errors.Trace(err)
	}
	return installed, nil
}