summaryrefslogtreecommitdiff
path: root/roles/streaming/mpv-headless/templates
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2024-04-01 19:35:36 +0200
committerChristian Pointner <equinox@spreadspace.org>2024-04-01 19:35:36 +0200
commitc11a6871836d1baab0aa007b496e3d2c658eb2ac (patch)
tree98197931b9ec065b8d3738e52cae3468dd836021 /roles/streaming/mpv-headless/templates
parentmpv-headless: go back to using video= kernel command line option (diff)
mpv-headless: add simple ssh control interface
Diffstat (limited to 'roles/streaming/mpv-headless/templates')
-rw-r--r--roles/streaming/mpv-headless/templates/ssh-forced.sh.j231
1 files changed, 31 insertions, 0 deletions
diff --git a/roles/streaming/mpv-headless/templates/ssh-forced.sh.j2 b/roles/streaming/mpv-headless/templates/ssh-forced.sh.j2
new file mode 100644
index 00000000..777f0b32
--- /dev/null
+++ b/roles/streaming/mpv-headless/templates/ssh-forced.sh.j2
@@ -0,0 +1,31 @@
+#!/bin/sh
+
+if [ -z "${SSH_ORIGINAL_COMMAND}" ]; then
+ echo "please specify a command!"
+ exit 1
+fi
+
+command=$(echo "${SSH_ORIGINAL_COMMAND}" | awk '{print($1)}')
+arg=$(echo "${SSH_ORIGINAL_COMMAND}" | awk '{print($2)}')
+
+case "$command" in
+ list)
+ ls --hide "lost+found" -1 /srv/media
+ ;;
+ play)
+ media_file="/srv/media/$(basename "$arg")"
+ if [ -e "$media_file" ]; then
+ exec ./play "$media_file"
+ else
+ echo "file '$media_file' not found!"
+ exit 1
+ fi
+ ;;
+ stop)
+ killall mpv
+ ;;
+ *)
+ echo "invalid command: '$command'"
+ exit 1
+ ;;
+esac