summaryrefslogtreecommitdiff
path: root/roles/streaming/mpv-headless/templates/ssh-forced.sh.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/streaming/mpv-headless/templates/ssh-forced.sh.j2')
-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