MCPcopy Create free account
hub / github.com/Icinga/icinga2 / Program

Class Program

agent/windows-setup-agent/Program.cs:19–108  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17 }
18
19 static class Program
20 {
21 public static string Icinga2InstallDir
22 {
23 get
24 {
25 StringBuilder szProduct;
26
27 for (int index = 0; ; index++) {
28 szProduct = new StringBuilder(39);
29 if (NativeMethods.MsiEnumProducts(index, szProduct) != 0)
30 break;
31
32 int cbName = 128;
33 StringBuilder szName = new StringBuilder(cbName);
34
35 if (NativeMethods.MsiGetProductInfo(szProduct.ToString(), "ProductName", szName, ref cbName) != 0)
36 continue;
37
38 if (szName.ToString() != "Icinga 2")
39 continue;
40
41 int cbLocation = 1024;
42 StringBuilder szLocation = new StringBuilder(cbLocation);
43 if (NativeMethods.MsiGetProductInfo(szProduct.ToString(), "InstallLocation", szLocation, ref cbLocation) == 0)
44 return szLocation.ToString();
45 }
46
47 return "";
48 }
49 }
50
51 public static string Icinga2DataDir
52 {
53 get
54 {
55 return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\icinga2";
56 }
57 }
58
59 public static string Icinga2User
60 {
61 get
62 {
63 if (!File.Exists(Icinga2DataDir + "\\etc\\icinga2\\user"))
64 return "NT AUTHORITY\\NetworkService";
65 System.IO.StreamReader file = new System.IO.StreamReader(Icinga2DataDir + "\\etc\\icinga2\\user");
66 string line = file.ReadLine();
67 file.Close();
68
69 if (line != null)
70 return line;
71 else
72 return "NT AUTHORITY\\NetworkService";
73 }
74 }
75
76

Callers

nothing calls this directly

Calls 6

MsiEnumProductsMethod · 0.80
MsiGetProductInfoMethod · 0.80
ExistsMethod · 0.80
ToStringMethod · 0.45
ReadLineMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected