-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YI
committed
May 1, 2018
1 parent
7c10b53
commit 010821b
Showing
136 changed files
with
3,210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,44 @@ | ||
# script | ||
脚本管理工具 | ||
脚本管理工具,管理我们许许多多的脚本文件,特别是服务器重启没设置自启的各个脚本,一个一个去启动特麻烦, | ||
项目使用Spring Boot + MySQL。 | ||
|
||
## 特性 | ||
- 支持windows 命令管理 | ||
- 支持windows 脚本管理 | ||
- 支持linux 服务器远程命令管理 | ||
- 支持linux 服务器远程脚本管理 | ||
- 支持命令和脚本查看(linux远程脚本管理查看未实现) | ||
- 支持执行结果日志输出 | ||
|
||
## 使用 | ||
|
||
通过maven工程直接引入,打包即可,不过打包之前记得修改数据库配置。 | ||
![](https://i.imgur.com/doIM2G6.png) | ||
|
||
数据库的脚本在此地。 | ||
|
||
![](https://i.imgur.com/2EFgjw0.png) | ||
|
||
|
||
## 截个图举个栗子🌰 | ||
主界面 | ||
![](https://i.imgur.com/sC2irEz.gif) | ||
查看脚本功能 | ||
![](https://i.imgur.com/UUZzdqo.gif) | ||
查看执行结果 | ||
![](https://i.imgur.com/JqvKVfX.png) | ||
|
||
## 存在问题 | ||
-是否生效选择那里没实现,不知道layui怎么初始化那块,我再研究一下 | ||
-linux远程脚本查看没实现 | ||
-为了赶时间,把代码结构写的挺差,后续再慢慢优化了 | ||
-没有安全认证,容易泄密 | ||
|
||
## 感谢 | ||
[layui][1] | ||
[1]: http://www.layui.com/ | ||
[hutool][2] | ||
[2]: http://www.hutool.cn/ | ||
## 问题建议 | ||
- 提Issues | ||
- 联系我的邮箱:ilovey_hwy@163.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.yi</groupId> | ||
<artifactId>script</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>script</name> | ||
<description>script project for Spring Boot</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.0.1.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<hutool-all.version>4.0.10</hutool-all.version> | ||
<druid.version>1.1.9</druid.version> | ||
<jsch.version>0.1.54</jsch.version> | ||
<mybatis-spring-boot-starter.version>1.3.2</mybatis-spring-boot-starter.version> | ||
<javax.servlet-api.version>3.1.0</javax.servlet-api.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-freemarker</artifactId> | ||
</dependency> | ||
|
||
<!-- druid的starter --> | ||
<dependency> | ||
<groupId>com.alibaba</groupId> | ||
<artifactId>druid</artifactId> | ||
<version>${druid.version}</version> | ||
</dependency> | ||
<!-- mybatis的starter --> | ||
<dependency> | ||
<groupId>org.mybatis.spring.boot</groupId> | ||
<artifactId>mybatis-spring-boot-starter</artifactId> | ||
<version>${mybatis-spring-boot-starter.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>mysql</groupId> | ||
<artifactId>mysql-connector-java</artifactId> | ||
<scope>runtime</scope> | ||
</dependency> | ||
|
||
<!--SSH连接工具--> | ||
<dependency> | ||
<groupId>com.jcraft</groupId> | ||
<artifactId>jsch</artifactId> | ||
<version>${jsch.version}</version> | ||
</dependency> | ||
|
||
<!--SSH读取linux文件--> | ||
<dependency> | ||
<groupId>sshtools</groupId> | ||
<artifactId>j2ssh-core</artifactId> | ||
<version>0.2.9</version> | ||
</dependency> | ||
|
||
<!--第三方开源工具类--> | ||
<dependency> | ||
<groupId>cn.hutool</groupId> | ||
<artifactId>hutool-all</artifactId> | ||
<version>${hutool-all.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<version>${javax.servlet-api.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Navicat MySQL Data Transfer | ||
Source Server : MySQL | ||
Source Server Version : 50720 | ||
Source Host : localhost:3306 | ||
Source Database : script | ||
Target Server Type : MYSQL | ||
Target Server Version : 50720 | ||
File Encoding : 65001 | ||
Date: 2018-05-01 01:24:09 | ||
*/ | ||
|
||
SET FOREIGN_KEY_CHECKS=0; | ||
|
||
-- ---------------------------- | ||
-- Table structure for script_info | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `script_info`; | ||
CREATE TABLE `script_info` ( | ||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'ID', | ||
`path` varchar(255) DEFAULT NULL COMMENT '脚本路径', | ||
`command` varchar(255) DEFAULT NULL COMMENT '命令', | ||
`type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:linux命令、1:linux shll脚本、2:windows命令、3:windows bat脚本', | ||
`remark` varchar(255) DEFAULT NULL COMMENT '备注', | ||
`enable` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:启用、1:失效', | ||
`host` varchar(255) DEFAULT NULL COMMENT '远程脚本IP', | ||
`user_name` varchar(255) DEFAULT NULL COMMENT '服务器账号', | ||
`pass_word` varchar(255) DEFAULT NULL COMMENT '服务器密码', | ||
`del` tinyint(4) NOT NULL DEFAULT '0' COMMENT '0:正常使用、-1:已被删除', | ||
`crtTime` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COMMENT='用戶表'; | ||
|
||
-- ---------------------------- | ||
-- Records of script_info | ||
-- ---------------------------- | ||
INSERT INTO `script_info` VALUES ('1', 'H:/Program Files/nginx-1.13.10/nginx.bat', 'H:/Program Files/nginx-1.13.10/nginx.bat', '3', 'nainx启动脚本', '0', null, null, null, '0', '2018-04-27 17:23:24'); | ||
INSERT INTO `script_info` VALUES ('2', 'H:/Program Files/MongoDBServer3.4/inmongod.exe', 'H:/Program Files/MongoDBServer3.4/inmongod.exe', '3', 'MongoDB启动脚本', '0', 'null', 'null', 'null', '-1', '2018-04-27 17:24:09'); | ||
INSERT INTO `script_info` VALUES ('3', 'I:/Program Files/elasticsearch-5.5.2-noed1/bin/elasticsearch.bat', 'I:/Program Files/elasticsearch-5.5.2-noed1/bin/elasticsearch.bat', '3', 'elasticsearch-5.5.2-noed1启动脚本', '0', null, null, null, '0', '2018-04-27 17:24:57'); | ||
INSERT INTO `script_info` VALUES ('4', 'H:/Program Files/elasticsearch-5.5.2-noed2/inelasticsearch.bat', 'H:/Program Files/elasticsearch-5.5.2-noed2/inelasticsearch.bat', '3', 'elasticsearch-5.5.2-noed2启动脚本', '0', null, null, null, '0', '2018-04-27 17:25:07'); | ||
INSERT INTO `script_info` VALUES ('5', 'H:/Program Files/elasticsearch-5.5.2-noed3/inelasticsearch.bat', 'H:/Program Files/elasticsearch-5.5.2-noed3/inelasticsearch.bat', '3', 'elasticsearch-5.5.2-noed3启动脚本', '0', null, null, null, '0', '2018-04-27 17:25:18'); | ||
INSERT INTO `script_info` VALUES ('6', null, 'ipconfig', '2', '查看IP地址', '0', null, null, null, '0', '2018-04-30 23:29:58'); | ||
INSERT INTO `script_info` VALUES ('7', null, 'ifconfig', '0', '查看IP地址', '0', '111.230.10.220', 'root', '123456yi', '0', '2018-05-01 00:19:10'); | ||
INSERT INTO `script_info` VALUES ('8', '/home/yi/software/tale/tale-cli', 'cd /home/yi/software/tale && ./tale-cli status', '1', '查看Tale博客状态', '0', '111.230.10.220', 'root', '123456yi', '0', '2018-05-01 00:42:46'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.yi.script; | ||
|
||
import org.mybatis.spring.annotation.MapperScan; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.web.servlet.ServletComponentScan; | ||
|
||
/** | ||
* 脚本启动程序 | ||
* @author YI | ||
* @date 2018-4-27 15:12:49 | ||
*/ | ||
@SpringBootApplication | ||
@MapperScan(basePackages = {"com.yi.script.dao"}) | ||
@ServletComponentScan(basePackages = {"com.yi.script.**"}) | ||
public class ScriptApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ScriptApplication.class, args); | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
src/main/java/com/yi/script/config/DruidConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package com.yi.script.config; | ||
|
||
import com.alibaba.druid.pool.DruidDataSource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.context.annotation.PropertySource; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* druid连接池配置 | ||
* @author YI | ||
* @date 2018-4-27 15:28:21 | ||
*/ | ||
@Configuration | ||
@PropertySource("classpath:config/druidConfig.properties") | ||
public class DruidConfiguration { | ||
private Logger logger = LoggerFactory.getLogger(DruidConfiguration.class); | ||
|
||
@Value("${spring.datasource.url}") | ||
private String dbUrl; | ||
|
||
@Value("${spring.datasource.username}") | ||
private String username; | ||
|
||
@Value("${spring.datasource.password}") | ||
private String password; | ||
|
||
@Value("${spring.datasource.driver-class-name}") | ||
private String driverClassName; | ||
|
||
@Value("${spring.datasource.initialSize}") | ||
private int initialSize; | ||
|
||
@Value("${spring.datasource.minIdle}") | ||
private int minIdle; | ||
|
||
@Value("${spring.datasource.maxActive}") | ||
private int maxActive; | ||
|
||
@Value("${spring.datasource.maxWait}") | ||
private int maxWait; | ||
|
||
@Value("${spring.datasource.timeBetweenEvictionRunsMillis}") | ||
private int timeBetweenEvictionRunsMillis; | ||
|
||
@Value("${spring.datasource.minEvictableIdleTimeMillis}") | ||
private int minEvictableIdleTimeMillis; | ||
|
||
@Value("${spring.datasource.validationQuery}") | ||
private String validationQuery; | ||
|
||
@Value("${spring.datasource.testWhileIdle}") | ||
private boolean testWhileIdle; | ||
|
||
@Value("${spring.datasource.testOnBorrow}") | ||
private boolean testOnBorrow; | ||
|
||
@Value("${spring.datasource.testOnReturn}") | ||
private boolean testOnReturn; | ||
|
||
@Value("${spring.datasource.poolPreparedStatements}") | ||
private boolean poolPreparedStatements; | ||
|
||
@Value("${spring.datasource.maxPoolPreparedStatementPerConnectionSize}") | ||
private int maxPoolPreparedStatementPerConnectionSize; | ||
|
||
@Value("${spring.datasource.filters}") | ||
private String filters; | ||
|
||
@Value("{spring.datasource.connectionProperties}") | ||
private String connectionProperties; | ||
|
||
/** | ||
* @Bean 声明,DataSource 对象为 Spring 容器所管理; | ||
* @Primary 表示这里定义的DataSource将覆盖其他来源的DataSource。 | ||
* StatFilter,用于统计监控信息。StatFilter的别名是stat。 | ||
* 统计SQL信息,合并统计。mergeStat是的MergeStatFilter缩写。 | ||
* 通过 DataSource 的属性<property name="filters" value="mergeStat" /> 或者 | ||
* connectProperties属性来打开mergeSql功能 <property name="connectionProperties" value="druid.stat.mergeSql=true" /> | ||
* StatFilter属性slowSqlMillis用来配置SQL慢的标准 | ||
* | ||
* @return | ||
*/ | ||
@Bean | ||
@Primary | ||
public DataSource dataSource() { | ||
DruidDataSource datasource = new DruidDataSource(); | ||
datasource.setUrl(dbUrl); | ||
datasource.setDriverClassName(driverClassName); | ||
datasource.setUsername(username); | ||
datasource.setPassword(password); | ||
|
||
//configuration | ||
datasource.setInitialSize(initialSize); | ||
datasource.setMinIdle(minIdle); | ||
datasource.setMaxActive(maxActive); | ||
datasource.setMaxWait(maxWait); | ||
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | ||
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | ||
datasource.setValidationQuery(validationQuery); | ||
datasource.setTestWhileIdle(testWhileIdle); | ||
datasource.setTestOnBorrow(testOnBorrow); | ||
datasource.setTestOnReturn(testOnReturn); | ||
datasource.setPoolPreparedStatements(poolPreparedStatements); | ||
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); | ||
try { | ||
/** | ||
* 设置StatFilter,用于统计监控信息。 | ||
* StatFilter的别名是stat | ||
* | ||
*/ | ||
datasource.setFilters(filters); | ||
} catch (SQLException e) { | ||
logger.error("druid configuration initialization filter : {0}",e); | ||
} | ||
datasource.setConnectionProperties(connectionProperties); | ||
|
||
return datasource; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.yi.script.config; | ||
|
||
import com.alibaba.druid.support.http.WebStatFilter; | ||
|
||
import javax.servlet.annotation.WebFilter; | ||
import javax.servlet.annotation.WebInitParam; | ||
|
||
/** | ||
* WebStatFilter用于采集web-jdbc关联监控的数据。 | ||
* 属性filterName声明过滤器的名称,可选 | ||
* 属性urlPatterns指定要过滤 的URL模式,也可使用属性value来声明.(指定要过滤的URL模式是必选属性) | ||
* @author YI | ||
* @date 2018-4-27 15:41:28 | ||
*/ | ||
@WebFilter( | ||
urlPatterns = "/demo1/*", | ||
initParams = { | ||
@WebInitParam(name = "exclusions",value = "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*") | ||
} | ||
) | ||
public class DruidStatFilter extends WebStatFilter { | ||
|
||
} |
Oops, something went wrong.