mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-24 14:14:45 +02:00
parent
0fb55f3404
commit
e19948fc95
@ -788,7 +788,7 @@ String Utility::EscapeShellArg(const String& s)
|
||||
result += ' ';
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
if (ch == '\') {
|
||||
if (ch == '\'')
|
||||
result += "'\\'";
|
||||
#endif
|
||||
result += ch;
|
||||
|
@ -39,3 +39,12 @@ if(UNIX OR CYGWIN)
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
include_external_msproject(icinga2setupagent ${CMAKE_CURRENT_SOURCE_DIR}/icinga2-setup-agent/Icinga2SetupAgent.csproj)
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/icinga2-setup-agent/bin/${CMAKE_BUILD_TYPE}/Icinga2SetupAgent.exe
|
||||
DESTINATION ${CMAKE_INSTALL_SBINDIR}
|
||||
)
|
||||
endif()
|
2
tools/icinga2-setup-agent/.gitignore
vendored
Normal file
2
tools/icinga2-setup-agent/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
bin
|
||||
obj
|
582
tools/icinga2-setup-agent/AgentWizard.Designer.cs
generated
Normal file
582
tools/icinga2-setup-agent/AgentWizard.Designer.cs
generated
Normal file
@ -0,0 +1,582 @@
|
||||
namespace Icinga
|
||||
{
|
||||
partial class AgentWizard
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AgentWizard));
|
||||
this.tbcPages = new System.Windows.Forms.TabControl();
|
||||
this.tabAgentKey = new System.Windows.Forms.TabPage();
|
||||
this.lblHostKey = new System.Windows.Forms.Label();
|
||||
this.prgHostKey = new System.Windows.Forms.ProgressBar();
|
||||
this.tabCSR = new System.Windows.Forms.TabPage();
|
||||
this.txtCSR = new System.Windows.Forms.TextBox();
|
||||
this.lblCSRPrompt = new System.Windows.Forms.Label();
|
||||
this.tabCertificateBundle = new System.Windows.Forms.TabPage();
|
||||
this.txtBundle = new System.Windows.Forms.TextBox();
|
||||
this.lblBundlePrompt = new System.Windows.Forms.Label();
|
||||
this.tabParameters = new System.Windows.Forms.TabPage();
|
||||
this.txtInstanceName = new System.Windows.Forms.TextBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.groupBox3 = new System.Windows.Forms.GroupBox();
|
||||
this.rdoNoConnect = new System.Windows.Forms.RadioButton();
|
||||
this.txtPeerPort = new System.Windows.Forms.TextBox();
|
||||
this.lblPeerPort = new System.Windows.Forms.Label();
|
||||
this.txtPeerHost = new System.Windows.Forms.TextBox();
|
||||
this.lblPeerHost = new System.Windows.Forms.Label();
|
||||
this.rdoConnect = new System.Windows.Forms.RadioButton();
|
||||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||||
this.rdoNoListener = new System.Windows.Forms.RadioButton();
|
||||
this.txtListenerPort = new System.Windows.Forms.TextBox();
|
||||
this.lblListenerPort = new System.Windows.Forms.Label();
|
||||
this.rdoListener = new System.Windows.Forms.RadioButton();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.txtMasterInstance = new System.Windows.Forms.TextBox();
|
||||
this.lblMasterInstance = new System.Windows.Forms.Label();
|
||||
this.rdoNoMaster = new System.Windows.Forms.RadioButton();
|
||||
this.rdoNewMaster = new System.Windows.Forms.RadioButton();
|
||||
this.picBanner = new System.Windows.Forms.PictureBox();
|
||||
this.btnBack = new System.Windows.Forms.Button();
|
||||
this.btnNext = new System.Windows.Forms.Button();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.tabConfigure = new System.Windows.Forms.TabPage();
|
||||
this.prgConfig = new System.Windows.Forms.ProgressBar();
|
||||
this.lblConfigStatus = new System.Windows.Forms.Label();
|
||||
this.tabFinish = new System.Windows.Forms.TabPage();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tbcPages.SuspendLayout();
|
||||
this.tabAgentKey.SuspendLayout();
|
||||
this.tabCSR.SuspendLayout();
|
||||
this.tabCertificateBundle.SuspendLayout();
|
||||
this.tabParameters.SuspendLayout();
|
||||
this.groupBox3.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picBanner)).BeginInit();
|
||||
this.tabConfigure.SuspendLayout();
|
||||
this.tabFinish.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tbcPages
|
||||
//
|
||||
this.tbcPages.Appearance = System.Windows.Forms.TabAppearance.FlatButtons;
|
||||
this.tbcPages.Controls.Add(this.tabAgentKey);
|
||||
this.tbcPages.Controls.Add(this.tabCSR);
|
||||
this.tbcPages.Controls.Add(this.tabCertificateBundle);
|
||||
this.tbcPages.Controls.Add(this.tabParameters);
|
||||
this.tbcPages.Controls.Add(this.tabConfigure);
|
||||
this.tbcPages.Controls.Add(this.tabFinish);
|
||||
this.tbcPages.ItemSize = new System.Drawing.Size(0, 1);
|
||||
this.tbcPages.Location = new System.Drawing.Point(0, 80);
|
||||
this.tbcPages.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tbcPages.Name = "tbcPages";
|
||||
this.tbcPages.SelectedIndex = 0;
|
||||
this.tbcPages.Size = new System.Drawing.Size(625, 509);
|
||||
this.tbcPages.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
|
||||
this.tbcPages.TabIndex = 0;
|
||||
this.tbcPages.SelectedIndexChanged += new System.EventHandler(this.tbcPages_SelectedIndexChanged);
|
||||
//
|
||||
// tabAgentKey
|
||||
//
|
||||
this.tabAgentKey.Controls.Add(this.lblHostKey);
|
||||
this.tabAgentKey.Controls.Add(this.prgHostKey);
|
||||
this.tabAgentKey.Location = new System.Drawing.Point(4, 5);
|
||||
this.tabAgentKey.Name = "tabAgentKey";
|
||||
this.tabAgentKey.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabAgentKey.Size = new System.Drawing.Size(617, 500);
|
||||
this.tabAgentKey.TabIndex = 0;
|
||||
this.tabAgentKey.Text = "Agent Key";
|
||||
this.tabAgentKey.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblHostKey
|
||||
//
|
||||
this.lblHostKey.AutoSize = true;
|
||||
this.lblHostKey.Location = new System.Drawing.Point(118, 222);
|
||||
this.lblHostKey.Name = "lblHostKey";
|
||||
this.lblHostKey.Size = new System.Drawing.Size(197, 13);
|
||||
this.lblHostKey.TabIndex = 1;
|
||||
this.lblHostKey.Text = "Generating a host key for this machine...";
|
||||
//
|
||||
// prgHostKey
|
||||
//
|
||||
this.prgHostKey.Location = new System.Drawing.Point(118, 254);
|
||||
this.prgHostKey.Name = "prgHostKey";
|
||||
this.prgHostKey.Size = new System.Drawing.Size(369, 23);
|
||||
this.prgHostKey.Style = System.Windows.Forms.ProgressBarStyle.Marquee;
|
||||
this.prgHostKey.TabIndex = 0;
|
||||
//
|
||||
// tabCSR
|
||||
//
|
||||
this.tabCSR.Controls.Add(this.txtCSR);
|
||||
this.tabCSR.Controls.Add(this.lblCSRPrompt);
|
||||
this.tabCSR.Location = new System.Drawing.Point(4, 5);
|
||||
this.tabCSR.Name = "tabCSR";
|
||||
this.tabCSR.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabCSR.Size = new System.Drawing.Size(617, 500);
|
||||
this.tabCSR.TabIndex = 1;
|
||||
this.tabCSR.Text = "Certificate Signing Request";
|
||||
this.tabCSR.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// txtCSR
|
||||
//
|
||||
this.txtCSR.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtCSR.Location = new System.Drawing.Point(24, 42);
|
||||
this.txtCSR.Multiline = true;
|
||||
this.txtCSR.Name = "txtCSR";
|
||||
this.txtCSR.ReadOnly = true;
|
||||
this.txtCSR.Size = new System.Drawing.Size(564, 452);
|
||||
this.txtCSR.TabIndex = 1;
|
||||
//
|
||||
// lblCSRPrompt
|
||||
//
|
||||
this.lblCSRPrompt.AutoSize = true;
|
||||
this.lblCSRPrompt.Location = new System.Drawing.Point(21, 15);
|
||||
this.lblCSRPrompt.Name = "lblCSRPrompt";
|
||||
this.lblCSRPrompt.Size = new System.Drawing.Size(373, 13);
|
||||
this.lblCSRPrompt.TabIndex = 0;
|
||||
this.lblCSRPrompt.Text = "Please sign the following certificate signing request (CSR) using the agent CA:";
|
||||
//
|
||||
// tabCertificateBundle
|
||||
//
|
||||
this.tabCertificateBundle.Controls.Add(this.txtBundle);
|
||||
this.tabCertificateBundle.Controls.Add(this.lblBundlePrompt);
|
||||
this.tabCertificateBundle.Location = new System.Drawing.Point(4, 5);
|
||||
this.tabCertificateBundle.Name = "tabCertificateBundle";
|
||||
this.tabCertificateBundle.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabCertificateBundle.Size = new System.Drawing.Size(617, 500);
|
||||
this.tabCertificateBundle.TabIndex = 2;
|
||||
this.tabCertificateBundle.Text = "Certificate Bundle";
|
||||
this.tabCertificateBundle.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// txtBundle
|
||||
//
|
||||
this.txtBundle.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.txtBundle.Location = new System.Drawing.Point(24, 42);
|
||||
this.txtBundle.Multiline = true;
|
||||
this.txtBundle.Name = "txtBundle";
|
||||
this.txtBundle.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtBundle.Size = new System.Drawing.Size(564, 452);
|
||||
this.txtBundle.TabIndex = 1;
|
||||
//
|
||||
// lblBundlePrompt
|
||||
//
|
||||
this.lblBundlePrompt.AutoSize = true;
|
||||
this.lblBundlePrompt.Location = new System.Drawing.Point(21, 15);
|
||||
this.lblBundlePrompt.Name = "lblBundlePrompt";
|
||||
this.lblBundlePrompt.Size = new System.Drawing.Size(239, 13);
|
||||
this.lblBundlePrompt.TabIndex = 0;
|
||||
this.lblBundlePrompt.Text = "Paste the certificate bundle in the text box below:";
|
||||
//
|
||||
// tabParameters
|
||||
//
|
||||
this.tabParameters.Controls.Add(this.txtInstanceName);
|
||||
this.tabParameters.Controls.Add(this.label5);
|
||||
this.tabParameters.Controls.Add(this.groupBox3);
|
||||
this.tabParameters.Controls.Add(this.groupBox2);
|
||||
this.tabParameters.Controls.Add(this.groupBox1);
|
||||
this.tabParameters.Location = new System.Drawing.Point(4, 5);
|
||||
this.tabParameters.Name = "tabParameters";
|
||||
this.tabParameters.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabParameters.Size = new System.Drawing.Size(617, 500);
|
||||
this.tabParameters.TabIndex = 3;
|
||||
this.tabParameters.Text = "Agent Parameters";
|
||||
this.tabParameters.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// txtInstanceName
|
||||
//
|
||||
this.txtInstanceName.Location = new System.Drawing.Point(98, 16);
|
||||
this.txtInstanceName.Name = "txtInstanceName";
|
||||
this.txtInstanceName.ReadOnly = true;
|
||||
this.txtInstanceName.Size = new System.Drawing.Size(240, 20);
|
||||
this.txtInstanceName.TabIndex = 0;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(9, 20);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(82, 13);
|
||||
this.label5.TabIndex = 3;
|
||||
this.label5.Text = "Instance Name:";
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.rdoNoConnect);
|
||||
this.groupBox3.Controls.Add(this.txtPeerPort);
|
||||
this.groupBox3.Controls.Add(this.lblPeerPort);
|
||||
this.groupBox3.Controls.Add(this.txtPeerHost);
|
||||
this.groupBox3.Controls.Add(this.lblPeerHost);
|
||||
this.groupBox3.Controls.Add(this.rdoConnect);
|
||||
this.groupBox3.Location = new System.Drawing.Point(8, 305);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(601, 140);
|
||||
this.groupBox3.TabIndex = 3;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "TCP Connect";
|
||||
//
|
||||
// rdoNoConnect
|
||||
//
|
||||
this.rdoNoConnect.AutoSize = true;
|
||||
this.rdoNoConnect.Checked = true;
|
||||
this.rdoNoConnect.Location = new System.Drawing.Point(11, 108);
|
||||
this.rdoNoConnect.Name = "rdoNoConnect";
|
||||
this.rdoNoConnect.Size = new System.Drawing.Size(209, 17);
|
||||
this.rdoNoConnect.TabIndex = 3;
|
||||
this.rdoNoConnect.TabStop = true;
|
||||
this.rdoNoConnect.Text = "Do not connect to the master instance.";
|
||||
this.rdoNoConnect.UseVisualStyleBackColor = true;
|
||||
this.rdoNoConnect.CheckedChanged += new System.EventHandler(this.RadioConnect_CheckedChanged);
|
||||
//
|
||||
// txtPeerPort
|
||||
//
|
||||
this.txtPeerPort.Enabled = false;
|
||||
this.txtPeerPort.Location = new System.Drawing.Point(131, 79);
|
||||
this.txtPeerPort.Name = "txtPeerPort";
|
||||
this.txtPeerPort.Size = new System.Drawing.Size(84, 20);
|
||||
this.txtPeerPort.TabIndex = 2;
|
||||
this.txtPeerPort.Text = "8483";
|
||||
//
|
||||
// lblPeerPort
|
||||
//
|
||||
this.lblPeerPort.AutoSize = true;
|
||||
this.lblPeerPort.Location = new System.Drawing.Point(45, 82);
|
||||
this.lblPeerPort.Name = "lblPeerPort";
|
||||
this.lblPeerPort.Size = new System.Drawing.Size(29, 13);
|
||||
this.lblPeerPort.TabIndex = 6;
|
||||
this.lblPeerPort.Text = "Port:";
|
||||
//
|
||||
// txtPeerHost
|
||||
//
|
||||
this.txtPeerHost.Enabled = false;
|
||||
this.txtPeerHost.Location = new System.Drawing.Point(131, 53);
|
||||
this.txtPeerHost.Name = "txtPeerHost";
|
||||
this.txtPeerHost.Size = new System.Drawing.Size(240, 20);
|
||||
this.txtPeerHost.TabIndex = 1;
|
||||
//
|
||||
// lblPeerHost
|
||||
//
|
||||
this.lblPeerHost.AutoSize = true;
|
||||
this.lblPeerHost.Location = new System.Drawing.Point(45, 54);
|
||||
this.lblPeerHost.Name = "lblPeerHost";
|
||||
this.lblPeerHost.Size = new System.Drawing.Size(58, 13);
|
||||
this.lblPeerHost.TabIndex = 1;
|
||||
this.lblPeerHost.Text = "Hostname:";
|
||||
//
|
||||
// rdoConnect
|
||||
//
|
||||
this.rdoConnect.AutoSize = true;
|
||||
this.rdoConnect.Location = new System.Drawing.Point(11, 25);
|
||||
this.rdoConnect.Name = "rdoConnect";
|
||||
this.rdoConnect.Size = new System.Drawing.Size(175, 17);
|
||||
this.rdoConnect.TabIndex = 0;
|
||||
this.rdoConnect.Text = "Connect to the master instance:";
|
||||
this.rdoConnect.UseVisualStyleBackColor = true;
|
||||
this.rdoConnect.CheckedChanged += new System.EventHandler(this.RadioConnect_CheckedChanged);
|
||||
//
|
||||
// groupBox2
|
||||
//
|
||||
this.groupBox2.Controls.Add(this.rdoNoListener);
|
||||
this.groupBox2.Controls.Add(this.txtListenerPort);
|
||||
this.groupBox2.Controls.Add(this.lblListenerPort);
|
||||
this.groupBox2.Controls.Add(this.rdoListener);
|
||||
this.groupBox2.Location = new System.Drawing.Point(8, 178);
|
||||
this.groupBox2.Name = "groupBox2";
|
||||
this.groupBox2.Size = new System.Drawing.Size(601, 111);
|
||||
this.groupBox2.TabIndex = 2;
|
||||
this.groupBox2.TabStop = false;
|
||||
this.groupBox2.Text = "TCP Listener";
|
||||
//
|
||||
// rdoNoListener
|
||||
//
|
||||
this.rdoNoListener.AutoSize = true;
|
||||
this.rdoNoListener.Checked = true;
|
||||
this.rdoNoListener.Location = new System.Drawing.Point(11, 82);
|
||||
this.rdoNoListener.Name = "rdoNoListener";
|
||||
this.rdoNoListener.Size = new System.Drawing.Size(163, 17);
|
||||
this.rdoNoListener.TabIndex = 2;
|
||||
this.rdoNoListener.TabStop = true;
|
||||
this.rdoNoListener.Text = "Do not listen for connections.";
|
||||
this.rdoNoListener.UseVisualStyleBackColor = true;
|
||||
this.rdoNoListener.CheckedChanged += new System.EventHandler(this.RadioListener_CheckedChanged);
|
||||
//
|
||||
// txtListenerPort
|
||||
//
|
||||
this.txtListenerPort.Enabled = false;
|
||||
this.txtListenerPort.Location = new System.Drawing.Point(132, 51);
|
||||
this.txtListenerPort.Name = "txtListenerPort";
|
||||
this.txtListenerPort.Size = new System.Drawing.Size(84, 20);
|
||||
this.txtListenerPort.TabIndex = 1;
|
||||
this.txtListenerPort.Text = "8483";
|
||||
//
|
||||
// lblListenerPort
|
||||
//
|
||||
this.lblListenerPort.AutoSize = true;
|
||||
this.lblListenerPort.Location = new System.Drawing.Point(43, 55);
|
||||
this.lblListenerPort.Name = "lblListenerPort";
|
||||
this.lblListenerPort.Size = new System.Drawing.Size(29, 13);
|
||||
this.lblListenerPort.TabIndex = 1;
|
||||
this.lblListenerPort.Text = "Port:";
|
||||
//
|
||||
// rdoListener
|
||||
//
|
||||
this.rdoListener.AutoSize = true;
|
||||
this.rdoListener.Location = new System.Drawing.Point(11, 24);
|
||||
this.rdoListener.Name = "rdoListener";
|
||||
this.rdoListener.Size = new System.Drawing.Size(250, 17);
|
||||
this.rdoListener.TabIndex = 0;
|
||||
this.rdoListener.Text = "Listen for connections from the master instance:";
|
||||
this.rdoListener.UseVisualStyleBackColor = true;
|
||||
this.rdoListener.CheckedChanged += new System.EventHandler(this.RadioListener_CheckedChanged);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.txtMasterInstance);
|
||||
this.groupBox1.Controls.Add(this.lblMasterInstance);
|
||||
this.groupBox1.Controls.Add(this.rdoNoMaster);
|
||||
this.groupBox1.Controls.Add(this.rdoNewMaster);
|
||||
this.groupBox1.Location = new System.Drawing.Point(8, 48);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(601, 112);
|
||||
this.groupBox1.TabIndex = 1;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Master Instance";
|
||||
//
|
||||
// txtMasterInstance
|
||||
//
|
||||
this.txtMasterInstance.Location = new System.Drawing.Point(132, 78);
|
||||
this.txtMasterInstance.Name = "txtMasterInstance";
|
||||
this.txtMasterInstance.Size = new System.Drawing.Size(240, 20);
|
||||
this.txtMasterInstance.TabIndex = 2;
|
||||
//
|
||||
// lblMasterInstance
|
||||
//
|
||||
this.lblMasterInstance.AutoSize = true;
|
||||
this.lblMasterInstance.Location = new System.Drawing.Point(40, 81);
|
||||
this.lblMasterInstance.Name = "lblMasterInstance";
|
||||
this.lblMasterInstance.Size = new System.Drawing.Size(86, 13);
|
||||
this.lblMasterInstance.TabIndex = 2;
|
||||
this.lblMasterInstance.Text = "Master Instance:";
|
||||
//
|
||||
// rdoNoMaster
|
||||
//
|
||||
this.rdoNoMaster.AutoSize = true;
|
||||
this.rdoNoMaster.Checked = true;
|
||||
this.rdoNoMaster.Location = new System.Drawing.Point(11, 50);
|
||||
this.rdoNoMaster.Name = "rdoNoMaster";
|
||||
this.rdoNoMaster.Size = new System.Drawing.Size(383, 17);
|
||||
this.rdoNoMaster.TabIndex = 1;
|
||||
this.rdoNoMaster.TabStop = true;
|
||||
this.rdoNoMaster.Text = "This instance should report its check results to an existing Icinga 2 instance:";
|
||||
this.rdoNoMaster.UseVisualStyleBackColor = true;
|
||||
this.rdoNoMaster.CheckedChanged += new System.EventHandler(this.RadioMaster_CheckedChanged);
|
||||
//
|
||||
// rdoNewMaster
|
||||
//
|
||||
this.rdoNewMaster.AutoSize = true;
|
||||
this.rdoNewMaster.Location = new System.Drawing.Point(11, 22);
|
||||
this.rdoNewMaster.Name = "rdoNewMaster";
|
||||
this.rdoNewMaster.Size = new System.Drawing.Size(167, 17);
|
||||
this.rdoNewMaster.TabIndex = 0;
|
||||
this.rdoNewMaster.TabStop = true;
|
||||
this.rdoNewMaster.Text = "This is a new master instance.";
|
||||
this.rdoNewMaster.UseVisualStyleBackColor = true;
|
||||
this.rdoNewMaster.CheckedChanged += new System.EventHandler(this.RadioMaster_CheckedChanged);
|
||||
//
|
||||
// picBanner
|
||||
//
|
||||
this.picBanner.Image = global::Icinga.Properties.Resources.icinga_banner;
|
||||
this.picBanner.Location = new System.Drawing.Point(0, 0);
|
||||
this.picBanner.Name = "picBanner";
|
||||
this.picBanner.Size = new System.Drawing.Size(625, 77);
|
||||
this.picBanner.TabIndex = 1;
|
||||
this.picBanner.TabStop = false;
|
||||
//
|
||||
// btnBack
|
||||
//
|
||||
this.btnBack.Enabled = false;
|
||||
this.btnBack.Location = new System.Drawing.Point(367, 592);
|
||||
this.btnBack.Name = "btnBack";
|
||||
this.btnBack.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnBack.TabIndex = 1;
|
||||
this.btnBack.Text = "< &Back";
|
||||
this.btnBack.UseVisualStyleBackColor = true;
|
||||
this.btnBack.Click += new System.EventHandler(this.btnBack_Click);
|
||||
//
|
||||
// btnNext
|
||||
//
|
||||
this.btnNext.Enabled = false;
|
||||
this.btnNext.Location = new System.Drawing.Point(448, 592);
|
||||
this.btnNext.Name = "btnNext";
|
||||
this.btnNext.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnNext.TabIndex = 2;
|
||||
this.btnNext.Text = "&Next >";
|
||||
this.btnNext.UseVisualStyleBackColor = true;
|
||||
this.btnNext.Click += new System.EventHandler(this.btnNext_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.btnCancel.Location = new System.Drawing.Point(538, 592);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.btnCancel.TabIndex = 3;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// tabConfigure
|
||||
//
|
||||
this.tabConfigure.Controls.Add(this.lblConfigStatus);
|
||||
this.tabConfigure.Controls.Add(this.prgConfig);
|
||||
this.tabConfigure.Location = new System.Drawing.Point(4, 5);
|
||||
this.tabConfigure.Name = "tabConfigure";
|
||||
this.tabConfigure.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabConfigure.Size = new System.Drawing.Size(617, 500);
|
||||
this.tabConfigure.TabIndex = 4;
|
||||
this.tabConfigure.Text = "Configure Icinga 2";
|
||||
this.tabConfigure.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// prgConfig
|
||||
//
|
||||
this.prgConfig.Location = new System.Drawing.Point(184, 223);
|
||||
this.prgConfig.Name = "prgConfig";
|
||||
this.prgConfig.Size = new System.Drawing.Size(289, 23);
|
||||
this.prgConfig.TabIndex = 0;
|
||||
//
|
||||
// lblConfigStatus
|
||||
//
|
||||
this.lblConfigStatus.AutoSize = true;
|
||||
this.lblConfigStatus.Location = new System.Drawing.Point(184, 204);
|
||||
this.lblConfigStatus.Name = "lblConfigStatus";
|
||||
this.lblConfigStatus.Size = new System.Drawing.Size(141, 13);
|
||||
this.lblConfigStatus.TabIndex = 1;
|
||||
this.lblConfigStatus.Text = "Updating the configuration...";
|
||||
//
|
||||
// tabFinish
|
||||
//
|
||||
this.tabFinish.Controls.Add(this.label1);
|
||||
this.tabFinish.Location = new System.Drawing.Point(4, 5);
|
||||
this.tabFinish.Name = "tabFinish";
|
||||
this.tabFinish.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabFinish.Size = new System.Drawing.Size(617, 500);
|
||||
this.tabFinish.TabIndex = 5;
|
||||
this.tabFinish.Text = "Finish";
|
||||
this.tabFinish.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(34, 35);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(214, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "The Icinga 2 agent was set up successfully.";
|
||||
//
|
||||
// AgentWizard
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(625, 624);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.btnNext);
|
||||
this.Controls.Add(this.btnBack);
|
||||
this.Controls.Add(this.picBanner);
|
||||
this.Controls.Add(this.tbcPages);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "AgentWizard";
|
||||
this.Text = "Icinga 2 Agent Wizard";
|
||||
this.Shown += new System.EventHandler(this.AgentWizard_Shown);
|
||||
this.tbcPages.ResumeLayout(false);
|
||||
this.tabAgentKey.ResumeLayout(false);
|
||||
this.tabAgentKey.PerformLayout();
|
||||
this.tabCSR.ResumeLayout(false);
|
||||
this.tabCSR.PerformLayout();
|
||||
this.tabCertificateBundle.ResumeLayout(false);
|
||||
this.tabCertificateBundle.PerformLayout();
|
||||
this.tabParameters.ResumeLayout(false);
|
||||
this.tabParameters.PerformLayout();
|
||||
this.groupBox3.ResumeLayout(false);
|
||||
this.groupBox3.PerformLayout();
|
||||
this.groupBox2.ResumeLayout(false);
|
||||
this.groupBox2.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picBanner)).EndInit();
|
||||
this.tabConfigure.ResumeLayout(false);
|
||||
this.tabConfigure.PerformLayout();
|
||||
this.tabFinish.ResumeLayout(false);
|
||||
this.tabFinish.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TabControl tbcPages;
|
||||
private System.Windows.Forms.TabPage tabAgentKey;
|
||||
private System.Windows.Forms.TabPage tabCSR;
|
||||
private System.Windows.Forms.PictureBox picBanner;
|
||||
private System.Windows.Forms.Button btnBack;
|
||||
private System.Windows.Forms.Button btnNext;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Label lblHostKey;
|
||||
private System.Windows.Forms.ProgressBar prgHostKey;
|
||||
private System.Windows.Forms.TextBox txtCSR;
|
||||
private System.Windows.Forms.Label lblCSRPrompt;
|
||||
private System.Windows.Forms.TabPage tabCertificateBundle;
|
||||
private System.Windows.Forms.TextBox txtBundle;
|
||||
private System.Windows.Forms.Label lblBundlePrompt;
|
||||
private System.Windows.Forms.TabPage tabParameters;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.TextBox txtMasterInstance;
|
||||
private System.Windows.Forms.Label lblMasterInstance;
|
||||
private System.Windows.Forms.RadioButton rdoNoMaster;
|
||||
private System.Windows.Forms.RadioButton rdoNewMaster;
|
||||
private System.Windows.Forms.GroupBox groupBox2;
|
||||
private System.Windows.Forms.TextBox txtListenerPort;
|
||||
private System.Windows.Forms.Label lblListenerPort;
|
||||
private System.Windows.Forms.RadioButton rdoListener;
|
||||
private System.Windows.Forms.RadioButton rdoNoListener;
|
||||
private System.Windows.Forms.GroupBox groupBox3;
|
||||
private System.Windows.Forms.Label lblPeerHost;
|
||||
private System.Windows.Forms.RadioButton rdoConnect;
|
||||
private System.Windows.Forms.TextBox txtPeerPort;
|
||||
private System.Windows.Forms.Label lblPeerPort;
|
||||
private System.Windows.Forms.TextBox txtPeerHost;
|
||||
private System.Windows.Forms.RadioButton rdoNoConnect;
|
||||
private System.Windows.Forms.TextBox txtInstanceName;
|
||||
private System.Windows.Forms.Label label5;
|
||||
private System.Windows.Forms.TabPage tabConfigure;
|
||||
private System.Windows.Forms.Label lblConfigStatus;
|
||||
private System.Windows.Forms.ProgressBar prgConfig;
|
||||
private System.Windows.Forms.TabPage tabFinish;
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
|
331
tools/icinga2-setup-agent/AgentWizard.cs
Normal file
331
tools/icinga2-setup-agent/AgentWizard.cs
Normal file
@ -0,0 +1,331 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Xml;
|
||||
using Microsoft.Win32;
|
||||
using System.IO.Compression;
|
||||
using System.Diagnostics;
|
||||
using System.ServiceProcess;
|
||||
using System.Security.AccessControl;
|
||||
using tar_cs;
|
||||
|
||||
namespace Icinga
|
||||
{
|
||||
public partial class AgentWizard : Form
|
||||
{
|
||||
[DllImport("base", CallingConvention = CallingConvention.Cdecl)]
|
||||
private extern static int MakeX509CSR(string cn, string keyfile, string csrfile);
|
||||
|
||||
delegate void FormCallback();
|
||||
|
||||
public AgentWizard()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
txtInstanceName.Text = Icinga2InstanceName;
|
||||
}
|
||||
|
||||
private void FatalError(string message)
|
||||
{
|
||||
MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void Warning(string message)
|
||||
{
|
||||
MessageBox.Show(this, message, Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
private string Icinga2InstallDir
|
||||
{
|
||||
get
|
||||
{
|
||||
RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Icinga Development Team\\ICINGA2");
|
||||
|
||||
if (rk == null)
|
||||
return "";
|
||||
|
||||
return (string)rk.GetValue("");
|
||||
}
|
||||
}
|
||||
|
||||
private string Icinga2InstanceName
|
||||
{
|
||||
get
|
||||
{
|
||||
IPGlobalProperties props = IPGlobalProperties.GetIPGlobalProperties();
|
||||
|
||||
string fqdn = props.HostName;
|
||||
|
||||
if (props.DomainName != "")
|
||||
fqdn += "." + props.DomainName;
|
||||
|
||||
return fqdn;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableFeature(string feature)
|
||||
{
|
||||
using (FileStream fp = File.Open(Icinga2InstallDir + String.Format("\\etc\\icinga2\\features-enabled\\{0}.conf", feature), FileMode.Create)) {
|
||||
using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) {
|
||||
sw.Write(String.Format("include \"../features-available/{0}.conf\"\n", feature));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void GenerateHostKey()
|
||||
{
|
||||
if (!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.key") ||
|
||||
!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.csr")) {
|
||||
try {
|
||||
MakeX509CSR(Icinga2InstanceName,
|
||||
Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.key",
|
||||
Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.csr");
|
||||
} catch (Exception ex) {
|
||||
FatalError("MakeX509CSR failed: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
FinishHostKey();
|
||||
}
|
||||
|
||||
private void FinishHostKey()
|
||||
{
|
||||
if (InvokeRequired) {
|
||||
Invoke(new FormCallback(FinishHostKey));
|
||||
return;
|
||||
}
|
||||
|
||||
txtCSR.Text = File.ReadAllText(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.csr").Replace("\n", "\r\n");
|
||||
|
||||
if (!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt"))
|
||||
tbcPages.SelectedTab = tabCSR;
|
||||
else
|
||||
tbcPages.SelectedTab = tabParameters;
|
||||
}
|
||||
|
||||
private void SetConfigureStatus(int pct, string message)
|
||||
{
|
||||
if (InvokeRequired) {
|
||||
Invoke(new FormCallback(() => SetConfigureStatus(pct, message)));
|
||||
return;
|
||||
}
|
||||
|
||||
prgConfig.Value = pct;
|
||||
lblConfigStatus.Text = message;
|
||||
}
|
||||
|
||||
private void ConfigureService()
|
||||
{
|
||||
SetConfigureStatus(0, "Updating configuration files...");
|
||||
using (FileStream fp = File.Open(Icinga2InstallDir + "\\etc\\icinga2\\features-available\\agent.conf", FileMode.Create)) {
|
||||
using (StreamWriter sw = new StreamWriter(fp, Encoding.ASCII)) {
|
||||
sw.Write(
|
||||
"/**\n" +
|
||||
" * The agent listener accepts checks from agents.\n" +
|
||||
" */\n" +
|
||||
"\n" +
|
||||
"library \"agent\"\n" +
|
||||
"\n" +
|
||||
"object AgentListener \"agent\" {\n" +
|
||||
" cert_path = SysconfDir + \"/icinga2/pki/agent/agent.crt\"\n" +
|
||||
" key_path = SysconfDir + \"/icinga2/pki/agent/agent.key\"\n" +
|
||||
" ca_path = SysconfDir + \"/icinga2/pki/agent/ca.crt\"\n"
|
||||
);
|
||||
|
||||
if (rdoNoMaster.Checked)
|
||||
sw.Write(" upstream_name = \"{0}\"\n", txtMasterInstance.Text);
|
||||
|
||||
if (rdoListener.Checked)
|
||||
sw.Write(" bind_port = \"{0}\"\n", txtListenerPort.Text);
|
||||
|
||||
if (rdoConnect.Checked)
|
||||
sw.Write(
|
||||
" upstream_host = \"{0}\"\n" +
|
||||
" upstream_port = \"{1}\"\n", txtPeerHost.Text, txtPeerPort.Text
|
||||
);
|
||||
|
||||
sw.Write("}\n");
|
||||
}
|
||||
}
|
||||
|
||||
EnableFeature("agent");
|
||||
EnableFeature("checker");
|
||||
|
||||
SetConfigureStatus(10, "Setting ACLs for the Icinga 2 directory...");
|
||||
DirectoryInfo di = new DirectoryInfo(Icinga2InstallDir);
|
||||
DirectorySecurity ds = di.GetAccessControl();
|
||||
FileSystemAccessRule rule = new FileSystemAccessRule("NT AUTHORITY\\NetworkService",
|
||||
FileSystemRights.ReadAndExecute | FileSystemRights.Write | FileSystemRights.ListDirectory,
|
||||
InheritanceFlags.ObjectInherit | InheritanceFlags.ContainerInherit, PropagationFlags.None, AccessControlType.Allow);
|
||||
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...");
|
||||
ProcessStartInfo psi = new ProcessStartInfo();
|
||||
psi.FileName = Icinga2InstallDir + "\\sbin\\icinga2.exe";
|
||||
psi.Arguments = "--scm-install -c \"" + Icinga2InstallDir + "\\etc\\icinga2\\icinga2.conf\"";
|
||||
psi.CreateNoWindow = true;
|
||||
psi.UseShellExecute = false;
|
||||
|
||||
using (Process proc = Process.Start(psi)) {
|
||||
proc.WaitForExit();
|
||||
|
||||
if (proc.ExitCode != 0)
|
||||
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();
|
||||
}
|
||||
|
||||
private void FinishConfigure()
|
||||
{
|
||||
if (InvokeRequired) {
|
||||
Invoke(new FormCallback(FinishConfigure));
|
||||
return;
|
||||
}
|
||||
|
||||
tbcPages.SelectedTab = tabFinish;
|
||||
}
|
||||
|
||||
private void AgentWizard_Shown(object sender, EventArgs e)
|
||||
{
|
||||
string installDir = Icinga2InstallDir;
|
||||
|
||||
if (installDir == "")
|
||||
FatalError("Icinga 2 does not seem to be installed properly.");
|
||||
|
||||
/* TODO: This is something the NSIS installer should do */
|
||||
Directory.CreateDirectory(installDir + "\\var\\cache\\icinga2");
|
||||
Directory.CreateDirectory(installDir + "\\var\\lib\\icinga2\\agent\\inventory");
|
||||
Directory.CreateDirectory(installDir + "\\var\\lib\\icinga2\\cluster\\config");
|
||||
Directory.CreateDirectory(installDir + "\\var\\lib\\icinga2\\cluster\\log");
|
||||
Directory.CreateDirectory(installDir + "\\var\\log\\icinga2\\compat\\archive");
|
||||
Directory.CreateDirectory(installDir + "\\var\\run\\icinga2\\cmd");
|
||||
Directory.CreateDirectory(installDir + "\\var\\spool\\icinga2\\perfdata");
|
||||
Directory.CreateDirectory(installDir + "\\var\\spool\\icinga2\\tmp");
|
||||
|
||||
Directory.CreateDirectory(installDir + "\\etc\\icinga2\\pki\\agent");
|
||||
|
||||
Thread thread = new Thread(GenerateHostKey);
|
||||
thread.IsBackground = true;
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
private void btnBack_Click(object sender, EventArgs e)
|
||||
{
|
||||
tbcPages.SelectedIndex--;
|
||||
}
|
||||
|
||||
private void btnNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (tbcPages.SelectedTab == tabParameters) {
|
||||
if (rdoNoMaster.Checked && txtMasterInstance.Text == "") {
|
||||
Warning("You need to enter the name of the master instance.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rdoConnect.Checked && (txtPeerHost.Text == "" || txtPeerPort.Text == "")) {
|
||||
Warning("You need to specify a host and port.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rdoListener.Checked && (txtListenerPort.Text == "")) {
|
||||
Warning("You need to specify a listener port.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (rdoNoListener.Checked && rdoNoConnect.Checked) {
|
||||
Warning("You need to enable the listener or outbound connects.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (tbcPages.SelectedTab == tabFinish)
|
||||
Application.Exit();
|
||||
|
||||
tbcPages.SelectedIndex++;
|
||||
btnBack.Enabled = true;
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
private void tbcPages_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Refresh();
|
||||
|
||||
btnBack.Enabled = (tbcPages.SelectedTab != tabCSR && tbcPages.SelectedTab != tabFinish);
|
||||
btnNext.Enabled = true;
|
||||
|
||||
if (tbcPages.SelectedTab == tabFinish) {
|
||||
btnNext.Text = "&Finish >";
|
||||
btnCancel.Enabled = false;
|
||||
}
|
||||
|
||||
if (tbcPages.SelectedTab == tabParameters &&
|
||||
!File.Exists(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent\\agent.crt")) {
|
||||
byte[] bytes = Convert.FromBase64String(txtBundle.Text);
|
||||
MemoryStream ms = new MemoryStream(bytes);
|
||||
GZipStream gz = new GZipStream(ms, CompressionMode.Decompress);
|
||||
MemoryStream ms2 = new MemoryStream();
|
||||
gz.CopyTo(ms2);
|
||||
ms2.Position = 0;
|
||||
TarReader tr = new TarReader(ms2);
|
||||
tr.ReadToEnd(Icinga2InstallDir + "\\etc\\icinga2\\pki\\agent");
|
||||
}
|
||||
|
||||
if (tbcPages.SelectedTab == tabConfigure) {
|
||||
Thread thread = new Thread(ConfigureService);
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void RadioMaster_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
txtMasterInstance.Enabled = !rdoNewMaster.Checked;
|
||||
}
|
||||
|
||||
private void RadioListener_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
txtListenerPort.Enabled = rdoListener.Checked;
|
||||
}
|
||||
|
||||
private void RadioConnect_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
txtPeerHost.Enabled = rdoConnect.Checked;
|
||||
txtPeerPort.Enabled = rdoConnect.Checked;
|
||||
}
|
||||
}
|
||||
}
|
138
tools/icinga2-setup-agent/AgentWizard.resx
Normal file
138
tools/icinga2-setup-agent/AgentWizard.resx
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
AAABAAEAICAQAAAABADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAAAIAAAAAAAAAAAAAEAAAABAA
|
||||
AAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA/wD/AP//
|
||||
AAD///8AAAAAAAAAAAAAAAAAAAAAAAAHAAAAAAAAAAAAAAAAcAAAcAB3AAAAAAAAAAAAAAcABwB///cA
|
||||
AAAAAAAAAAAAcAAA////AAAAAAAAAAAAAAAAAP///3AAAAAAAAAAAAAAAAD///9wAAAAAAAAAAAAAAAA
|
||||
j//4AAAAB3AAAAAAAAAAAAj/jwAAAA/4AAAAAAAAAAAAAAiAAAAP9wAAAAAAAAAAAAAH9wAAf3AAAAAA
|
||||
AAAAAAAAAH93d/cAAAAAAAAAAAAAAAB////3AAAAAAAAAAAAAAAA/////wAAAAAAAAAAAAAAB/////9w
|
||||
AAAAAAAAAAAAAAf/////gAAAAAAAAAAAAAAH//////h3AAAAAAAAAAAAB/////+I//h3eHAAAAAAAAD/
|
||||
////AAB3j//3AAAAAAB4////9wAAAAf/+AAAAAf/+AB4iPAAAAAAj/cAAAAH//AAAAD3AAAAAAcAAAAA
|
||||
B/+AAAAAjwAAAAAAAAAAAAB3AAAAAA9wAAAAAAAAAAAAAAAAAAAIh3AAAAAAAAAAAAAAAAAAD//wAAAA
|
||||
AAAAAAAAAAAAAH//9wAAAAAAAAAAAAAAAAB///cAAAAAAAcAAAAAAAAACP+AAAAAAHAAcAAAAAAAAAB3
|
||||
AAAAAAcAAAcAAAAAAAAAAAAAAABwAAAAAAAAAAAAAAAAAAAAAAD/////4AAAB8AAAAOAAAABgAAAAYAA
|
||||
AAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAYAA
|
||||
AAGAAAABgAAAAYAAAAGAAAABgAAAAYAAAAGAAAABgAAAAcAAAAPgAAAH/////w==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
6
tools/icinga2-setup-agent/App.config
Normal file
6
tools/icinga2-setup-agent/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
108
tools/icinga2-setup-agent/Icinga2SetupAgent.csproj
Normal file
108
tools/icinga2-setup-agent/Icinga2SetupAgent.csproj
Normal file
@ -0,0 +1,108 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A86F1159-66E8-4BDB-BF28-A2BDAF76517C}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Icinga</RootNamespace>
|
||||
<AssemblyName>Icinga2SetupAgent</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>icinga.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AgentWizard.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AgentWizard.Designer.cs">
|
||||
<DependentUpon>AgentWizard.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="tar-cs\ITarHeader.cs" />
|
||||
<Compile Include="tar-cs\TarException.cs" />
|
||||
<Compile Include="tar-cs\TarHeader.cs" />
|
||||
<Compile Include="tar-cs\TarReader.cs" />
|
||||
<Compile Include="tar-cs\UsTarHeader.cs" />
|
||||
<EmbeddedResource Include="AgentWizard.resx">
|
||||
<DependentUpon>AgentWizard.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="app.manifest" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="icinga-banner.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="icinga.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
22
tools/icinga2-setup-agent/Program.cs
Normal file
22
tools/icinga2-setup-agent/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Icinga
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new AgentWizard());
|
||||
}
|
||||
}
|
||||
}
|
36
tools/icinga2-setup-agent/Properties/AssemblyInfo.cs
Normal file
36
tools/icinga2-setup-agent/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Icinga 2 Agent Wizard")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Icinga Development Team")]
|
||||
[assembly: AssemblyProduct("Icinga 2")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014 Icinga Development Team")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("51f4fcaf-8cf8-4d1c-9fde-61526c17a0d8")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
73
tools/icinga2-setup-agent/Properties/Resources.Designer.cs
generated
Normal file
73
tools/icinga2-setup-agent/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34011
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Icinga.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Icinga.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icinga_banner {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icinga-banner", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
124
tools/icinga2-setup-agent/Properties/Resources.resx
Normal file
124
tools/icinga2-setup-agent/Properties/Resources.resx
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="icinga-banner" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\icinga-banner.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
26
tools/icinga2-setup-agent/Properties/Settings.Designer.cs
generated
Normal file
26
tools/icinga2-setup-agent/Properties/Settings.Designer.cs
generated
Normal file
@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34011
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Icinga.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
tools/icinga2-setup-agent/Properties/Settings.settings
Normal file
7
tools/icinga2-setup-agent/Properties/Settings.settings
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
58
tools/icinga2-setup-agent/app.manifest
Normal file
58
tools/icinga2-setup-agent/app.manifest
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<!-- UAC Manifest Options
|
||||
If you want to change the Windows User Account Control level replace the
|
||||
requestedExecutionLevel node with one of the following.
|
||||
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
|
||||
|
||||
Specifying requestedExecutionLevel node will disable file and registry virtualization.
|
||||
If you want to utilize File and Registry Virtualization for backward
|
||||
compatibility then delete the requestedExecutionLevel node.
|
||||
-->
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- A list of all Windows versions that this application is designed to work with.
|
||||
Windows will automatically select the most compatible environment.-->
|
||||
|
||||
<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
|
||||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->
|
||||
|
||||
<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
|
||||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->
|
||||
|
||||
<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
|
||||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->
|
||||
|
||||
<!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node-->
|
||||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->
|
||||
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<!-- <dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>-->
|
||||
|
||||
</asmv1:assembly>
|
BIN
tools/icinga2-setup-agent/icinga-banner.png
Normal file
BIN
tools/icinga2-setup-agent/icinga-banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
BIN
tools/icinga2-setup-agent/icinga.ico
Normal file
BIN
tools/icinga2-setup-agent/icinga.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 766 B |
11
tools/icinga2-setup-agent/tar-cs/COPYING
Normal file
11
tools/icinga2-setup-agent/tar-cs/COPYING
Normal file
@ -0,0 +1,11 @@
|
||||
BSD License
|
||||
|
||||
Copyright (c) 2009, Vladimir Vasiltsov All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
tools/icinga2-setup-agent/tar-cs/ITarHeader.cs
Normal file
30
tools/icinga2-setup-agent/tar-cs/ITarHeader.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace tar_cs
|
||||
{
|
||||
public enum EntryType : byte
|
||||
{
|
||||
File = 0,
|
||||
FileObsolete = 0x30,
|
||||
HardLink = 0x31,
|
||||
SymLink = 0x32,
|
||||
CharDevice = 0x33,
|
||||
BlockDevice = 0x34,
|
||||
Directory = 0x35,
|
||||
Fifo = 0x36,
|
||||
}
|
||||
|
||||
public interface ITarHeader
|
||||
{
|
||||
string FileName { get; set; }
|
||||
int Mode { get; set; }
|
||||
int UserId { get; set; }
|
||||
string UserName { get; set; }
|
||||
int GroupId { get; set; }
|
||||
string GroupName { get; set; }
|
||||
long SizeInBytes { get; set; }
|
||||
DateTime LastModification { get; set; }
|
||||
int HeaderSize { get; }
|
||||
EntryType EntryType { get; set; }
|
||||
}
|
||||
}
|
11
tools/icinga2-setup-agent/tar-cs/TarException.cs
Normal file
11
tools/icinga2-setup-agent/tar-cs/TarException.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace tar_cs
|
||||
{
|
||||
public class TarException : Exception
|
||||
{
|
||||
public TarException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
197
tools/icinga2-setup-agent/tar-cs/TarHeader.cs
Normal file
197
tools/icinga2-setup-agent/tar-cs/TarHeader.cs
Normal file
@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using tar_cs;
|
||||
|
||||
namespace tar_cs
|
||||
{
|
||||
internal class TarHeader : ITarHeader
|
||||
{
|
||||
private readonly byte[] buffer = new byte[512];
|
||||
private long headerChecksum;
|
||||
|
||||
public TarHeader()
|
||||
{
|
||||
// Default values
|
||||
Mode = 511; // 0777 dec
|
||||
UserId = 61; // 101 dec
|
||||
GroupId = 61; // 101 dec
|
||||
}
|
||||
|
||||
private string fileName;
|
||||
protected readonly DateTime TheEpoch = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||
public EntryType EntryType { get; set; }
|
||||
private static byte[] spaces = Encoding.ASCII.GetBytes(" ");
|
||||
|
||||
public virtual string FileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return fileName.Replace("\0",string.Empty);
|
||||
}
|
||||
set
|
||||
{
|
||||
if(value.Length > 100)
|
||||
{
|
||||
throw new TarException("A file name can not be more than 100 chars long");
|
||||
}
|
||||
fileName = value;
|
||||
}
|
||||
}
|
||||
public int Mode { get; set; }
|
||||
|
||||
public string ModeString
|
||||
{
|
||||
get { return Convert.ToString(Mode, 8).PadLeft(7, '0'); }
|
||||
}
|
||||
|
||||
public int UserId { get; set; }
|
||||
public virtual string UserName
|
||||
{
|
||||
get { return UserId.ToString(); }
|
||||
set { UserId = Int32.Parse(value); }
|
||||
}
|
||||
|
||||
public string UserIdString
|
||||
{
|
||||
get { return Convert.ToString(UserId, 8).PadLeft(7, '0'); }
|
||||
}
|
||||
|
||||
public int GroupId { get; set; }
|
||||
public virtual string GroupName
|
||||
{
|
||||
get { return GroupId.ToString(); }
|
||||
set { GroupId = Int32.Parse(value); }
|
||||
}
|
||||
|
||||
public string GroupIdString
|
||||
{
|
||||
get { return Convert.ToString(GroupId, 8).PadLeft(7, '0'); }
|
||||
}
|
||||
|
||||
public long SizeInBytes { get; set; }
|
||||
|
||||
public string SizeString
|
||||
{
|
||||
get { return Convert.ToString(SizeInBytes, 8).PadLeft(11, '0'); }
|
||||
}
|
||||
|
||||
public DateTime LastModification { get; set; }
|
||||
|
||||
public string LastModificationString
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToString((long)(LastModification - TheEpoch).TotalSeconds, 8).PadLeft(11, '0');
|
||||
}
|
||||
}
|
||||
|
||||
public string HeaderChecksumString
|
||||
{
|
||||
get { return Convert.ToString(headerChecksum, 8).PadLeft(6, '0'); }
|
||||
}
|
||||
|
||||
|
||||
public virtual int HeaderSize
|
||||
{
|
||||
get { return 512; }
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public virtual bool UpdateHeaderFromBytes()
|
||||
{
|
||||
FileName = Encoding.ASCII.GetString(buffer, 0, 100);
|
||||
// thanks to Shasha Alperocivh. Trimming nulls.
|
||||
Mode = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 100, 7).Trim(), 8);
|
||||
UserId = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 108, 7).Trim(), 8);
|
||||
GroupId = Convert.ToInt32(Encoding.ASCII.GetString(buffer, 116, 7).Trim(), 8);
|
||||
|
||||
EntryType = (EntryType)buffer[156];
|
||||
|
||||
if((buffer[124] & 0x80) == 0x80) // if size in binary
|
||||
{
|
||||
long sizeBigEndian = BitConverter.ToInt64(buffer,0x80);
|
||||
SizeInBytes = IPAddress.NetworkToHostOrder(sizeBigEndian);
|
||||
}
|
||||
else
|
||||
{
|
||||
SizeInBytes = Convert.ToInt64(Encoding.ASCII.GetString(buffer, 124, 11), 8);
|
||||
}
|
||||
long unixTimeStamp = Convert.ToInt64(Encoding.ASCII.GetString(buffer,136,11),8);
|
||||
LastModification = TheEpoch.AddSeconds(unixTimeStamp);
|
||||
|
||||
var storedChecksum = Convert.ToInt32(Encoding.ASCII.GetString(buffer,148,6));
|
||||
RecalculateChecksum(buffer);
|
||||
if (storedChecksum == headerChecksum)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
RecalculateAltChecksum(buffer);
|
||||
return storedChecksum == headerChecksum;
|
||||
}
|
||||
|
||||
private void RecalculateAltChecksum(byte[] buf)
|
||||
{
|
||||
spaces.CopyTo(buf, 148);
|
||||
headerChecksum = 0;
|
||||
foreach(byte b in buf)
|
||||
{
|
||||
if((b & 0x80) == 0x80)
|
||||
{
|
||||
headerChecksum -= b ^ 0x80;
|
||||
}
|
||||
else
|
||||
{
|
||||
headerChecksum += b;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual byte[] GetHeaderValue()
|
||||
{
|
||||
// Clean old values
|
||||
Array.Clear(buffer,0, buffer.Length);
|
||||
|
||||
if (string.IsNullOrEmpty(FileName)) throw new TarException("FileName can not be empty.");
|
||||
if (FileName.Length >= 100) throw new TarException("FileName is too long. It must be less than 100 bytes.");
|
||||
|
||||
// Fill header
|
||||
Encoding.ASCII.GetBytes(FileName.PadRight(100, '\0')).CopyTo(buffer, 0);
|
||||
Encoding.ASCII.GetBytes(ModeString).CopyTo(buffer, 100);
|
||||
Encoding.ASCII.GetBytes(UserIdString).CopyTo(buffer, 108);
|
||||
Encoding.ASCII.GetBytes(GroupIdString).CopyTo(buffer, 116);
|
||||
Encoding.ASCII.GetBytes(SizeString).CopyTo(buffer, 124);
|
||||
Encoding.ASCII.GetBytes(LastModificationString).CopyTo(buffer, 136);
|
||||
|
||||
// buffer[156] = 20;
|
||||
buffer[156] = ((byte) EntryType);
|
||||
|
||||
|
||||
RecalculateChecksum(buffer);
|
||||
|
||||
// Write checksum
|
||||
Encoding.ASCII.GetBytes(HeaderChecksumString).CopyTo(buffer, 148);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
protected virtual void RecalculateChecksum(byte[] buf)
|
||||
{
|
||||
// Set default value for checksum. That is 8 spaces.
|
||||
spaces.CopyTo(buf, 148);
|
||||
|
||||
// Calculate checksum
|
||||
headerChecksum = 0;
|
||||
foreach (byte b in buf)
|
||||
{
|
||||
headerChecksum += b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
224
tools/icinga2-setup-agent/tar-cs/TarReader.cs
Normal file
224
tools/icinga2-setup-agent/tar-cs/TarReader.cs
Normal file
@ -0,0 +1,224 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace tar_cs
|
||||
{
|
||||
/// <summary>
|
||||
/// Extract contents of a tar file represented by a stream for the TarReader constructor
|
||||
/// </summary>
|
||||
public class TarReader
|
||||
{
|
||||
private readonly byte[] dataBuffer = new byte[512];
|
||||
private readonly UsTarHeader header;
|
||||
private readonly Stream inStream;
|
||||
private long remainingBytesInFile;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs TarReader object to read data from `tarredData` stream
|
||||
/// </summary>
|
||||
/// <param name="tarredData">A stream to read tar archive from</param>
|
||||
public TarReader(Stream tarredData)
|
||||
{
|
||||
inStream = tarredData;
|
||||
header = new UsTarHeader();
|
||||
}
|
||||
|
||||
public ITarHeader FileInfo
|
||||
{
|
||||
get { return header; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read all files from an archive to a directory. It creates some child directories to
|
||||
/// reproduce a file structure from the archive.
|
||||
/// </summary>
|
||||
/// <param name="destDirectory">The out directory.</param>
|
||||
///
|
||||
/// CAUTION! This method is not safe. It's not tar-bomb proof.
|
||||
/// {see http://en.wikipedia.org/wiki/Tar_(file_format) }
|
||||
/// If you are not sure about the source of an archive you extracting,
|
||||
/// then use MoveNext and Read and handle paths like ".." and "../.." according
|
||||
/// to your business logic.
|
||||
public void ReadToEnd(string destDirectory)
|
||||
{
|
||||
while (MoveNext(false))
|
||||
{
|
||||
string fileNameFromArchive = FileInfo.FileName;
|
||||
string totalPath = destDirectory + Path.DirectorySeparatorChar + fileNameFromArchive;
|
||||
if(UsTarHeader.IsPathSeparator(fileNameFromArchive[fileNameFromArchive.Length -1]) || FileInfo.EntryType == EntryType.Directory)
|
||||
{
|
||||
// Record is a directory
|
||||
Directory.CreateDirectory(totalPath);
|
||||
continue;
|
||||
}
|
||||
// If record is a file
|
||||
string fileName = Path.GetFileName(totalPath);
|
||||
string directory = totalPath.Remove(totalPath.Length - fileName.Length);
|
||||
Directory.CreateDirectory(directory);
|
||||
using (FileStream file = File.Create(totalPath))
|
||||
{
|
||||
Read(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read data from a current file to a Stream.
|
||||
/// </summary>
|
||||
/// <param name="dataDestanation">A stream to read data to</param>
|
||||
///
|
||||
/// <seealso cref="MoveNext"/>
|
||||
public void Read(Stream dataDestanation)
|
||||
{
|
||||
Debug.WriteLine("tar stream position Read in: " + inStream.Position);
|
||||
int readBytes;
|
||||
byte[] read;
|
||||
while ((readBytes = Read(out read)) != -1)
|
||||
{
|
||||
Debug.WriteLine("tar stream position Read while(...) : " + inStream.Position);
|
||||
dataDestanation.Write(read, 0, readBytes);
|
||||
}
|
||||
Debug.WriteLine("tar stream position Read out: " + inStream.Position);
|
||||
}
|
||||
|
||||
protected int Read(out byte[] buffer)
|
||||
{
|
||||
if(remainingBytesInFile == 0)
|
||||
{
|
||||
buffer = null;
|
||||
return -1;
|
||||
}
|
||||
int align512 = -1;
|
||||
long toRead = remainingBytesInFile - 512;
|
||||
|
||||
if (toRead > 0)
|
||||
toRead = 512;
|
||||
else
|
||||
{
|
||||
align512 = 512 - (int)remainingBytesInFile;
|
||||
toRead = remainingBytesInFile;
|
||||
}
|
||||
|
||||
int bytesRead = 0;
|
||||
long bytesRemainingToRead = toRead;
|
||||
do
|
||||
{
|
||||
|
||||
bytesRead = inStream.Read(dataBuffer, (int)(toRead-bytesRemainingToRead), (int)bytesRemainingToRead);
|
||||
bytesRemainingToRead -= bytesRead;
|
||||
remainingBytesInFile -= bytesRead;
|
||||
} while (bytesRead < toRead && bytesRemainingToRead > 0);
|
||||
|
||||
if(inStream.CanSeek && align512 > 0)
|
||||
{
|
||||
inStream.Seek(align512, SeekOrigin.Current);
|
||||
}
|
||||
else
|
||||
while(align512 > 0)
|
||||
{
|
||||
inStream.ReadByte();
|
||||
--align512;
|
||||
}
|
||||
|
||||
buffer = dataBuffer;
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if all bytes in buffer are zeroes
|
||||
/// </summary>
|
||||
/// <param name="buffer">buffer to check</param>
|
||||
/// <returns>true if all bytes are zeroes, otherwise false</returns>
|
||||
private static bool IsEmpty(IEnumerable<byte> buffer)
|
||||
{
|
||||
foreach(byte b in buffer)
|
||||
{
|
||||
if (b != 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move internal pointer to a next file in archive.
|
||||
/// </summary>
|
||||
/// <param name="skipData">Should be true if you want to read a header only, otherwise false</param>
|
||||
/// <returns>false on End Of File otherwise true</returns>
|
||||
///
|
||||
/// Example:
|
||||
/// while(MoveNext())
|
||||
/// {
|
||||
/// Read(dataDestStream);
|
||||
/// }
|
||||
/// <seealso cref="Read(Stream)"/>
|
||||
public bool MoveNext(bool skipData)
|
||||
{
|
||||
Debug.WriteLine("tar stream position MoveNext in: " + inStream.Position);
|
||||
if (remainingBytesInFile > 0)
|
||||
{
|
||||
if (!skipData)
|
||||
{
|
||||
throw new TarException(
|
||||
"You are trying to change file while not all the data from the previous one was read. If you do want to skip files use skipData parameter set to true.");
|
||||
}
|
||||
// Skip to the end of file.
|
||||
if (inStream.CanSeek)
|
||||
{
|
||||
long remainer = (remainingBytesInFile%512);
|
||||
inStream.Seek(remainingBytesInFile + (512 - (remainer == 0 ? 512 : remainer) ), SeekOrigin.Current);
|
||||
}
|
||||
else
|
||||
{
|
||||
byte[] buffer;
|
||||
while (Read(out buffer) > 0)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] bytes = header.GetBytes();
|
||||
int headerRead;
|
||||
int bytesRemaining = header.HeaderSize;
|
||||
do
|
||||
{
|
||||
headerRead = inStream.Read(bytes, header.HeaderSize - bytesRemaining, bytesRemaining);
|
||||
bytesRemaining -= headerRead;
|
||||
if (headerRead <= 0 && bytesRemaining > 0)
|
||||
{
|
||||
throw new TarException("Can not read header");
|
||||
}
|
||||
} while (bytesRemaining > 0);
|
||||
|
||||
if(IsEmpty(bytes))
|
||||
{
|
||||
bytesRemaining = header.HeaderSize;
|
||||
do
|
||||
{
|
||||
headerRead = inStream.Read(bytes, header.HeaderSize - bytesRemaining, bytesRemaining);
|
||||
bytesRemaining -= headerRead;
|
||||
if (headerRead <= 0 && bytesRemaining > 0)
|
||||
{
|
||||
throw new TarException("Broken archive");
|
||||
}
|
||||
|
||||
} while (bytesRemaining > 0);
|
||||
if (bytesRemaining == 0 && IsEmpty(bytes))
|
||||
{
|
||||
Debug.WriteLine("tar stream position MoveNext out(false): " + inStream.Position);
|
||||
return false;
|
||||
}
|
||||
throw new TarException("Broken archive");
|
||||
}
|
||||
|
||||
if (header.UpdateHeaderFromBytes())
|
||||
{
|
||||
throw new TarException("Checksum check failed");
|
||||
}
|
||||
|
||||
remainingBytesInFile = header.SizeInBytes;
|
||||
|
||||
Debug.WriteLine("tar stream position MoveNext out(true): " + inStream.Position);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
127
tools/icinga2-setup-agent/tar-cs/UsTarHeader.cs
Normal file
127
tools/icinga2-setup-agent/tar-cs/UsTarHeader.cs
Normal file
@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
|
||||
namespace tar_cs
|
||||
{
|
||||
/// <summary>
|
||||
/// UsTar header implementation.
|
||||
/// </summary>
|
||||
internal class UsTarHeader : TarHeader
|
||||
{
|
||||
private const string magic = "ustar";
|
||||
private const string version = " ";
|
||||
private string groupName;
|
||||
|
||||
private string namePrefix = string.Empty;
|
||||
private string userName;
|
||||
|
||||
public override string UserName
|
||||
{
|
||||
get { return userName.Replace("\0",string.Empty); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 32)
|
||||
{
|
||||
throw new TarException("user name can not be longer than 32 chars");
|
||||
}
|
||||
userName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string GroupName
|
||||
{
|
||||
get { return groupName.Replace("\0",string.Empty); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 32)
|
||||
{
|
||||
throw new TarException("group name can not be longer than 32 chars");
|
||||
}
|
||||
groupName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string FileName
|
||||
{
|
||||
get { return namePrefix.Replace("\0", string.Empty) + base.FileName.Replace("\0", string.Empty); }
|
||||
set
|
||||
{
|
||||
if (value.Length > 100)
|
||||
{
|
||||
if (value.Length > 255)
|
||||
{
|
||||
throw new TarException("UsTar fileName can not be longer thatn 255 chars");
|
||||
}
|
||||
int position = value.Length - 100;
|
||||
|
||||
// Find first path separator in the remaining 100 chars of the file name
|
||||
while (!IsPathSeparator(value[position]))
|
||||
{
|
||||
++position;
|
||||
if (position == value.Length)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position == value.Length)
|
||||
position = value.Length - 100;
|
||||
namePrefix = value.Substring(0, position);
|
||||
base.FileName = value.Substring(position, value.Length - position);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.FileName = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool UpdateHeaderFromBytes()
|
||||
{
|
||||
byte[] bytes = GetBytes();
|
||||
UserName = Encoding.ASCII.GetString(bytes, 0x109, 32);
|
||||
GroupName = Encoding.ASCII.GetString(bytes, 0x129, 32);
|
||||
namePrefix = Encoding.ASCII.GetString(bytes, 347, 157);
|
||||
return base.UpdateHeaderFromBytes();
|
||||
}
|
||||
|
||||
internal static bool IsPathSeparator(char ch)
|
||||
{
|
||||
return (ch == '\\' || ch == '/' || ch == '|'); // All the path separators I ever met.
|
||||
}
|
||||
|
||||
public override byte[] GetHeaderValue()
|
||||
{
|
||||
byte[] header = base.GetHeaderValue();
|
||||
|
||||
Encoding.ASCII.GetBytes(magic).CopyTo(header, 0x101); // Mark header as ustar
|
||||
Encoding.ASCII.GetBytes(version).CopyTo(header, 0x106);
|
||||
Encoding.ASCII.GetBytes(UserName).CopyTo(header, 0x109);
|
||||
Encoding.ASCII.GetBytes(GroupName).CopyTo(header, 0x129);
|
||||
Encoding.ASCII.GetBytes(namePrefix).CopyTo(header, 347);
|
||||
|
||||
if (SizeInBytes >= 0x1FFFFFFFF)
|
||||
{
|
||||
byte[] bytes = BitConverter.GetBytes(IPAddress.HostToNetworkOrder(SizeInBytes));
|
||||
SetMarker(AlignTo12(bytes)).CopyTo(header, 124);
|
||||
}
|
||||
|
||||
RecalculateChecksum(header);
|
||||
Encoding.ASCII.GetBytes(HeaderChecksumString).CopyTo(header, 148);
|
||||
return header;
|
||||
}
|
||||
|
||||
private static byte[] SetMarker(byte[] bytes)
|
||||
{
|
||||
bytes[0] |= 0x80;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
private static byte[] AlignTo12(byte[] bytes)
|
||||
{
|
||||
var retVal = new byte[12];
|
||||
bytes.CopyTo(retVal, 12 - bytes.Length);
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user