提交 d28f5b9c authored 作者: 曾传波's avatar 曾传波

最新版

上级 4c47efe3
...@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.31313.79 ...@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.31313.79
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tool", "Tool\Tool.csproj", "{9B6513DB-F34F-4E5C-82D2-225D7D3B4529}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tool", "Tool\Tool.csproj", "{9B6513DB-F34F-4E5C-82D2-225D7D3B4529}"
EndProject EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "Setup\Setup.vdproj", "{BB9114B0-C3DD-4B74-9411-6D12A0A3E5A6}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -15,6 +17,8 @@ Global ...@@ -15,6 +17,8 @@ Global
{9B6513DB-F34F-4E5C-82D2-225D7D3B4529}.Debug|Any CPU.Build.0 = Debug|Any CPU {9B6513DB-F34F-4E5C-82D2-225D7D3B4529}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B6513DB-F34F-4E5C-82D2-225D7D3B4529}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B6513DB-F34F-4E5C-82D2-225D7D3B4529}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B6513DB-F34F-4E5C-82D2-225D7D3B4529}.Release|Any CPU.Build.0 = Release|Any CPU {9B6513DB-F34F-4E5C-82D2-225D7D3B4529}.Release|Any CPU.Build.0 = Release|Any CPU
{BB9114B0-C3DD-4B74-9411-6D12A0A3E5A6}.Debug|Any CPU.ActiveCfg = Debug
{BB9114B0-C3DD-4B74-9411-6D12A0A3E5A6}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -43,13 +43,15 @@ namespace Tool ...@@ -43,13 +43,15 @@ namespace Tool
this.port = new System.Windows.Forms.TextBox(); this.port = new System.Windows.Forms.TextBox();
this.Windows = new System.Windows.Forms.RadioButton(); this.Windows = new System.Windows.Forms.RadioButton();
this.Linux = new System.Windows.Forms.RadioButton(); this.Linux = new System.Windows.Forms.RadioButton();
this.Close = new System.Windows.Forms.Button();
this.Open = new System.Windows.Forms.Button();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// Detection // Detection
// //
this.Detection.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold); this.Detection.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold);
this.Detection.Location = new System.Drawing.Point(166, 44); this.Detection.Location = new System.Drawing.Point(32, 33);
this.Detection.Name = "Detection"; this.Detection.Name = "Detection";
this.Detection.Size = new System.Drawing.Size(120, 67); this.Detection.Size = new System.Drawing.Size(120, 67);
this.Detection.TabIndex = 0; this.Detection.TabIndex = 0;
...@@ -61,7 +63,7 @@ namespace Tool ...@@ -61,7 +63,7 @@ namespace Tool
// //
this.Start.Enabled = false; this.Start.Enabled = false;
this.Start.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold); this.Start.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold);
this.Start.Location = new System.Drawing.Point(363, 44); this.Start.Location = new System.Drawing.Point(180, 33);
this.Start.Name = "Start"; this.Start.Name = "Start";
this.Start.Size = new System.Drawing.Size(120, 67); this.Start.Size = new System.Drawing.Size(120, 67);
this.Start.TabIndex = 1; this.Start.TabIndex = 1;
...@@ -198,11 +200,37 @@ namespace Tool ...@@ -198,11 +200,37 @@ namespace Tool
this.Linux.UseVisualStyleBackColor = true; this.Linux.UseVisualStyleBackColor = true;
this.Linux.CheckedChanged += new System.EventHandler(this.Linux_CheckedChanged); this.Linux.CheckedChanged += new System.EventHandler(this.Linux_CheckedChanged);
// //
// Close
//
this.Close.Enabled = false;
this.Close.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Bold);
this.Close.Location = new System.Drawing.Point(328, 33);
this.Close.Name = "Close";
this.Close.Size = new System.Drawing.Size(131, 67);
this.Close.TabIndex = 4;
this.Close.Text = "关闭防火墙";
this.Close.UseVisualStyleBackColor = true;
this.Close.Click += new System.EventHandler(this.Close_Click);
//
// Open
//
this.Open.Enabled = false;
this.Open.Font = new System.Drawing.Font("微软雅黑", 16F, System.Drawing.FontStyle.Bold);
this.Open.Location = new System.Drawing.Point(487, 33);
this.Open.Name = "Open";
this.Open.Size = new System.Drawing.Size(131, 67);
this.Open.TabIndex = 5;
this.Open.Text = "打开防火墙";
this.Open.UseVisualStyleBackColor = true;
this.Open.Click += new System.EventHandler(this.Open_Click);
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(640, 432); this.ClientSize = new System.Drawing.Size(640, 432);
this.Controls.Add(this.Open);
this.Controls.Add(this.Close);
this.Controls.Add(this.Linux); this.Controls.Add(this.Linux);
this.Controls.Add(this.Windows); this.Controls.Add(this.Windows);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
...@@ -234,6 +262,8 @@ namespace Tool ...@@ -234,6 +262,8 @@ namespace Tool
private System.Windows.Forms.RadioButton Windows; private System.Windows.Forms.RadioButton Windows;
private System.Windows.Forms.RadioButton Linux; private System.Windows.Forms.RadioButton Linux;
private System.Windows.Forms.ProgressBar progressBar1; private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.Button Close;
private System.Windows.Forms.Button Open;
} }
} }
...@@ -19,7 +19,6 @@ namespace Tool ...@@ -19,7 +19,6 @@ namespace Tool
{ {
public partial class Form1 : Form public partial class Form1 : Form
{ {
Thread t1, t2;
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
...@@ -56,21 +55,22 @@ namespace Tool ...@@ -56,21 +55,22 @@ namespace Tool
SshClient ssh = new SshClient(this.host.Text, Convert.ToInt32(this.port.Text), this.name.Text, this.pwd.Text);//创建ssh连接 SshClient ssh = new SshClient(this.host.Text, Convert.ToInt32(this.port.Text), this.name.Text, this.pwd.Text);//创建ssh连接
ssh.Connect();//打开连接 ssh.Connect();//打开连接
SshCommand cmd = ssh.RunCommand("bash --login -c 'java -version'"); SshCommand cmd = ssh.RunCommand("bash --login -c 'java -version'");
if (cmd.Error.Contains("1.8")){ if (cmd.Error.Contains("1.8"))
cmd=ssh.RunCommand("cat /etc/redhat-release");//这条命令是查看centos的版本
string[] result = cmd.Execute().Split(' ');
string version = result[3];
if (Convert.ToInt32(version.Split('.')[0]) >= 8)//这个是判断centOS的版本号是否大过了8版本
{
MessageBox.Show("您的centOS版本过高");
return;
}
else//版本合适的话,Linux内需要上传文件到Linux机器中,然后在运行,这里面是所有验证都通过了
{ {
//cmd=ssh.RunCommand("cat /etc/redhat-release");//这条命令是查看centos的版本
//string[] result = cmd.Execute().Split(' ');
//string version = result[3];
// if (Convert.ToInt32(version.Split('.')[0]) >= 8)//这个是判断centOS的版本号是否大过了8版本
// {
// MessageBox.Show("您的centOS版本过高");
// return;
//}
//else//版本合适的话,Linux内需要上传文件到Linux机器中,然后在运行,这里面是所有验证都通过了
//{
MessageBox.Show("请点击启动按钮"); MessageBox.Show("请点击启动按钮");
this.Start.Enabled = true; this.Start.Enabled = true;
ssh.Dispose(); ssh.Dispose();
} //}
} }
else//这个是Linux下没有安装java环境时去执行的 else//这个是Linux下没有安装java环境时去执行的
{ {
...@@ -79,12 +79,12 @@ namespace Tool ...@@ -79,12 +79,12 @@ namespace Tool
//创建sftp对象的目的就是将java的压缩包上传到Linux上,然后给他解压并且安装 //创建sftp对象的目的就是将java的压缩包上传到Linux上,然后给他解压并且安装
sftp.Connect(); sftp.Connect();
string filename = "jdk-8u301-linux-x64.tar.gz";//这个是java安装包的名字 string filename = "jdk-8u301-linux-x64.tar.gz";//这个是java安装包的名字
FileInfo fi = new FileInfo(string.Format(@"{0}\{1}\{2}",Application.StartupPath, "Resources", filename)); FileInfo fi = new FileInfo(string.Format(@"{0}\{1}\{2}", Application.StartupPath, "Resources", filename));
Stream stream = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); Stream stream = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
sftp.UploadFile(stream, "/usr/local/src/"+filename);//这个是把Java压缩文件复制到Linux中的路径里面 sftp.UploadFile(stream, "/usr/local/src/" + filename);//这个是把Java压缩文件复制到Linux中的路径里面
cmd = ssh.CreateCommand(string.Format("tar -zxvf /usr/local/src/{0} -C /usr/local/src/", filename));//这个是将java压缩包解压到文件夹中 cmd = ssh.CreateCommand(string.Format("tar -zxvf /usr/local/src/{0} -C /usr/local/src/", filename));//这个是将java压缩包解压到文件夹中
cmd.Execute();//执行解压命令 cmd.Execute();//执行解压命令
fi = new FileInfo(string.Format(@"{0}\{1}\{2}",Application.StartupPath, "Resources", "JavaPath.sh")); fi = new FileInfo(string.Format(@"{0}\{1}\{2}", Application.StartupPath, "Resources", "JavaPath.sh"));
stream = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite); stream = new FileStream(fi.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
filename = "JavaPath.sh"; filename = "JavaPath.sh";
sftp.UploadFile(stream, "/usr/local/src/" + filename);//这个是把设置path的脚本复制到Linux中的文件夹里面 sftp.UploadFile(stream, "/usr/local/src/" + filename);//这个是把设置path的脚本复制到Linux中的文件夹里面
...@@ -148,8 +148,8 @@ namespace Tool ...@@ -148,8 +148,8 @@ namespace Tool
MaxSize = (int)stream.Length; MaxSize = (int)stream.Length;
this.progressBar1.Invoke( this.progressBar1.Invoke(
(MethodInvoker)delegate { this.progressBar1.Maximum = MaxSize; }); (MethodInvoker)delegate { this.progressBar1.Maximum = MaxSize; });
sftp.UploadFile(stream, "/java/javafilestoragepath/ServiceProxy.jar",UpdateProgresBar);//上传第二个jar包 sftp.UploadFile(stream, "/java/javafilestoragepath/ServiceProxy.jar", UpdateProgresBar);//上传第二个jar包
cmd = ssh.CreateCommand(string.Format("bash --login -c 'nohup java -jar /java/javafilestoragepath/ServiceManagement.jar > /java/javafilestoragepath/log.out &'")); cmd = ssh.CreateCommand(string.Format("bash --login -c 'nohup java -jar /java/javafilestoragepath/ServiceManagement.jar > log.out &'"));
cmd.Execute(); cmd.Execute();
//MessageBox.Show(cmd.Result); //MessageBox.Show(cmd.Result);
} }
...@@ -208,16 +208,16 @@ namespace Tool ...@@ -208,16 +208,16 @@ namespace Tool
} }
public static string[] GetValue(string[] path)//获取文件路径下包含.jar文件的路劲 public static string[] GetValue(string[] path)//获取文件路径下包含.jar文件的路劲
{ {
for(int i = 0; i < path.Length; i++) for (int i = 0; i < path.Length; i++)
{ {
if (path[i].Contains(".jar"))//如果这个路径内包含带有.jar后缀的文件 if (path[i].Contains(".jar"))//如果这个路径内包含带有.jar后缀的文件
{ {
char[] temp = path[i].ToCharArray(); char[] temp = path[i].ToCharArray();
Array.Reverse(temp); Array.Reverse(temp);
path[i] = string.Join("",temp).Split(' ')[0];//这个可以获取jar文件 path[i] = string.Join("", temp).Split(' ')[0];//这个可以获取jar文件
temp = path[i].ToCharArray(); temp = path[i].ToCharArray();
Array.Reverse(temp); Array.Reverse(temp);
path[i] = string.Join("",temp); path[i] = string.Join("", temp);
} }
else else
{ {
...@@ -260,6 +260,8 @@ namespace Tool ...@@ -260,6 +260,8 @@ namespace Tool
} }
private void Windows_CheckedChanged(object sender, EventArgs e) private void Windows_CheckedChanged(object sender, EventArgs e)
{ {
this.Close.Enabled = false;
this.Open.Enabled = false;
this.panel1.Visible = false; this.panel1.Visible = false;
this.Start.Enabled = false;//启动按钮 this.Start.Enabled = false;//启动按钮
} }
...@@ -270,9 +272,35 @@ namespace Tool ...@@ -270,9 +272,35 @@ namespace Tool
this.port.Text = "22"; this.port.Text = "22";
} }
private void Close_Click(object sender, EventArgs e)//关闭防火墙
{
SshCommand cmd = null;
SshClient ssh = new SshClient(this.host.Text, Convert.ToInt32(this.port.Text), this.name.Text, this.pwd.Text);
ssh.Connect();
cmd = ssh.CreateCommand("bash --login -c 'systemctl stop firewalld'");//关闭防火墙
cmd.Execute();
cmd.Dispose();
ssh.Dispose();
this.Detection.Enabled = true;
}
private void Open_Click(object sender, EventArgs e)//打开防火墙
{
SshCommand cmd = null;
SshClient ssh = new SshClient(this.host.Text, Convert.ToInt32(this.port.Text), this.name.Text, this.pwd.Text);
ssh.Connect();
cmd = ssh.CreateCommand("bash --login -c 'systemctl start firewalld'");//打开防火墙
cmd.Execute();
this.Detection.Enabled = false;
this.Start.Enabled = false;
}
private void Linux_CheckedChanged(object sender, EventArgs e) private void Linux_CheckedChanged(object sender, EventArgs e)
{ {
this.panel1.Visible = true; this.panel1.Visible = true;
this.Close.Enabled = true;
this.Open.Enabled = true;
this.Detection.Enabled = false;
this.Start.Enabled = false;//启动按钮 this.Start.Enabled = false;//启动按钮
} }
} }
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic> <Deterministic>true</Deterministic>
<IsWebBootstrapper>false</IsWebBootstrapper> <IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>D:\toolExe\</PublishUrl> <PublishUrl>D:\toolExe2\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled> <UpdateEnabled>false</UpdateEnabled>
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
<UpdatePeriodically>false</UpdatePeriodically> <UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired> <UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<AutorunEnabled>true</AutorunEnabled> <ApplicationRevision>23</ApplicationRevision>
<ApplicationRevision>22</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论