mirror of https://github.com/Icinga/icinga2.git
Make sure the etc and var directories are in the common data directory
refs #11449
This commit is contained in:
parent
e1373386fa
commit
6e2e90cc62
|
@ -28,82 +28,95 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServiceStatus));
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ServiceStatus));
|
||||||
this.picBanner = new System.Windows.Forms.PictureBox();
|
this.picBanner = new System.Windows.Forms.PictureBox();
|
||||||
this.lblStatus = new System.Windows.Forms.Label();
|
this.lblStatus = new System.Windows.Forms.Label();
|
||||||
this.txtStatus = new System.Windows.Forms.TextBox();
|
this.txtStatus = new System.Windows.Forms.TextBox();
|
||||||
this.btnReconfigure = new System.Windows.Forms.Button();
|
this.btnReconfigure = new System.Windows.Forms.Button();
|
||||||
this.btnOK = new System.Windows.Forms.Button();
|
this.btnOK = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit();
|
this.btnOpenConfigDir = new System.Windows.Forms.Button();
|
||||||
this.SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit();
|
||||||
//
|
this.SuspendLayout();
|
||||||
// picBanner
|
//
|
||||||
//
|
// picBanner
|
||||||
this.picBanner.Image = global::Icinga.Properties.Resources.icinga_banner;
|
//
|
||||||
this.picBanner.Location = new System.Drawing.Point(0, 0);
|
this.picBanner.Image = global::Icinga.Properties.Resources.icinga_banner;
|
||||||
this.picBanner.Name = "picBanner";
|
this.picBanner.Location = new System.Drawing.Point(0, 0);
|
||||||
this.picBanner.Size = new System.Drawing.Size(625, 77);
|
this.picBanner.Name = "picBanner";
|
||||||
this.picBanner.TabIndex = 2;
|
this.picBanner.Size = new System.Drawing.Size(625, 77);
|
||||||
this.picBanner.TabStop = false;
|
this.picBanner.TabIndex = 2;
|
||||||
//
|
this.picBanner.TabStop = false;
|
||||||
// lblStatus
|
//
|
||||||
//
|
// lblStatus
|
||||||
this.lblStatus.AutoSize = true;
|
//
|
||||||
this.lblStatus.Location = new System.Drawing.Point(12, 105);
|
this.lblStatus.AutoSize = true;
|
||||||
this.lblStatus.Name = "lblStatus";
|
this.lblStatus.Location = new System.Drawing.Point(12, 105);
|
||||||
this.lblStatus.Size = new System.Drawing.Size(79, 13);
|
this.lblStatus.Name = "lblStatus";
|
||||||
this.lblStatus.TabIndex = 3;
|
this.lblStatus.Size = new System.Drawing.Size(79, 13);
|
||||||
this.lblStatus.Text = "Service Status:";
|
this.lblStatus.TabIndex = 3;
|
||||||
//
|
this.lblStatus.Text = "Service Status:";
|
||||||
// txtStatus
|
//
|
||||||
//
|
// txtStatus
|
||||||
this.txtStatus.Location = new System.Drawing.Point(97, 102);
|
//
|
||||||
this.txtStatus.Name = "txtStatus";
|
this.txtStatus.Location = new System.Drawing.Point(97, 102);
|
||||||
this.txtStatus.ReadOnly = true;
|
this.txtStatus.Name = "txtStatus";
|
||||||
this.txtStatus.Size = new System.Drawing.Size(278, 20);
|
this.txtStatus.ReadOnly = true;
|
||||||
this.txtStatus.TabIndex = 2;
|
this.txtStatus.Size = new System.Drawing.Size(278, 20);
|
||||||
//
|
this.txtStatus.TabIndex = 3;
|
||||||
// btnReconfigure
|
//
|
||||||
//
|
// btnReconfigure
|
||||||
this.btnReconfigure.Location = new System.Drawing.Point(219, 143);
|
//
|
||||||
this.btnReconfigure.Name = "btnReconfigure";
|
this.btnReconfigure.Location = new System.Drawing.Point(195, 143);
|
||||||
this.btnReconfigure.Size = new System.Drawing.Size(75, 23);
|
this.btnReconfigure.Name = "btnReconfigure";
|
||||||
this.btnReconfigure.TabIndex = 1;
|
this.btnReconfigure.Size = new System.Drawing.Size(89, 23);
|
||||||
this.btnReconfigure.Text = "Reconfigure";
|
this.btnReconfigure.TabIndex = 1;
|
||||||
this.btnReconfigure.UseVisualStyleBackColor = true;
|
this.btnReconfigure.Text = "Reconfigure";
|
||||||
this.btnReconfigure.Click += new System.EventHandler(this.btnReconfigure_Click);
|
this.btnReconfigure.UseVisualStyleBackColor = true;
|
||||||
//
|
this.btnReconfigure.Click += new System.EventHandler(this.btnReconfigure_Click);
|
||||||
// btnOK
|
//
|
||||||
//
|
// btnOK
|
||||||
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
//
|
||||||
this.btnOK.Location = new System.Drawing.Point(300, 143);
|
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
this.btnOK.Name = "btnOK";
|
this.btnOK.Location = new System.Drawing.Point(290, 143);
|
||||||
this.btnOK.Size = new System.Drawing.Size(75, 23);
|
this.btnOK.Name = "btnOK";
|
||||||
this.btnOK.TabIndex = 0;
|
this.btnOK.Size = new System.Drawing.Size(89, 23);
|
||||||
this.btnOK.Text = "OK";
|
this.btnOK.TabIndex = 0;
|
||||||
this.btnOK.UseVisualStyleBackColor = true;
|
this.btnOK.Text = "OK";
|
||||||
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
this.btnOK.UseVisualStyleBackColor = true;
|
||||||
//
|
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
|
||||||
// ServiceStatus
|
//
|
||||||
//
|
// btnOpenConfigDir
|
||||||
this.AcceptButton = this.btnOK;
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.btnOpenConfigDir.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.btnOpenConfigDir.Location = new System.Drawing.Point(100, 143);
|
||||||
this.CancelButton = this.btnOK;
|
this.btnOpenConfigDir.Name = "btnOpenConfigDir";
|
||||||
this.ClientSize = new System.Drawing.Size(391, 186);
|
this.btnOpenConfigDir.Size = new System.Drawing.Size(89, 23);
|
||||||
this.Controls.Add(this.btnOK);
|
this.btnOpenConfigDir.TabIndex = 2;
|
||||||
this.Controls.Add(this.btnReconfigure);
|
this.btnOpenConfigDir.Text = "Examine Config";
|
||||||
this.Controls.Add(this.txtStatus);
|
this.btnOpenConfigDir.UseVisualStyleBackColor = true;
|
||||||
this.Controls.Add(this.lblStatus);
|
this.btnOpenConfigDir.Click += new System.EventHandler(this.btnOpenConfigDir_Click);
|
||||||
this.Controls.Add(this.picBanner);
|
//
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
// ServiceStatus
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
//
|
||||||
this.MaximizeBox = false;
|
this.AcceptButton = this.btnOK;
|
||||||
this.Name = "ServiceStatus";
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.Text = "Icinga 2 Service Status";
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
|
this.CancelButton = this.btnOK;
|
||||||
this.ResumeLayout(false);
|
this.ClientSize = new System.Drawing.Size(391, 186);
|
||||||
this.PerformLayout();
|
this.Controls.Add(this.btnOpenConfigDir);
|
||||||
|
this.Controls.Add(this.btnOK);
|
||||||
|
this.Controls.Add(this.btnReconfigure);
|
||||||
|
this.Controls.Add(this.txtStatus);
|
||||||
|
this.Controls.Add(this.lblStatus);
|
||||||
|
this.Controls.Add(this.picBanner);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.Name = "ServiceStatus";
|
||||||
|
this.Text = "Icinga 2 Service Status";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,5 +127,6 @@
|
||||||
private System.Windows.Forms.TextBox txtStatus;
|
private System.Windows.Forms.TextBox txtStatus;
|
||||||
private System.Windows.Forms.Button btnReconfigure;
|
private System.Windows.Forms.Button btnReconfigure;
|
||||||
private System.Windows.Forms.Button btnOK;
|
private System.Windows.Forms.Button btnOK;
|
||||||
}
|
private System.Windows.Forms.Button btnOpenConfigDir;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -6,6 +6,7 @@ using System.Drawing;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.ServiceProcess;
|
using System.ServiceProcess;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Icinga
|
namespace Icinga
|
||||||
{
|
{
|
||||||
|
@ -33,5 +34,9 @@ namespace Icinga
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void btnOpenConfigDir_Click(object sender, EventArgs e) {
|
||||||
|
Process.Start("explorer.exe", Program.Icinga2DataDir + "\\etc\\icinga2");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "base/utility.hpp"
|
#include "base/utility.hpp"
|
||||||
#include "base/application.hpp"
|
#include "base/application.hpp"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
#include <shellapi.h>
|
#include <shellapi.h>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
@ -48,7 +49,7 @@ static bool ExecuteCommand(const String& app, const String& arguments)
|
||||||
WaitForSingleObject(sei.hProcess, INFINITE);
|
WaitForSingleObject(sei.hProcess, INFINITE);
|
||||||
|
|
||||||
DWORD exitCode;
|
DWORD exitCode;
|
||||||
bool res = GetExitCodeProcess(sei.hProcess, &exitCode);
|
BOOL res = GetExitCodeProcess(sei.hProcess, &exitCode);
|
||||||
CloseHandle(sei.hProcess);
|
CloseHandle(sei.hProcess);
|
||||||
|
|
||||||
if (!res)
|
if (!res)
|
||||||
|
@ -94,6 +95,41 @@ static String GetNSISInstallPath(void)
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void CollectPaths(std::vector<String>& paths, const String& path)
|
||||||
|
{
|
||||||
|
paths.push_back(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool MoveDirectory(const String& source, const String& destination)
|
||||||
|
{
|
||||||
|
if (!MoveFileEx(source.CStr(), destination.CStr(), MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH)) {
|
||||||
|
// SHFileOperation requires file names to be terminated with two \0s
|
||||||
|
String tmpSource = source + String(1, '\0');
|
||||||
|
String tmpDestination = destination + String(1, '\0');
|
||||||
|
|
||||||
|
SHFILEOPSTRUCT fop;
|
||||||
|
fop.wFunc = FO_COPY;
|
||||||
|
fop.pFrom = tmpSource.CStr();
|
||||||
|
fop.pTo = tmpDestination.CStr();
|
||||||
|
fop.fFlags = FOF_NO_UI;
|
||||||
|
if (SHFileOperation(&fop) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
std::vector<String> paths;
|
||||||
|
paths.push_back(source);
|
||||||
|
Utility::GlobRecursive(source, "*", boost::bind(&CollectPaths, boost::ref(paths), _1), GlobDirectory);
|
||||||
|
Utility::GlobRecursive(source, "*", boost::bind(&CollectPaths, boost::ref(paths), _1), GlobFile);
|
||||||
|
|
||||||
|
std::reverse(paths.begin(), paths.end());
|
||||||
|
|
||||||
|
BOOST_FOREACH(const String& path, paths) {
|
||||||
|
(void)MoveFileEx(path.CStr(), NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int UpgradeNSIS(void)
|
static int UpgradeNSIS(void)
|
||||||
{
|
{
|
||||||
String installPath = GetNSISInstallPath();
|
String installPath = GetNSISInstallPath();
|
||||||
|
@ -108,15 +144,28 @@ static int UpgradeNSIS(void)
|
||||||
|
|
||||||
String dataPath = Utility::GetIcingaDataPath();
|
String dataPath = Utility::GetIcingaDataPath();
|
||||||
|
|
||||||
if (!Utility::PathExists(dataPath))
|
/* perform open heart surgery on the user's data dirs - yay */
|
||||||
CreateSymbolicLink(dataPath.CStr(), installPath.CStr(), SYMBOLIC_LINK_FLAG_DIRECTORY);
|
if (!Utility::PathExists(dataPath)) {
|
||||||
|
Utility::MkDirP(dataPath, 0700);
|
||||||
|
|
||||||
|
String oldNameEtc = installPath + "\\etc";
|
||||||
|
String newNameEtc = dataPath + "\\etc";
|
||||||
|
if (!MoveDirectory(oldNameEtc, newNameEtc))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
String oldNameVar = installPath + "\\var";
|
||||||
|
String newNameVar = dataPath + "\\var";
|
||||||
|
if (!MoveDirectory(oldNameVar, newNameVar))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int InstallIcinga(void)
|
static int InstallIcinga(void)
|
||||||
{
|
{
|
||||||
UpgradeNSIS();
|
if (UpgradeNSIS() != 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
String installDir = GetIcingaInstallPath();
|
String installDir = GetIcingaInstallPath();
|
||||||
String dataDir = Utility::GetIcingaDataPath();
|
String dataDir = Utility::GetIcingaDataPath();
|
||||||
|
|
Loading…
Reference in New Issue