]> granicus.if.org Git - icinga2/blob - agent/windows-setup-agent/Program.cs
a36af0ef928a723a40e82c34c1542bf1711fe252
[icinga2] / agent / windows-setup-agent / Program.cs
1 using System;
2 using System.IO;
3 using System.Windows.Forms;
4 using Microsoft.Win32;
5
6 namespace Icinga
7 {
8         static class Program
9         {
10
11                 public static string Icinga2InstallDir
12                 {
13                         get
14                         {
15                                 RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Icinga Development Team\\ICINGA2");
16
17                                 if (rk == null)
18                                         return "";
19
20                                 return (string)rk.GetValue("");
21                         }
22                 }
23
24                 public static void FatalError(Form owner, string message)
25                 {
26                         MessageBox.Show(owner, message, "Icinga 2 Setup Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error);
27                         Application.Exit();
28                 }
29
30                 /// <summary>
31                 /// The main entry point for the application.
32                 /// </summary>
33                 [STAThread]
34                 static void Main()
35                 {
36                         Application.EnableVisualStyles();
37                         Application.SetCompatibleTextRenderingDefault(false);
38
39                         string installDir = Program.Icinga2InstallDir;
40
41                         if (installDir == "")
42                                 FatalError(null, "Icinga 2 does not seem to be installed properly.");
43
44                         Form form;
45
46                         if (File.Exists(installDir + "\\etc\\icinga2\\features-enabled\\api.conf"))
47                                 form = new ServiceStatus();
48                         else
49                                 form = new SetupWizard();
50
51                         Application.Run(form);
52                 }
53         }
54 }