mirror of https://github.com/Icinga/icinga2.git
parent
088b15e964
commit
ad894c367a
|
@ -146,6 +146,7 @@ set(CPACK_SOURCE_IGNORE_FILES "/.git/" "/debian/" "/.vagrant/" "/release/" "/deb
|
|||
set(CPACK_NSIS_EXECUTABLES_DIRECTORY "sbin")
|
||||
set(CPACK_PACKAGE_EXECUTABLES "Icinga2SetupAgent;Icinga 2 Agent Wizard")
|
||||
set(CPACK_NSIS_MUI_FINISHPAGE_RUN "Icinga2SetupAgent")
|
||||
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "nsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\icinga2\\\" --scm-uninstall'")
|
||||
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
|
|
@ -471,9 +471,12 @@ static int SetupService(bool install, int argc, char **argv)
|
|||
for (int i = 0; i < argc; i++)
|
||||
szArgs += " " + Utility::EscapeShellArg(argv[i]);
|
||||
|
||||
SC_HANDLE schService = OpenService(schSCManager, "icinga2", DELETE);
|
||||
SC_HANDLE schService = OpenService(schSCManager, "icinga2", DELETE | SERVICE_STOP);
|
||||
|
||||
if (schService != NULL) {
|
||||
SERVICE_STATUS status;
|
||||
ControlService(schService, SERVICE_CONTROL_STOP, &status);
|
||||
|
||||
if (!DeleteService(schService)) {
|
||||
printf("DeleteService failed (%d)\n", GetLastError());
|
||||
CloseServiceHandle(schService);
|
||||
|
@ -513,6 +516,13 @@ static int SetupService(bool install, int argc, char **argv)
|
|||
SERVICE_DESCRIPTION sdDescription = { "The Icinga 2 monitoring application" };
|
||||
ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &sdDescription);
|
||||
|
||||
if (!StartService(schService, 0, NULL)) {
|
||||
printf("StartService failed (%d)\n", GetLastError());
|
||||
CloseServiceHandle(schService);
|
||||
CloseServiceHandle(schSCManager);
|
||||
return 1;
|
||||
}
|
||||
|
||||
CloseServiceHandle(schService);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ namespace Icinga
|
|||
EnableFeature("agent");
|
||||
EnableFeature("checker");
|
||||
|
||||
SetConfigureStatus(10, "Setting ACLs for the Icinga 2 directory...");
|
||||
SetConfigureStatus(50, "Setting ACLs for the Icinga 2 directory...");
|
||||
DirectoryInfo di = new DirectoryInfo(Icinga2InstallDir);
|
||||
DirectorySecurity ds = di.GetAccessControl();
|
||||
FileSystemAccessRule rule = new FileSystemAccessRule("NT AUTHORITY\\NetworkService",
|
||||
|
@ -166,16 +166,7 @@ namespace Icinga
|
|||
ds.AddAccessRule(rule);
|
||||
di.SetAccessControl(ds);
|
||||
|
||||
// TODO: Update config
|
||||
SetConfigureStatus(25, "Stopping the Icinga 2 service...");
|
||||
try {
|
||||
using (ServiceController sc = new ServiceController("icinga2")) {
|
||||
sc.Stop();
|
||||
sc.WaitForStatus(ServiceControllerStatus.Stopped);
|
||||
}
|
||||
} catch (Exception) { }
|
||||
|
||||
SetConfigureStatus(50, "Installing the Icinga 2 service...");
|
||||
SetConfigureStatus(75, "Installing the Icinga 2 service...");
|
||||
ProcessStartInfo psi = new ProcessStartInfo();
|
||||
psi.FileName = Icinga2InstallDir + "\\sbin\\icinga2.exe";
|
||||
psi.Arguments = "--scm-install -c \"" + Icinga2InstallDir + "\\etc\\icinga2\\icinga2.conf\"";
|
||||
|
@ -189,16 +180,6 @@ namespace Icinga
|
|||
FatalError("The Windows service could not be installed.");
|
||||
}
|
||||
|
||||
SetConfigureStatus(75, "Starting the Icinga 2 service...");
|
||||
try {
|
||||
using (ServiceController sc = new ServiceController("icinga2")) {
|
||||
sc.Start();
|
||||
sc.WaitForStatus(ServiceControllerStatus.Running);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
FatalError("Could not start the Icinga 2 service: " + ex.Message);
|
||||
}
|
||||
|
||||
SetConfigureStatus(100, "Finished.");
|
||||
|
||||
FinishConfigure();
|
||||
|
|
Loading…
Reference in New Issue