diff options
author | Christian Pointner <equinox@spreadspace.org> | 2024-04-01 19:35:36 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2024-04-01 19:35:36 +0200 |
commit | c11a6871836d1baab0aa007b496e3d2c658eb2ac (patch) | |
tree | 98197931b9ec065b8d3738e52cae3468dd836021 /roles/streaming/mpv-headless/templates/ssh-forced.sh.j2 | |
parent | mpv-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/ssh-forced.sh.j2')
-rw-r--r-- | roles/streaming/mpv-headless/templates/ssh-forced.sh.j2 | 31 |
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 |