public KibanaProcess(IEnumerable <string> args) : base(null, null, null) { this.HomeDirectory = (this.HomeDirectory ?? Environment.GetEnvironmentVariable(KibanaEnvironmentVariables.KIBANA_HOME_ENV_VAR, EnvironmentVariableTarget.Machine) ?? Directory.GetParent(".").FullName).TrimEnd('\\'); this.ConfigDirectory = (this.ConfigDirectory ?? Environment.GetEnvironmentVariable(KibanaEnvironmentVariables.KIBANA_CONFIG_ENV_VAR, EnvironmentVariableTarget.Machine) ?? Path.Combine(this.HomeDirectory, "config")).TrimEnd('\\'); this.JsPath = Path.Combine(this.HomeDirectory, @"src\cli"); this.ConfigFile = Path.Combine(this.ConfigDirectory, "kibana.yml"); this.ProcessExe = Path.Combine(this.HomeDirectory, @"node\node.exe"); var yamlConfig = KibanaYamlConfiguration.FromFolder(this.ConfigDirectory); this.LogFile = yamlConfig.Settings.LoggingDestination; var parsedArguments = this.ParseArguments(args); this.Arguments = this.CreateObservableProcessArguments(parsedArguments); }
protected override bool ExecuteTask() { this.Session.SendActionStart(TotalTicks, ActionName, "Configuring Kibana", "Configuring Kibana: [1]"); var locations = this.InstallationModel.LocationsModel; var config = this.InstallationModel.ConfigurationModel; var connecting = this.InstallationModel.ConnectingModel; this.Session.SendProgress(1000, "reading kibana.yml from " + locations.ConfigDirectory); var yaml = KibanaYamlConfiguration.FromFolder(locations.ConfigDirectory, this.FileSystem); this.Session.SendProgress(1000, "updating kibana.yml"); var settings = yaml.Settings; settings.LoggingDestination = locations.LogsFile; settings.ServerHost = config.HostName; settings.ServerPort = config.HttpPort; settings.ServerBasePath = config.BasePath; settings.ServerName = config.ServerName; settings.ServerKey = config.ServerKey; settings.ServerCert = config.ServerCertificate; settings.ServerDefaultRoute = config.DefaultRoute; settings.ElasticsearchUrl = connecting.Url; settings.KibanaIndex = connecting.IndexName; settings.ElasticsearchKey = connecting.ElasticsearchKey; settings.ElasticsearchCert = connecting.ElasticsearchCert; settings.ElasticsearchCA = connecting.ElasticsearchCA; yaml.Save(); // log file needs to exist for plugin installation if (locations.LogsFile != "stdout" && !this.FileSystem.File.Exists(locations.LogsFile)) { var fileInfo = this.FileSystem.FileInfo.FromFileName(locations.LogsFile); fileInfo.Directory.Create(); using (this.FileSystem.File.Create(locations.LogsFile)) { } } this.Session.SendProgress(1000, "kibana.yml updated"); return(true); }
protected override bool ExecuteTask() { if (this.InstallationModel.NoticeModel.AlreadyInstalled && !this.Session.Uninstalling) { return(true); } var configDirectory = this.InstallationModel.LocationsModel.ConfigDirectory; if (!this.FileSystem.Directory.Exists(configDirectory)) { return(true); } this.Session.SendActionStart(1000, ActionName, "Removing data, logs, and config directory", "Removing directories: [1]"); var yamlConfiguration = KibanaYamlConfiguration.FromFolder(configDirectory); var logsDirectory = yamlConfiguration?.Settings?.LoggingDestination ?? string.Empty; if (this.FileSystem.Directory.Exists(logsDirectory)) { this.DeleteDirectory(logsDirectory); } if (this.FileSystem.Directory.Exists(configDirectory)) { this.DeleteDirectory(configDirectory); } this.Session.SendProgress(1000, "Data, logs, and config directories removed"); var installDirectory = this.InstallationModel.LocationsModel.InstallDir; if (!this.FileSystem.Directory.Exists(installDirectory)) { return(true); } var directories = this.FileSystem.Directory.GetDirectories(installDirectory).ToList(); this.Session.SendActionStart((directories.Count * 1000) + 1000, ActionName, "Removing Kibana installation directory", "Removing directories: [1]"); foreach (var directory in directories) { this.Session.Log($"Attemping to delete {directory}"); this.FileSystem.Directory.Delete(directory, true); this.Session.SendProgress(1000, $"{directory} removed"); } if (Empty(installDirectory)) { this.FileSystem.Directory.Delete(installDirectory, true); } if (Empty(LocationsModel.DefaultCompanyDirectory)) { this.FileSystem.Directory.Delete(LocationsModel.DefaultCompanyDirectory, true); } this.Session.SendProgress(1000, "Elasticsearch installation directory removed"); return(true); }