From c11a6871836d1baab0aa007b496e3d2c658eb2ac Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 1 Apr 2024 19:35:36 +0200 Subject: mpv-headless: add simple ssh control interface --- .../mpv-headless/templates/ssh-forced.sh.j2 | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 roles/streaming/mpv-headless/templates/ssh-forced.sh.j2 (limited to 'roles/streaming/mpv-headless/templates') 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 -- cgit v1.2.3