-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from yehux/dev
重新开始
- Loading branch information
Showing
550 changed files
with
146,206 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.js linguist-language=Go | ||
*.css linguist-language=Go | ||
*.html linguist-language=Go |
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,19 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
.idea | ||
vendor | ||
.DS_Store | ||
*/.DS_Store | ||
*/.idea/% | ||
*/vendor/% |
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 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 野虎团队 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,93 @@ | ||
# Coot | ||
玩转 IFTTT 体验极客生活,互联网自动化神器 | ||
 | ||
|
||
# 介绍 | ||
|
||
**Coot** 是一款 **IFTTT** 自动化神器,基于 **Golang** 开发让你体验不同的极客生活。 | ||
|
||
- **快速安装** 基于 **Golang** + **SqlLite** 开发,用户可在 **Linux** 和 **Mac** 上快速部署 | ||
- **两种语言** 支持 **Python** + **Shell** 两种语言 让用户更多的选择 | ||
- **插件库** 基于 **Github** 实现云插件库,用户无需编写代码直接使用 | ||
|
||
# 地址 | ||
|
||
- 官网:https://coot.io | ||
- Github:https://github.com/yehuio/Coot | ||
- 下载地址:https://github.com/yehuio/Coot/releases | ||
- 插件库地址:https://github.com/yehuio/Coot-Plugs | ||
|
||
# 部署说明 | ||
|
||
> 下载软件到 **Linux** or **Mac**下解压 | ||
输入 | ||
|
||
``` | ||
./coot help | ||
``` | ||
|
||
 | ||
|
||
运行 | ||
|
||
``` | ||
./coot run | ||
or | ||
./coot run 0.0.0.0:9000 | ||
``` | ||
|
||
 | ||
|
||
# 使用截图 | ||
|
||
 | ||
 | ||
