2021-10-18 08:49:16 +00:00
|
|
|
# Config UI
|
|
|
|
|
2021-10-20 15:58:14 +00:00
|
|
|
a web app to edit and action on update powered by [ACE](https://ace.c9.io/#nav=howto&api=edit_session)
|
2021-10-18 08:49:16 +00:00
|
|
|
|
2021-10-18 15:53:49 +00:00
|
|
|
```
|
|
|
|
Usage: configui [options]
|
2021-10-20 16:19:32 +00:00
|
|
|
-allow string
|
|
|
|
IPs to allow, blank to allow all
|
2021-10-18 15:53:49 +00:00
|
|
|
-bind string
|
2021-10-20 16:19:32 +00:00
|
|
|
address to bind (default "0.0.0.0:8000")
|
2021-10-18 15:53:49 +00:00
|
|
|
-c string
|
|
|
|
cmd to apply
|
|
|
|
-f string
|
|
|
|
path to config file
|
|
|
|
-log string
|
|
|
|
log to file
|
|
|
|
-n string
|
2021-10-23 04:56:24 +00:00
|
|
|
Name of file
|
2021-10-18 15:53:49 +00:00
|
|
|
-p string
|
|
|
|
path to file, precedence over config
|
2021-10-20 16:19:32 +00:00
|
|
|
-static
|
|
|
|
disable config api
|
2021-10-18 15:53:49 +00:00
|
|
|
-v show version
|
|
|
|
```
|
|
|
|
|
2021-10-20 17:23:54 +00:00
|
|
|
## Install
|
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo rm -f /usr/local/bin/configui
|
|
|
|
sudo sh -c "curl -fsSL RELEASE_URL | tar -C /usr/local/bin/ -xz"
|
|
|
|
```
|
|
|
|
|
2021-10-18 15:53:49 +00:00
|
|
|
## Config
|
|
|
|
|
|
|
|
```json
|
2021-11-01 07:58:02 +00:00
|
|
|
{
|
|
|
|
"app_name": "ConfigUI",
|
|
|
|
"base_url": "/",
|
|
|
|
"config_path": "conf.json",
|
|
|
|
"no_reconfig": false,
|
|
|
|
"allow_ip": "",
|
|
|
|
"files": [
|
|
|
|
{
|
|
|
|
"path": "main.go",
|
|
|
|
"name": "GoPlayground",
|
|
|
|
"action": "go run main.go",
|
|
|
|
"ro": false,
|
|
|
|
"lang": "",
|
|
|
|
"order": 0,
|
|
|
|
"data": ""
|
|
|
|
}
|
|
|
|
],
|
2021-11-09 03:27:58 +00:00
|
|
|
"Actions": [
|
|
|
|
{
|
|
|
|
"name": "User",
|
|
|
|
"cmd": "whoami"
|
|
|
|
}
|
|
|
|
],
|
2021-11-01 07:58:02 +00:00
|
|
|
"result_bellow": false,
|
|
|
|
"hide_config": false,
|
|
|
|
"log_path": "access.log",
|
|
|
|
"silent_sys_out": false
|
|
|
|
}
|
2021-10-18 15:53:49 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
`configui -f PATH/TO/CONFIG`
|
|
|
|
|
2021-11-09 03:27:58 +00:00
|
|
|
## Add integrations to ConfigUI
|
|
|
|
|
|
|
|
```go
|
|
|
|
cui.Integrations = append(cui.Integrations, &configui.Integration{
|
|
|
|
Name: "test", Description: "test", Cmd: func() (string, error) {
|
|
|
|
if rand.Int31n(40) > 20 {
|
|
|
|
return "ok", nil
|
|
|
|
}
|
|
|
|
return "", fmt.Errorf("error")
|
|
|
|
},
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2021-10-20 17:23:54 +00:00
|
|
|
## Systemd
|
|
|
|
|
|
|
|
```ini
|
|
|
|
; /etc/systemd/system/configui.service
|
|
|
|
[Unit]
|
|
|
|
Description=CoonfigUI Server
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
WorkingDirectory=/home/ubuntu/ConfigUI
|
|
|
|
ExecStart=configui -log access.log -f conf.json -bind 0.0.0.0:80
|
|
|
|
Restart=always
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
```
|
|
|
|
|
2021-11-01 07:58:02 +00:00
|
|
|
## Use as a sub route
|
|
|
|
|
|
|
|
```go
|
|
|
|
cui.BaseUrl = "/configui/"
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
mux.Handle("/configui/", http.StripPrefix("/configui", cui))
|
|
|
|
```
|
|
|
|
|
|
|
|
## Use as subpath in caddy
|
|
|
|
|
|
|
|
```caddyfile
|
|
|
|
DOMAIN {
|
|
|
|
...
|
|
|
|
route /configui/* {
|
|
|
|
uri strip_prefix /configui
|
|
|
|
reverse_proxy localhost:8000
|
|
|
|
}
|
|
|
|
...
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-10-18 08:49:16 +00:00
|
|
|
## Api
|
|
|
|
|
|
|
|
### Files
|
|
|
|
|
|
|
|
`GET /api/files`
|
|
|
|
|
|
|
|
res:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"test": {
|
|
|
|
"path": "test",
|
|
|
|
"name": "test",
|
|
|
|
"action": "myip local -P",
|
|
|
|
"data": ""
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### File
|
|
|
|
|
2021-10-23 04:56:24 +00:00
|
|
|
`GET /api/file?name=Name`
|
2021-10-18 08:49:16 +00:00
|
|
|
|
|
|
|
res:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"action": "myip local -P",
|
|
|
|
"data": "test",
|
|
|
|
"name": "test",
|
|
|
|
"path": "test"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Update
|
|
|
|
|
|
|
|
`POST /api/file`
|
|
|
|
|
|
|
|
req:
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"data": "test",
|
|
|
|
"name": "test",
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Apply
|
|
|
|
|
2021-10-23 04:56:24 +00:00
|
|
|
`POST /api/apply?name=Name`
|