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

Function InstallIcinga

icinga-installer/icinga-installer.cpp:214–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214static int InstallIcinga(void)
215{
216 std::string installDir = GetIcingaInstallPath();
217 std::string skelDir = installDir + "\\share\\skel";
218 std::string dataDir = GetIcingaDataPath();
219
220 if (!PathExists(dataDir)) {
221 std::string sourceDir = skelDir + std::string(1, '\0');
222 std::string destinationDir = dataDir + std::string(1, '\0');
223
224 SHFILEOPSTRUCT fop;
225 fop.wFunc = FO_COPY;
226 fop.pFrom = sourceDir.c_str();
227 fop.pTo = destinationDir.c_str();
228 fop.fFlags = FOF_NO_UI | FOF_NOCOPYSECURITYATTRIBS;
229
230 if (SHFileOperation(&fop) != 0)
231 return 1;
232
233 MkDirP(dataDir + "/etc/icinga2/pki");
234 MkDirP(dataDir + "/var/cache/icinga2");
235 MkDirP(dataDir + "/var/lib/icinga2/certs");
236 MkDirP(dataDir + "/var/lib/icinga2/certificate-requests");
237 MkDirP(dataDir + "/var/lib/icinga2/agent/inventory");
238 MkDirP(dataDir + "/var/lib/icinga2/api/config");
239 MkDirP(dataDir + "/var/lib/icinga2/api/log");
240 MkDirP(dataDir + "/var/lib/icinga2/api/zones");
241 MkDirP(dataDir + "/var/log/icinga2/compat/archive");
242 MkDirP(dataDir + "/var/log/icinga2/crash");
243 MkDirP(dataDir + "/var/run/icinga2/cmd");
244 MkDirP(dataDir + "/var/spool/icinga2/perfdata");
245 MkDirP(dataDir + "/var/spool/icinga2/tmp");
246 }
247
248 // Upgrade from versions older than 2.13 by making the windowseventlog feature available,
249 // enable it by default and disable the old mainlog feature.
250 if (!PathExists(dataDir + "/etc/icinga2/features-available/windowseventlog.conf")) {
251 // Disable the old mainlog feature as it is replaced by windowseventlog by default.
252 std::string mainlogEnabledFile = dataDir + "/etc/icinga2/features-enabled/mainlog.conf";
253 if (PathExists(mainlogEnabledFile)) {
254 if (DeleteFileA(mainlogEnabledFile.c_str()) == 0) {
255 throw std::runtime_error("deleting '" + mainlogEnabledFile + "' failed");
256 }
257 }
258
259 // Install the new windowseventlog feature. As features-available/windowseventlog.conf is used as a marker file,
260 // copy it as the last step, so that this is run again should the upgrade be interrupted.
261 for (const std::string& d : {"features-enabled", "features-available"}) {
262 std::string sourceFile = skelDir + "/etc/icinga2/" + d + "/windowseventlog.conf";
263 std::string destinationFile = dataDir + "/etc/icinga2/" + d + "/windowseventlog.conf";
264
265 if (CopyFileA(sourceFile.c_str(), destinationFile.c_str(), false) == 0) {
266 throw std::runtime_error("copying '" + sourceFile + "' to '" + destinationFile + "' failed");
267 }
268 }
269 }
270
271 // TODO: In Icinga 2.14, rename features-available/mainlog.conf to mainlog.conf.deprecated

Callers 1

WinMainFunction · 0.85

Calls 6

GetIcingaInstallPathFunction · 0.85
GetIcingaDataPathFunction · 0.85
PathExistsFunction · 0.85
MkDirPFunction · 0.85
ExecuteCommandFunction · 0.85
ExecuteIcingaCommandFunction · 0.85

Tested by

no test coverage detected