-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugins.example
56 lines (52 loc) · 1.42 KB
/
plugins.example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/sh
#
# Example file to demonstrate the plugin mechanism.
#
# The plugin mechanism allows to
# 1.) extend the built-in commands by custom commands
# 2.) define a custom handler that is notified on file changes
#
# All plugins may use the built-in core functions
# that are defined in /app/bin/core_functions.
#
# Requirements for a plugin command:
# - function name starts with 'get_'
# - result is written to standard out
# - errors are written to standard error
# - return code is 0 on success
# - return code is not 0 on error
#
# Requirement for a custom notify handler:
# - function name must be handle_notify
#
#
# Plugin command 'serverinfo': request 'serverinfo' from Tvheadend
#
function get_serverinfo() {
serverinfo=$(request "$TVHEADEND_HTTP_URL/api/serverinfo" 2>&1) || return "$?"
print_json "$serverinfo"
}
#
# Plugin command 'hello': check arguments and print 'hello world'
#
function get_hello() {
[ -n "$1" ] || log_error "$?" "Missing argument for hello" || return "$?"
if [ "$1" == 'world' ]; then
echo "{ \"hello\": \"world\" }"
else
echo "Unsupported argument '$1'" >&2
return 2
fi
}
#
# Custom handler: notifications will be printed only (effectively disables MQTT publishing)
#
# handle_notify() {
# log "$(date '+%Y-%m-%d %H:%M:%S') custom-notify $*"
#
# event="$1"
# directory="$2"
# file="$3"
#
# echo "Custom notify: event '$event' on file '$file' in directory '$directory'"
# }