mirror of https://github.com/Icinga/icinga2.git
parent
6bf3225e84
commit
14db2f04a8
|
@ -328,6 +328,7 @@ set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "nsExec::Exec '\\\"$INSTDIR\\\\sbin\\\\i
|
|||
set(CPACK_WIX_PRODUCT_ICON "${CMAKE_CURRENT_SOURCE_DIR}/icinga-app\\\\icinga.ico")
|
||||
set(CPACK_WIX_UPGRADE_GUID "52F2BEAA-4DF0-4C3E-ABDC-C0F61DE4DF8A")
|
||||
set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/icinga2.wixpatch")
|
||||
set(CPACK_WIX_EXTENSIONS "WixUtilExtension")
|
||||
|
||||
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP TRUE)
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
|
|
@ -22,15 +22,54 @@
|
|||
|
||||
using namespace icinga;
|
||||
|
||||
int InstallIcinga(void)
|
||||
static String GetIcingaInstallDir(void)
|
||||
{
|
||||
MessageBox(NULL, "Install", "Icinga 2", 0);
|
||||
char szFileName[MAX_PATH];
|
||||
if (!GetModuleFileName(NULL, szFileName, sizeof(szFileName)))
|
||||
return "";
|
||||
return Utility::DirName(Utility::DirName(szFileName));
|
||||
}
|
||||
|
||||
static void ExecuteCommand(const String& command)
|
||||
{
|
||||
std::cerr << "Executing command: " << command << std::endl;
|
||||
system(command.CStr());
|
||||
}
|
||||
|
||||
static void ExecuteIcingaCommand(const String& args)
|
||||
{
|
||||
ExecuteCommand("\"" + GetIcingaInstallDir() + "\\sbin\\icinga2.exe\" " + args);
|
||||
}
|
||||
|
||||
static int InstallIcinga(void)
|
||||
{
|
||||
String installDir = GetIcingaInstallDir();
|
||||
|
||||
ExecuteCommand("icacls \"" + installDir + "\" /grant *S-1-5-20:(oi)(ci)m");
|
||||
ExecuteCommand("icacls \"" + installDir + "\\etc\" /inheritance:r /grant:r *S-1-5-20:(oi)(ci)m *S-1-5-32-544:(oi)(ci)f");
|
||||
|
||||
Utility::MkDirP(installDir + "/etc/icinga2/pki", 0700);
|
||||
Utility::MkDirP(installDir + "/var/cache/icinga2", 0700);
|
||||
Utility::MkDirP(installDir + "/var/lib/icinga2/pki", 0700);
|
||||
Utility::MkDirP(installDir + "/var/lib/icinga2/agent/inventory", 0700);
|
||||
Utility::MkDirP(installDir + "/var/lib/icinga2/api/config", 0700);
|
||||
Utility::MkDirP(installDir + "/var/lib/icinga2/api/log", 0700);
|
||||
Utility::MkDirP(installDir + "/var/lib/icinga2/api/zones", 0700);
|
||||
Utility::MkDirP(installDir + "/var/lib/icinga2/api/zones", 0700);
|
||||
Utility::MkDirP(installDir + "/var/log/icinga2/compat/archive", 0700);
|
||||
Utility::MkDirP(installDir + "/var/log/icinga2/crash", 0700);
|
||||
Utility::MkDirP(installDir + "/var/spool/icinga2/perfdata", 0700);
|
||||
Utility::MkDirP(installDir + "/var/spool/icinga2/tmp", 0700);
|
||||
|
||||
ExecuteIcingaCommand("--scm-install daemon");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int UninstallIcinga(void)
|
||||
static int UninstallIcinga(void)
|
||||
{
|
||||
MessageBox(NULL, "Uninstall", "Icinga 2", 0);
|
||||
ExecuteIcingaCommand("--scm-uninstall");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -42,6 +81,8 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
/* must be called before using any other libbase functions */
|
||||
Application::InitializeBase();
|
||||
|
||||
//AllocConsole();
|
||||
|
||||
int rc;
|
||||
|
||||
if (strcmp(lpCmdLine, "install") == 0) {
|
||||
|
@ -53,5 +94,7 @@ int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
rc = 1;
|
||||
}
|
||||
|
||||
//Utility::Sleep(3);
|
||||
|
||||
Application::Exit(rc);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,28 @@
|
|||
<CPackWiXPatch>
|
||||
<CPackWiXFragment Id="#PRODUCT">
|
||||
<Property Id="ALLUSERS">1</Property>
|
||||
|
||||
<CustomAction Id="XtraInstall" FileKey="CM_FP_sbin.icinga2_installer.exe" ExeCommand="install" Execute="deferred" Impersonate="no" />
|
||||
<CustomAction Id="XtraUninstall" FileKey="CM_FP_sbin.icinga2_installer.exe" ExeCommand="uninstall" Execute="deferred" Impersonate="no" />
|
||||
|
||||
<InstallExecuteSequence>
|
||||
<Custom Action="XtraInstall" Before="InstallFinalize">$CM_CP_sbin.icinga2_installer.exe>2</Custom>
|
||||
<Custom Action="XtraUninstall" After="InstallInitialize">$CM_CP_sbin.icinga2_installer.exe=2</Custom>
|
||||
<Custom Action="XtraUninstall" Before="RemoveExistingProducts">$CM_CP_sbin.icinga2_installer.exe=2</Custom>
|
||||
</InstallExecuteSequence>
|
||||
|
||||
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Run Icinga 2 setup wizard" />
|
||||
|
||||
<Property Id="WixShellExecTarget" Value="[#CM_FP_sbin.Icinga2SetupAgent.exe]" />
|
||||
<CustomAction Id="LaunchIcinga2Wizard"
|
||||
BinaryKey="WixCA"
|
||||
DllEntry="WixShellExec"
|
||||
Impersonate="no" />
|
||||
|
||||
<UI>
|
||||
<Publish Dialog="ExitDialog"
|
||||
Control="Finish"
|
||||
Event="DoAction"
|
||||
Value="LaunchIcinga2Wizard">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
|
||||
</UI>
|
||||
</CPackWiXFragment>
|
||||
</CPackWiXPatch>
|
Loading…
Reference in New Issue