|
||
|
||
# 注意事项 | ||
|
||
- 邮箱 **SMTP** 配置后需要开启方可使用 | ||
- 创建任务需要开启邮箱通知填写接收邮箱(可写多个) | ||
- 编写脚本 输出结果 0&&测试 ,没有0&& 不会进行通知 | ||
- 服务重启后,所有任务都会变成停止状态 | ||
- 目前无登录功能,对互联网开放请自设置安全限制 | ||
|
||
# Todo | ||
|
||
- [x] 任务中心 | ||
- [x] 任务添加 | ||
- [x] 任务删除 | ||
- [x] 任务执行 | ||
- [x] 任务暂停 | ||
- [x] 支持 Shell+Python | ||
- [x] 支持 秒 | ||
- [x] 支持 分钟 | ||
- [x] 支持 小时 | ||
- [x] 支持每天指定时间 | ||
- [x] 支持每月指定时间 | ||
- [x] 插件仓库 | ||
- [x] 插件列表 | ||
- [x] 插件使用 | ||
- [x] 消息通知 | ||
- [x] 仪表盘统计 | ||
- [x] 日记记录 | ||
- [x] 启动命令行 | ||
- [x] 自定义 ip 端口 | ||
- [x] 任务详情 | ||
- [x] 任务修改 | ||
- [x] 支持更多的通知方式 | ||
- [x] 是否启用登录 | ||
- [ ] 平台统计 | ||
- [ ] 手机版本优化 | ||
|
||
# 关于 | ||
|
||
- 出品:野虎团队 | ||
- URL:https://yehu.io | ||
|
||
# 反馈群: | ||
|
||
加微信拉人,请备注 **野虎** | ||
|
||
 |
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,177 @@ | ||
package dbUtil | ||
|
||
import ( | ||
"database/sql" | ||
_ "github.com/mattn/go-sqlite3" | ||
"Coot/error" | ||
) | ||
|
||
// 连接数据库 | ||
func conn() *sql.DB { | ||
db, err := sql.Open("sqlite3", "./db/coot.db") | ||
error.Check(err, "连接数据库失败") | ||
return db | ||
} | ||
|
||
// 插入数据 | ||
func Insert(sql string, args ...interface{}) int64 { | ||
/* | ||
参数说明: | ||
sql insert 语句 | ||
args insert value 参数 | ||
使用案例: | ||
sql := ` | ||
INSERT INTO coot_tasks ( | ||
task_name, | ||
task_explain, | ||
task_id, | ||
task_time_type, | ||
task_time, | ||
last_exec_time, | ||
is_plug_script, | ||
script_type, | ||
script_path, | ||
alert_type, | ||
create_time | ||
) | ||
VALUES | ||
(?,?,?,?,?,?,?,?,?,?,?); | ||
` | ||
dbUtil.Insert(sql, "插入任务测试", "测试说明", "", 1, "2", "", "1", "shell", "/scripts/myscript/test.sh", "1", "2019-07-10 16:12") | ||
*/ | ||
db := conn() | ||
stmt, _ := db.Prepare(sql) | ||
|
||
res, err := stmt.Exec(args...) | ||
error.Check(err, "插入数据失败") | ||
|
||
defer stmt.Close() | ||
|
||
id, err := res.LastInsertId() | ||
error.Check(err, "获取插入ID失败") | ||
|
||
defer db.Close() | ||
|
||
// 返回 自增长 ID | ||
return id | ||
} | ||
|
||
// 更新数据 | ||
func Update(sql string, args ...interface{}) int64 { | ||
/* | ||
参数说明: | ||
sql update 语句 | ||
args update 参数 | ||
使用案例: | ||
sql := ` | ||
UPDATE coot_tasks | ||
SET task_name = ? | ||
WHERE | ||
id = ?; | ||
` | ||
dbUtil.Update(sql, "任务更新测试", 1) | ||
*/ | ||
db := conn() | ||
stmt, _ := db.Prepare(sql) | ||
|
||
res, err := stmt.Exec(args...) | ||
|
||
error.Check(err, "更新数据失败") | ||
defer stmt.Close() | ||
|
||
affect, err := res.RowsAffected() | ||
error.Check(err, "获取影响行数失败") | ||
|
||
defer db.Close() | ||
|
||
return affect | ||
} | ||
|
||
// 查询数据 | ||
func Query(sql string, args ...interface{}) []map[string]interface{} { | ||
/* | ||
参数说明: | ||
sql select 语句 | ||
args select 参数 | ||
使用案例: | ||
sql := `select * from coot_tasks where id=?;` | ||
result := dbUtil.Query(sql, 1) | ||
*/ | ||
db := conn() | ||
|
||
rows, err := db.Query(sql, args ...) | ||
error.Check(err, "查询数据失败") | ||
|
||
defer rows.Close() | ||
|
||
columns, err := rows.Columns() | ||
error.Check(err, "查询表名失败") | ||
|
||
count := len(columns) | ||
|
||
tableData := make([]map[string]interface{}, 0) | ||
values := make([]interface{}, count) | ||
valuePtrs := make([]interface{}, count) | ||
|
||
for rows.Next() { | ||
for i := 0; i < count; i++ { | ||
valuePtrs[i] = &values[i] | ||
} | ||
rows.Scan(valuePtrs...) | ||
entry := make(map[string]interface{}) | ||
for i, col := range columns { | ||
var v interface{} | ||
val := values[i] | ||
b, ok := val.([]byte) | ||
if ok { | ||
v = string(b) | ||
} else { | ||
v = val | ||
} | ||
entry[col] = v | ||
} | ||
tableData = append(tableData, entry) | ||
} | ||
|
||
defer db.Close() | ||
|
||
return tableData | ||
} | ||
|
||
// 删除数据 | ||
func Delete(sql string, args ...interface{}) int64 { | ||
/* | ||
参数说明: | ||
sql delete 语句 | ||
args delete 参数 | ||
使用案例: | ||
sql := `delete from coot_tasks where id=?;` | ||
dbUtil.Delete(sql, 2) | ||
*/ | ||
db := conn() | ||
|
||
stmt, _ := db.Prepare(sql) | ||
|
||
res, err := stmt.Exec(args...) | ||
error.Check(err, "删除数据失败") | ||
defer stmt.Close() | ||
|
||
affect, err := res.RowsAffected() | ||
error.Check(err, "获取影响行数失败") | ||
|
||
defer db.Close() | ||
|
||
return affect | ||
} |
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,18 @@ | ||
package exec | ||
|
||
import ( | ||
"bytes" | ||
"os/exec" | ||
) | ||
|
||
func Execute(shell string) (string, error) { | ||
cmd := exec.Command("/bin/bash", "-c", shell) | ||
var out bytes.Buffer | ||
|
||
cmd.Stdout = &out | ||
err := cmd.Run() | ||
if err != nil { | ||
return "", err | ||
} | ||
return out.String(), nil | ||
} |
Oops, something went wrong.