https://github.com/martindai/http-shell
可以通过http接口执行shell脚本
https://github.com/martindai/http-shell
http shell
Last synced: 8 months ago
JSON representation
可以通过http接口执行shell脚本
- Host: GitHub
- URL: https://github.com/martindai/http-shell
- Owner: MartinDai
- License: mit
- Created: 2022-02-24T07:02:39.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-24T09:09:58.000Z (about 4 years ago)
- Last Synced: 2025-02-22T04:42:23.033Z (about 1 year ago)
- Topics: http, shell
- Language: Go
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# http-shell
提供通过http接口执行shell脚本的功能
## 编译执行
编译适合当前系统的可执行文件:
```
make http-shell
```
编译全平台的可执行文件:
```
make all
```
生成的可执行文件在bin目录下
默认端口为8080,也可以通过`-p `指定端口启动项目
## Docker运行
执行下面这行命令可以得到一个编译好的镜像
```
docker build --no-cache -t http-shell:latest .
```
编译好镜像以后,执行下面的命令,可以后台启动项目
```
docker run --name http-shell -p 8080:8080 -d http-shell:latest
```
## 接口介绍
### /sh
`/sh`接口支持使用sh命令运行指定的脚本
使用示例
```
curl --request POST 'http://127.0.0.1:8080/sh' \
--header 'Content-Type: application/json' \
--data '{
"shellPath":"/Users/martin/Downloads/test.sh"
}'
```
### /execShell
`/execShell`接口支持运行指定的脚本
使用示例
```
curl --request POST 'http://127.0.0.1:8080/execShell' \
--header 'Content-Type: application/json' \
--data '{
"shellPath":"/Users/martin/Downloads/test.sh"
}'
```