Docs
parent
a160da3ad9
commit
26fda847ca
|
@ -35,7 +35,7 @@ var flagsPublish = append(
|
|||
&cli.StringFlag{Name: "email", Aliases: []string{"mail", "e"}, EnvVars: []string{"NTFY_EMAIL"}, Usage: "also send to e-mail address"},
|
||||
&cli.StringFlag{Name: "user", Aliases: []string{"u"}, EnvVars: []string{"NTFY_USER"}, Usage: "username[:password] used to auth against the server"},
|
||||
&cli.IntFlag{Name: "wait-pid", Aliases: []string{"pid"}, EnvVars: []string{"NTFY_WAIT_PID"}, Usage: "wait until PID exits before publishing"},
|
||||
&cli.BoolFlag{Name: "wait-cmd", Aliases: []string{"cmd", "done"}, EnvVars: []string{"NTFY_WAIT_CMD"}, Usage: "run and wait until command finishes before publishing"},
|
||||
&cli.BoolFlag{Name: "wait-cmd", Aliases: []string{"cmd", "done"}, EnvVars: []string{"NTFY_WAIT_CMD"}, Usage: "run command and wait until it finishes before publishing"},
|
||||
&cli.BoolFlag{Name: "no-cache", Aliases: []string{"C"}, EnvVars: []string{"NTFY_NO_CACHE"}, Usage: "do not cache message server-side"},
|
||||
&cli.BoolFlag{Name: "no-firebase", Aliases: []string{"F"}, EnvVars: []string{"NTFY_NO_FIREBASE"}, Usage: "do not forward message to Firebase"},
|
||||
&cli.BoolFlag{Name: "env-topic", Aliases: []string{"P"}, EnvVars: []string{"NTFY_ENV_TOPIC"}, Usage: "use topic from NTFY_TOPIC env variable"},
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package cmd
|
||||
|
||||
import "syscall"
|
||||
|
||||
func processExists(pid int) bool {
|
||||
err := syscall.Kill(pid, syscall.Signal(0))
|
||||
return err == nil
|
||||
}
|
|
@ -8,6 +8,7 @@ and the [ntfy Android app](https://github.com/binwiederhier/ntfy-android/release
|
|||
|
||||
**Features:**
|
||||
|
||||
* ntfy CLI can now [wait for a command or PID](https://ntfy.sh/docs/subscribe/cli/#wait-for-pidcommand) before publishing ([#263](https://github.com/binwiederhier/ntfy/issues/263), thanks to the [original ntfy](https://github.com/dschep/ntfy) for the idea)
|
||||
* Trace: Log entire HTTP request to simplify debugging (no ticket)
|
||||
* Allow setting user password via `NTFY_PASSWORD` env variable ([#327](https://github.com/binwiederhier/ntfy/pull/327), thanks to [@Kenix3](https://github.com/Kenix3))
|
||||
|
||||
|
|
|
@ -56,6 +56,71 @@ quick ones:
|
|||
ntfy pub mywebhook
|
||||
```
|
||||
|
||||
### Attaching a local file
|
||||
You can easily upload and attach a local file to a notification:
|
||||
|
||||
```
|
||||
$ ntfy pub --file README.md mytopic | jq .
|
||||
{
|
||||
"id": "meIlClVLABJQ",
|
||||
"time": 1655825460,
|
||||
"event": "message",
|
||||
"topic": "mytopic",
|
||||
"message": "You received a file: README.md",
|
||||
"attachment": {
|
||||
"name": "README.md",
|
||||
"type": "text/plain; charset=utf-8",
|
||||
"size": 2892,
|
||||
"expires": 1655836260,
|
||||
"url": "https://ntfy.sh/file/meIlClVLABJQ.txt"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Wait for PID/command
|
||||
If you have a long-running command, you may wrap it directly with `ntfy publish --wait-cmd`,
|
||||
or if you forgot to wrap it and it's already running, wait for the process to complete with
|
||||
`ntfy publish --wait-pid`.
|
||||
|
||||
Run a command and wait for it to complete (here: `rsync ...`):
|
||||
|
||||
```
|
||||
$ ntfy pub --wait-cmd mytopic rsync -av ./ root@example.com:/backups/ | jq .
|
||||
{
|
||||
"id": "Re0rWXZQM8WB",
|
||||
"time": 1655825624,
|
||||
"event": "message",
|
||||
"topic": "mytopic",
|
||||
"message": "Command succeeded after 56.553s: rsync -av ./ root@example.com:/backups/"
|
||||
}
|
||||
```
|
||||
|
||||
Or, if you already started the long-running process and want to wait for it, you can do this:
|
||||
|
||||
=== "Using a PID directly"
|
||||
```
|
||||
$ ntfy pub --wait-pid 8458 mytopic | jq .
|
||||
{
|
||||
"id": "orM6hJKNYkWb",
|
||||
"time": 1655825827,
|
||||
"event": "message",
|
||||
"topic": "mytopic",
|
||||
"message": "Process with PID 8458 exited after 2.003s"
|
||||
}
|
||||
```
|
||||
|
||||
=== "Using a `pidof`"
|
||||
```
|
||||
$ ntfy pub --wait-pid $(pidof rsync) mytopic | jq .
|
||||
{
|
||||
"id": "orM6hJKNYkWb",
|
||||
"time": 1655825827,
|
||||
"event": "message",
|
||||
"topic": "mytopic",
|
||||
"message": "Process with PID 8458 exited after 2.003s"
|
||||
}
|
||||
```
|
||||
|
||||
## Subscribe to topics
|
||||
You can subscribe to topics using `ntfy subscribe`. Depending on how it is called, this command
|
||||
will either print or execute a command for every arriving message. There are a few different ways
|
||||
|
|
Loading…
Reference in New Issue