diff --git a/agent/windows-setup-agent/Program.cs b/agent/windows-setup-agent/Program.cs index 3dcd3de75..e132bc1b1 100644 --- a/agent/windows-setup-agent/Program.cs +++ b/agent/windows-setup-agent/Program.cs @@ -45,7 +45,16 @@ namespace Icinga } } - public static void FatalError(Form owner, string message) + public static string Icinga2DataDir + { + get + { + return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2"; + } + } + + + public static void FatalError(Form owner, string message) { MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); @@ -69,7 +78,7 @@ namespace Icinga Form form; - if (File.Exists(installDir + "\\etc\\icinga2\\features-enabled\\api.conf")) + if (File.Exists(Program.Icinga2DataDir + "\\etc\\icinga2\\features-enabled\\api.conf")) form = new ServiceStatus(); else form = new SetupWizard(); diff --git a/agent/windows-setup-agent/SetupWizard.cs b/agent/windows-setup-agent/SetupWizard.cs index 6bc13c7ff..ada117674 100644 --- a/agent/windows-setup-agent/SetupWizard.cs +++ b/agent/windows-setup-agent/SetupWizard.cs @@ -65,7 +65,7 @@ namespace Icinga { FileStream fp = null; try { - fp = File.Open(Program.Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create); + fp = File.Open(Program.Icinga2DataDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create); using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) { fp = null; sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature)); @@ -144,8 +144,7 @@ namespace Icinga { SetRetrievalStatus(25); - string pathPrefix = Program.Icinga2InstallDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text; - + string pathPrefix = Program.Icinga2DataDir + "\\etc\\icinga2\\pki\\" + txtInstanceName.Text; string output; if (!File.Exists(pathPrefix + ".crt")) { @@ -355,8 +354,8 @@ namespace Icinga thread.Start(); } - /*if (tbcPages.SelectedTab == tabParameters && - !File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) { + /*if (tbcPages.SelectedTab == tabParameters && + !File.Exists(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) { byte[] bytes = Convert.FromBase64String(txtBundle.Text); MemoryStream ms = new MemoryStream(bytes); GZipStream gz = new GZipStream(ms, CompressionMode.Decompress); @@ -368,10 +367,10 @@ namespace Icinga ms2.Write(buffer, 0, rc); ms2.Position = 0; TarReader tr = new TarReader(ms2); - tr.ReadToEnd(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent"); + tr.ReadToEnd(Icinga2DataDir + "\\etc\\icinga2\\pki\\agent"); }*/ - if (tbcPages.SelectedTab == tabConfigure) { + if (tbcPages.SelectedTab == tabConfigure) { Thread thread = new Thread(ConfigureService); thread.Start(); }